Consider a Remix component importing a CSS Module file. What happens to the CSS class names when the component is rendered?
import styles from './Button.module.css'; export default function Button() { return <button className={styles.primary}>Click me</button>; }
Think about how CSS Modules prevent style conflicts by changing class names.
CSS Modules generate unique class names for each imported style to avoid conflicts. This means the 'primary' class is scoped locally and renamed in the final HTML.
Given a CSS Module file named styles.module.css, which import statement is valid in a Remix component?
CSS Modules require importing the styles as an object to access class names.
To use CSS Modules, you import the CSS file as an object (default import) to access scoped class names. Importing without assignment or with wildcard is invalid for CSS Modules.
Look at the code below. The button does not get styled as expected. What is the most likely cause?
import styles from './Button.module.css'; export default function Button() { return <button className="styles.primary">Click me</button>; }
Check how the className is assigned in JSX when using CSS Modules.
Using className="styles.primary" treats it as a plain string, not the variable. It should be className={styles.primary} to apply the scoped class.
Given the CSS Module Card.module.css with a class container, and this component:
import styles from './Card.module.css';
export default function Card() {
return <div className={styles.container}>Content</div>;
}What will the class attribute look like in the browser?
CSS Modules add unique hashes to class names to scope styles.
The class name is transformed to a unique string like 'container_abc123' to avoid conflicts. It is not the plain class name or the object name.
Choose the best explanation for why CSS Modules are often used instead of global CSS files in Remix applications.
Think about how style conflicts happen in big projects and how CSS Modules help.
CSS Modules create locally scoped class names, avoiding conflicts and making it easier to manage styles in large apps. They do not convert CSS to inline styles or require CSS-in-JS syntax.