Recall & Review
beginner
What is the main purpose of CSS Modules in Astro?
CSS Modules help keep CSS styles local to a component, avoiding conflicts by generating unique class names automatically.Click to reveal answer
beginner
How do you import a CSS Module in an Astro component?You import the CSS file as an object using <code>import styles from './filename.module.css';</code> and then use the styles as <code>class={styles.className}</code>.Click to reveal answer
intermediate
Why is using CSS Modules better than global CSS in component-based frameworks?
Because CSS Modules scope styles locally, they prevent style clashes and make components easier to maintain and reuse.
Click to reveal answer
beginner
What file extension is typically used for CSS Modules in Astro?
The file extension is
.module.css to indicate the CSS file should be treated as a module.Click to reveal answer
intermediate
How does Astro handle CSS Modules during build time?
Astro processes CSS Modules by generating unique class names and linking them to the imported styles object, ensuring styles apply only to the component.Click to reveal answer
What does importing a CSS Module in Astro return?
✗ Incorrect
Importing a CSS Module returns an object where keys are original class names and values are unique generated class names.
Which file extension indicates a CSS Module in Astro?
✗ Incorrect
The '.module.css' extension tells Astro to treat the CSS file as a module with scoped styles.
Why should you use CSS Modules in Astro components?
✗ Incorrect
CSS Modules scope styles locally to components, preventing conflicts and improving maintainability.
How do you apply a CSS Module class to an element in Astro?
✗ Incorrect
You apply the class by referencing the imported styles object with
class={styles.className}.What happens if two components use the same CSS class name in CSS Modules?
✗ Incorrect
CSS Modules generate unique class names per component, so same class names do not conflict.
Explain how CSS Modules help manage styles in Astro components.
Think about how styles stay inside one component without affecting others.
You got /5 concepts.
Describe the steps to use a CSS Module in an Astro component from file creation to applying styles.
Start from the CSS file and end with how the styles appear on the page.
You got /4 concepts.