Recall & Review
beginner
What is a CSS variable and why use it?
A CSS variable is a custom property that stores a value you can reuse throughout your styles. It helps keep your design consistent and makes updates easier by changing the value in one place.
Click to reveal answer
beginner
How do you define a CSS variable in Tailwind's
:root?You define CSS variables inside the
:root selector in your CSS file or inside a @layer base block in Tailwind. For example:<br>:root { --main-color: #4ade80; }Click to reveal answer
intermediate
How can you use a CSS variable inside Tailwind utility classes?
You can use the
var(--variable-name) syntax inside Tailwind's theme.extend or directly in your CSS. For example, setting a background color: bg-[color:var(--main-color)] applies the CSS variable as a background color.Click to reveal answer
intermediate
Why combine CSS variables with Tailwind instead of only using Tailwind colors?
CSS variables let you change colors dynamically (like dark mode or themes) without rebuilding Tailwind classes. They add flexibility and make your design easier to maintain and customize.Click to reveal answer
intermediate
How do you update a CSS variable value for a dark mode theme in Tailwind?
You can override the CSS variable inside a dark mode selector. For example:<br>
@media (prefers-color-scheme: dark) { :root { --main-color: #22c55e; } } This changes the variable when dark mode is active.Click to reveal answer
Where do you usually define CSS variables for use with Tailwind?
✗ Incorrect
CSS variables are custom properties defined in CSS, usually inside the :root selector or Tailwind's @layer base for global access.
How do you reference a CSS variable in Tailwind utility classes?
✗ Incorrect
Tailwind supports arbitrary values inside square brackets, so you can use CSS variables with var() syntax like bg-[color:var(--main-color)].
What is a main benefit of using CSS variables with Tailwind?
✗ Incorrect
CSS variables let you change colors or styles dynamically, such as switching themes, without needing to rebuild or change Tailwind classes.
How can you change a CSS variable for dark mode in Tailwind?
✗ Incorrect
You override CSS variables inside a dark mode selector, such as @media (prefers-color-scheme: dark) or a .dark class, to change their values.
Which syntax is correct to define a CSS variable for a green color?
✗ Incorrect
CSS variables are defined inside selectors like :root with --variable-name: value; syntax.
Explain how to set up and use a CSS variable for colors in a Tailwind project.
Think about where CSS variables live and how Tailwind allows custom values.
You got /4 concepts.
Describe how CSS variables help implement dark mode in Tailwind.
Focus on how variable values change depending on theme.
You got /4 concepts.