0
0
Astroframework~5 mins

CSS Modules support in Astro - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AAn object mapping class names to unique generated names
BA string with all CSS content
CA function to apply styles
DA global CSS stylesheet
Which file extension indicates a CSS Module in Astro?
A.css
B.module.css
C.astro.css
D.style.css
Why should you use CSS Modules in Astro components?
ATo avoid style conflicts by scoping styles locally
BTo disable CSS caching
CTo write global styles faster
DTo inline CSS in JavaScript
How do you apply a CSS Module class to an element in Astro?
AUse <code>class="className"</code>
BUse <code>id={styles.className}</code>
CUse <code>style={styles.className}</code>
DUse <code>class={styles.className}</code>
What happens if two components use the same CSS class name in CSS Modules?
AThey share the same style globally
BAstro throws an error
CEach gets a unique generated class name to avoid conflicts
DThe last imported style overrides the others
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.