I couldn’t manage to import my CSS file even though I already download the required node modules.
Also I change and try module
I tried to import the CSS file in my React component, though the existing CSS/SCSS file is not working when I import it.
2
Welcome to Stack Overflow!
It seems you are importing the wrong file. CardBorder.scss should be named CardBorder.module.css to match your actual import.
CardBorder.scss
CardBorder.module.css
I think that this is what you’re trying to do, even if the blog is about tailwind.
// Navigation.styles.js export default { nav: 'container', ul: [ 'flex', 'flex-col', 'justify-end', 'list-none', 'sm:flex-row', ].join(' '), li: [ 'mb-3', 'sm:ml-3', 'sm:mb-0', 'even:bg-gray-50', 'odd:bg-white', ].join(' '), a: ({ isActive }) => [ 'text-black', 'font-bold', 'inline-block', 'rounded-full', 'bg-yellow-400', 'py-1', 'px-3', isActive ? 'text-white' : 'hover:bg-yellow-500', ].join(' '), }
Usage:
// Navigation.jsx import styles from "./Navigation.styles"; const Navigation = ({ links }) => { const router = useRouter() return ( <nav className={styles.nav}> <ul className={styles.ul}> {links.map((link, index) => { const isActive = router.pathname === link.path return ( <li key={index} className={styles.li}> <a className={styles.a({ isActive })} href={link.path}> {link.name} </a> </li> ) })} </ul> </nav> ) }
Source: Simple strategy for structuring classnames
Click here to cancel reply.
2
Answers
Welcome to Stack Overflow!
It seems you are importing the wrong file.
CardBorder.scss
should be namedCardBorder.module.css
to match your actual import.I think that this is what you’re trying to do, even if the blog is about tailwind.
Usage:
Source: Simple strategy for structuring classnames