Theming

Component description

All editable design parameters (colors, border width, shadows, …) are exposed as Design Tokens. These are carefully structured CSS variables — you should be able to guess each token’s effect from its name. Valuya uses Tailwind to handle Design Tokens and Utility Classes.

Please note that theming has its reasonable limits. While a theme covers many stylistic details, it does not affect layout or proportions.

Entrypoint

./resources/css/main.css is the entry point for theming. This file sets up the basic structure for all of Valuya’s CSS. It …

  • Sets up the cascade layers
  • Imports all Tailwind-related files and defines additional custom Tailwind utilities
  • Performs a CSS reset/normalization (via Tailwind’s preflight)
  • Imports all Design Tokens
  • Sets the base type styles and colors for the document root (HTML, Body)

Default Theme

The file ./resources/css/themes/default.css contains all design tokens, starting with the base level: spacing, color palettes, typography and so on. All these base tokens are available as Tailwind utility classes inside your markup as well. Furthermore, default.css includes all component-level tokens.

Developing a Theme With Overrides

If you expect it to maintain most of the default styling in your new theme, you should add a CSS file in ./resources/css/themes/, copy the desired tokens over and change them there. Make sure to import your theme file via ./resources/css/main.css _after_ the default theme CSS.

You will most likely only override base-level tokens but not component-level tokens. Let’s take a look at an example:

Label
--button-borderWidth: var(--stroke-width);
--badge-borderWidth: var(--stroke-width);

Both components in this example, Button and Badge, share the same border with, applied by the base-level token stroke-width. Let’s change --stroke-width to 4px:

Label
--stroke-width: 4px;

In fact, the base-level token --stroke-width changes all border-widths on all components. A single override changes the global appearance. Let’s say in our example, you wish to only change the border-with for buttons. This would move your override further down to the component-level and you would change the component token --button-borderWidth directly:

Label
--button-borderWidth: 4px;

Developing a Theme From Scratch

If you wish to make a lot of changes to the default theme, you may edit ./resources/css/themes/default.css directly.

Dark/Light Mode

Every theme is expected to be in light mode by default. If you wish to add a dark mode to your theme, include another file in ./resources/css/themes/ and maybe add -dark to the end of the file name. Take a look at ./resources/css/themes/default-dark.css for reference.