Bird
Raised Fist0
Remixframework~20 mins

CSS Modules in Remix - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
CSS Modules Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate
2:00remaining
How does CSS Modules scope styles in Remix?

Consider a Remix component importing a CSS Module file. What happens to the CSS class names when the component is rendered?

Remix
import styles from './Button.module.css';

export default function Button() {
  return <button className={styles.primary}>Click me</button>;
}
AThe class name 'primary' is replaced with a unique generated name scoped to this component.
BThe class name 'primary' is used as-is globally across the app.
CThe CSS is ignored and no styles are applied to the button.
DThe class name 'primary' is converted to inline styles automatically.
Attempts:
2 left
💡 Hint

Think about how CSS Modules prevent style conflicts by changing class names.

📝 Syntax
intermediate
1:30remaining
Which import statement correctly imports a CSS Module in Remix?

Given a CSS Module file named styles.module.css, which import statement is valid in a Remix component?

Aimport styles from './styles.module.css';
Bimport './styles.module.css';
Cimport * as styles from './styles.module.css';
Dimport styles from './styles.css';
Attempts:
2 left
💡 Hint

CSS Modules require importing the styles as an object to access class names.

🔧 Debug
advanced
2:30remaining
Why does this CSS Module style not apply in Remix?

Look at the code below. The button does not get styled as expected. What is the most likely cause?

Remix
import styles from './Button.module.css';

export default function Button() {
  return <button className="styles.primary">Click me</button>;
}
AThe CSS Module file is missing from the project directory.
BThe className is a string literal and does not reference the imported styles object.
CRemix does not support CSS Modules for button elements.
DThe styles.primary class is not defined in the CSS Module file.
Attempts:
2 left
💡 Hint

Check how the className is assigned in JSX when using CSS Modules.

❓ state_output
advanced
2:00remaining
What is the rendered class attribute value for this Remix component using CSS Modules?

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?

A"undefined" (no class applied)
B"container" (the original class name as-is)
C"container_abc123" (a unique generated name with a hash suffix)
D"styles_container" (the imported object name prefixed)
Attempts:
2 left
💡 Hint

CSS Modules add unique hashes to class names to scope styles.

🧠 Conceptual
expert
3:00remaining
Why are CSS Modules preferred over global CSS in Remix for large projects?

Choose the best explanation for why CSS Modules are often used instead of global CSS files in Remix applications.

ACSS Modules automatically convert CSS to inline styles, improving performance.
BGlobal CSS files are not supported in Remix, so CSS Modules are the only option.
CCSS Modules allow writing CSS in JavaScript syntax, which global CSS does not.
DCSS Modules scope styles locally, preventing unintended style overrides and making maintenance easier.
Attempts:
2 left
💡 Hint

Think about how style conflicts happen in big projects and how CSS Modules help.

Practice

(1/5)
1. What is the main purpose of using CSS Modules in a Remix app?
easy
A. To enable inline styles directly in JSX without CSS files
B. To keep CSS styles local to components and avoid style conflicts
C. To automatically minify CSS files for faster loading
D. To write global CSS that applies to the entire app

Solution

  1. Step 1: Understand CSS Modules concept

    CSS Modules scope CSS to components, preventing styles from leaking globally.
  2. Step 2: Compare options

    Only To keep CSS styles local to components and avoid style conflicts describes this local scoping purpose; others describe unrelated features.
  3. Final Answer:

    To keep CSS styles local to components and avoid style conflicts -> Option B
  4. Quick Check:

    CSS Modules = Local styles [OK]
Hint: CSS Modules isolate styles to components, preventing clashes [OK]
Common Mistakes:
  • Thinking CSS Modules create global styles
  • Confusing CSS Modules with inline styles
  • Assuming CSS Modules automatically minify CSS
2. Which file extension must you use for CSS files to be treated as CSS Modules in Remix?
easy
A. .css
B. .remix.css
C. .module.css
D. .cssmodule

Solution

  1. Step 1: Recall Remix CSS Modules naming convention

    Remix requires CSS Modules files to end with .module.css to enable local scoping.
  2. Step 2: Check options

    Only .module.css matches the required naming pattern; others are invalid extensions.
  3. Final Answer:

    .module.css -> Option C
  4. Quick Check:

    CSS Modules file extension = .module.css [OK]
Hint: Look for .module.css extension for CSS Modules files [OK]
Common Mistakes:
  • Using plain .css files for CSS Modules
  • Adding wrong extensions like .cssmodule
  • Confusing with other Remix file types
3. Given this Remix component code using CSS Modules:
import styles from "./Button.module.css";

export default function Button() {
  return <button className={styles.primary}>Click Me</button>;
}

And the CSS file Button.module.css contains:
.primary {
  background-color: blue;
  color: white;
}

What will be the rendered button's background color?
medium
A. Blue
B. White
C. Transparent
D. Red

Solution

  1. Step 1: Understand CSS Modules usage in component

    The component imports styles from Button.module.css and applies styles.primary as className.
  2. Step 2: Check CSS rules for .primary

    The CSS sets background-color: blue; and color: white;, so the button background is blue.
  3. Final Answer:

    Blue -> Option A
  4. Quick Check:

    styles.primary background-color = blue [OK]
Hint: ClassName from CSS Modules applies scoped styles correctly [OK]
Common Mistakes:
  • Confusing text color with background color
  • Assuming styles.primary is undefined
  • Ignoring CSS Modules scoping
4. What is wrong with this Remix component using CSS Modules?
import styles from "./Card.module.css";

export default function Card() {
  return <div className="styles.card">Content</div>;
}
medium
A. The component must use inline styles instead
B. The CSS file must be named Card.css, not Card.module.css
C. You cannot import CSS Modules in Remix components
D. The className should be {styles.card} without quotes

Solution

  1. Step 1: Identify how className is used

    The code uses className="styles.card" which treats it as a string literal, not a variable.
  2. Step 2: Correct usage of CSS Modules class

    To apply the CSS Module class, it should be className={styles.card} without quotes to use the imported object.
  3. Final Answer:

    The className should be {styles.card} without quotes -> Option D
  4. Quick Check:

    Use curly braces for CSS Modules className [OK]
Hint: Use curly braces, not quotes, for CSS Modules className [OK]
Common Mistakes:
  • Putting CSS Modules class names in quotes
  • Renaming CSS files incorrectly
  • Thinking CSS Modules can't be imported
5. You want to style two different buttons in a Remix app using CSS Modules. You have PrimaryButton.module.css and SecondaryButton.module.css. How do you ensure styles do not conflict and are applied correctly?
hard
A. Import each CSS Module in its button component and use the imported styles object for className
B. Combine both CSS files into one global CSS file and use global class names
C. Use inline styles instead of CSS Modules for both buttons
D. Rename both CSS files to the same name to share styles

Solution

  1. Step 1: Understand CSS Modules isolation

    Each CSS Module file scopes styles locally, so importing separately in each component keeps styles isolated.
  2. Step 2: Apply styles correctly

    Import the correct CSS Module in each button component and use the styles object for className to avoid conflicts.
  3. Final Answer:

    Import each CSS Module in its button component and use the imported styles object for className -> Option A
  4. Quick Check:

    Separate imports keep styles isolated [OK]
Hint: Import and use each CSS Module separately per component [OK]
Common Mistakes:
  • Merging CSS Modules into global CSS
  • Using same CSS file for different components
  • Avoiding CSS Modules and using inline styles unnecessarily
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard