Debase UI uses a very simple theming mechanism.
The styling across the components is unified through a well-defined list of CSS variables.
These variables serve a functional role as design tokens rather than hue values, for example "color-text" and not "primary-500".
Following the Installation guide, you should have defined the default variables in your project.
Once the default theme is set up, you can modify values based on your preferences.
You can edit the values directly; however, a cleaner approach is to overwrite them without changing the original, allowing you to keep track of your customizations. Here are different examples of overwrites.
Try it live:
... and more
One cool trick is that you can also add multiple themes. You can implement Light and Dark modes easily. Or, just like this website, let the visitor choose their theme on demand.
To achieve this, you can overwrite the variables conditionally.
As an example, this website uses a simple function to change the class applied to the root HTML element and juggle between different themes.
Here is the list of all the design tokens that are available in the default theme.
| --debase__color__text | Main text color. |
| --debase__color__text-sub | Sub-text color. |
| --debase__color__line | Color for borders and dividers. |
| --debase__color__background | Main background color. |
| --debase__color__background-sub | Secondary background color for contrast areas. |
| --debase__color__primary | Primary brand color for buttons and interactive elements. |
| --debase__color__primary-label | Text color compatible with primary color. |
| --debase__color__success | Color for success states and confirmations. |
| --debase__color__success-label | Text color compatible with success color. |
| --debase__color__warning | Color for warning states and cautionary actions. |
| --debase__color__warning-label | Text color compatible with warning color. |
| --debase__color__danger | Color for error states and destructive actions. |
| --debase__color__danger-label | Text color compatible with danger color. |
| --debase__spacing__x05 | Extra small spacing (4px). |
| --debase__spacing__x1 | Small spacing (8px). |
| --debase__spacing__x2 | Medium spacing (16px). |
| --debase__spacing__x3 | Large spacing (24px). |
| --debase__spacing__x4 | Extra large spacing (32px). |
| --debase__spacing__x5 | 2x extra large spacing (40px). |
| --debase__spacing__x6 | 3x extra large spacing (48px). |
| --debase__spacing__x7 | 4x extra large spacing (56px). |
| --debase__spacing__x8 | 5x extra large spacing (64px). |
| --debase__font-size__normal | Standard font size for body text. |
| --debase__font-size__small | Font size for small text elements like captions. |
| --debase__font-size__title1 | Font size for primary headings. |
| --debase__font-size__title2 | Font size for secondary headings. |
| --debase__font-size__title3 | Font size for tertiary headings. |
| --debase__font-family | Default font family with fallbacks. |
| --debase__radius | Default border radius for elements. |
| --debase__radius-strong | Larger border radius for emphasis. |