Theming
A step-by-step guide to customizing and extending Elemnts UI's design system to match your brand.
Customizing the Theme
Elemnts UI allows you to extend or override the default theme by adding your own design tokens, semantic tokens, and text styles in the theme.extend section of your configuration.
Modifying Design Tokens
Design tokens are the smallest building blocks of your design system, such as colors, font sizes, and spacing. You can define new tokens or override existing ones.
For example, to add a custom brand color palette:
Semantic Tokens
Semantic tokens map primitive tokens to specific contexts (e.g., danger, success, bg.primary). They are theme-aware, meaning they can adapt to light or dark modes automatically.
Here’s how to define semantic tokens for a danger color that changes between modes:
Reusable Text Styles
Text styles let you group typography properties (e.g., font family, size, weight) into reusable styles like hero, body, or caption.
Define your text styles in a separate file:
Then, include them in your configuration:
Customizing Components
Elemnts UI components are styled using Recipes and Slot Recipes. You can override these to change the default appearance of any component, such as a Button or Card.
Overriding Component Recipes
To customize a component’s styling, redefine its recipe in your configuration. For example, to style a Button with a bold font and rounded corners:
Best Practices for Theming
Follow these best practices to ensure a consistent and maintainable design system:
| Best Practice | Description |
|---|---|
| Use extend | Always place your customizations inside theme.extend to avoid accidentally overwriting the base Elemnts UI theme. |
| Reference Tokens Properly | Use the {category.name} syntax to reference tokens (e.g., {colors.red.50} or {surface.1}). |
| Leverage Theme Awareness | Use semantic tokens for colors or styles that should adapt to light/dark modes. |
| Maintain Consistency | Stick to the provided duration and easing tokens to preserve the "Elemnts" feel across your design system. |
| Organize Your Tokens | Group related tokens (e.g., colors, fonts) logically to make your configuration easier to maintain. |
Need help? Check out the Panda CSS documentation or reach out to the Elemnts UI community for support!

