Using CSS Variables and color utilities for theming.
Themes are used to customize component styles to fit the specific aesthetic of a brand or product.Themes are used to modify existing components to fit a specific visual style. By using natmfat tokens, developers can easily customize all of their components by changing a set of universal variables, eliminating the need to modify individual components.
Customizing a Theme
The default theme acts as a starting point; from there designers and developers can define how their own components and styles deviate from the default. Altering one, some, or all of the default token values will result in a new theme. The developer supplies new CSS variables in order to override the default theme.
Tokens use CSS variables as a source of truth exclusively, so code only needs to be changed once in one place to create system-wide effects. Tokens are used across all components and help keep global patterns and styles consistent. All tokens come pre-baked into natmfat, and are exposed as utility classes through the TailwindCSS integration. Tokens are simply CSS variables, but you can also import them into your projects if you need them in a JavaScript environment.
import { tokens } from "natmfat/lib/tokens";
tokens.space8; // var(--space-8)
Generally, you should not directly interact with tokens to build user interfaces or even custom components. TailwindCSS utility classes and special compositional components like Colorway can apply styles directly.There are several token categories:
Color
Spacing
Typography
Color
Each theme is assigned universal color variables, which are determined by common roles and usage. This allows for uniform color application across themes while maintaining full styling flexibility. For more information, see color.
Spacing
Use the spacing scale when building individual components. It includes small increments needed to create appropriate spatial relationships for detail-level designs. Spacing is also used to force elements to have specific sizes, like icons.
Typography
Typography has two of type styles (regular and code) that can be customized through tokens. These tokens are used both within components and across layouts. For more information, see typography.
Base Colors
For reference, here's a list of the base colors that are available.