larsejaas.com
Creating UI using React, TypeScript and/or whatever gets the job done.
Let's connect!
Most of the time, you’ll want to keep styles local, but sometimes it’s useful to reference global classes, IDs, or states.
You can combine local and global selectors with the global keyword.
Here, `.someLocalClass` remains local, but its style adapts to a global state.
Most of the time, you’ll want to keep styles local, but sometimes it’s useful to reference global classes, IDs, or states.
You can combine local and global selectors with the global keyword.
Here, `.someLocalClass` remains local, but its style adapts to a global state.
If you want full type safety in TypeScript, you can generate `.d.ts` files for your CSS Modules.
A package like typed-css-modules github.com/Quramy/typed... can do this automatically for all modules.
Now classnames will be typed, avoiding typos and giving you editor autocompletion.
If you want full type safety in TypeScript, you can generate `.d.ts` files for your CSS Modules.
A package like typed-css-modules github.com/Quramy/typed... can do this automatically for all modules.
Now classnames will be typed, avoiding typos and giving you editor autocompletion.
Wrap all component styles in the `components` cascade layer.
Anything outside cascade layers has higher specificity.
This makes it easier to override component styles from the outside when needed.
Wrap all component styles in the `components` cascade layer.
Anything outside cascade layers has higher specificity.
This makes it easier to override component styles from the outside when needed.
CSS Modules let you import from other `.module.css` files — even keyframes!
The import syntax allows for renaming the keyframe animations - or use them as-is.
Now you can use the animation as if it were local.
CSS Modules let you import from other `.module.css` files — even keyframes!
The import syntax allows for renaming the keyframe animations - or use them as-is.
Now you can use the animation as if it were local.
You can “spread” one class into another using `composes`.
Works a bit like Sass mixins but stays inside the CSS Modules ecosystem.
You can “spread” one class into another using `composes`.
Works a bit like Sass mixins but stays inside the CSS Modules ecosystem.
This magical syntax gives you BOTH:
Autocomplete for "apple" and "banana"
Ability to pass any string value
How does it work? 🪄
This magical syntax gives you BOTH:
Autocomplete for "apple" and "banana"
Ability to pass any string value
How does it work? 🪄
This happens because TypeScript widens to the most general type.
This happens because TypeScript widens to the most general type.