I am trying to animate some things using Motion (previously Framer Motion) for React (19) in a NextJS 15 project.
The problem is, that I cannot apply the colors defined in the global.css file in different variables to the motion.div component.
Here is the code snippet I am working with
import React from 'react';
import { motion } from 'motion/react';
type Props = {
target: string;
title: string;
};
const NavLink = (props: Props) => {
return (
<motion.div
layout
className="mt-1 cursor-pointer uppercase text-xs mx-2 relative"
initial={{ color: `var(--muted)` }} // <---- Not Applying
whileHover={{ color: ['var(--muted)', 'var(--primary)'] }} // <---- Not Working
transition={{ duration: 0.2 }}
onClick={() => console.log(props.target)}
>
{props.title}
</motion.div>
);
};
export default NavLink;
The Tailwindcss classes are not changing either, so instead if I try to do className: 'text-muted' does not work in motion, otherwise it does.
Not sure what the issue is, I am relatively new to NextJS and first time using Framer motion, so I'm probably not doing something obvious.