Theming
Change Wideset's colours, radius and font with CSS variables.
Wideset is themed with CSS variables. Override them in your own stylesheet, loaded after Wideset’s, and every component follows. There is no theme provider and no build step.
import '@wideset/react/styles';
import './theme.css'; // your overrides, last
Want to see it first? Themes previews brand presets on real components and gives you the CSS to copy.
Tokens
Tokens come in three layers, and each one reads the layer above it in this table.
| Layer | Example | Override it to |
|---|---|---|
| Primitive | --ws-colors-light-brand-600 |
Re-brand: every role built on it changes. |
| Dynamic | --ws-dynamic-fill-primary-default |
Change one role and keep its dark mode switch. |
| Semantic | --background-color-ws-dynamic-primary-default |
Change what a single class reads. |
Start as high in the table as covers what you want. Tokens lists every one, and the foundations pages (Colors, Typography, Spacing, Radius, Elevation) show each family.
Brand colour
The brand colour is a ramp of 11 steps, from 100 (lightest) to 1100 (darkest). There is one ramp per theme, and primary fills use step 600. Replace both ramps, or dark mode keeps the old brand.
:root {
--ws-colors-light-brand-100: #fff0f5;
/* …200 to 500 */
--ws-colors-light-brand-600: #e0115f;
/* …700 to 1000 */
--ws-colors-light-brand-1100: #48051f;
--ws-colors-dark-brand-100: #ffe3ee;
/* …200 to 500 */
--ws-colors-dark-brand-600: #d61a62;
/* …700 to 1000 */
--ws-colors-dark-brand-1100: #33081a;
}
Both ramps are defined on :root. Keep the order of the steps: text and borders on brand
surfaces pick lighter or darker steps by number.
The tinted brand backgrounds in Button, Tabs, Calendar and Table hold fixed colours, so they do
not follow a new ramp by themselves. Themes exports them with the ramps. By hand,
derive each one with color-mix():
:root {
--ws-colors-light-brand-opacity-600-8: color-mix(
in srgb,
var(--ws-colors-light-brand-600) 8%,
transparent
);
}
The light tints are 600-0, 600-4, 600-8, 600-12 and 600-16. The dark ones are 500-0,
500-8, 500-16, 500-24 and 500-32, under --ws-colors-dark-brand-opacity-*.
One role
To change the primary fill and leave the palette alone, set the dynamic role, once per theme:
:root {
--ws-dynamic-fill-primary-default: #e0115f;
--ws-dynamic-fill-primary-hover: #c20e53;
--ws-dynamic-fill-primary-pressed: #a30c46;
}
.dark {
--ws-dynamic-fill-primary-default: #d61a62;
--ws-dynamic-fill-primary-hover: #f03d7d;
--ws-dynamic-fill-primary-pressed: #b31452;
}
Radius
:root {
--radius-ws-control-md: 0.625rem;
--radius-ws-container-md: 1rem;
}
Font
Components inherit the font on body, so setting your brand font there is usually enough.
--font-ws-sans holds Wideset’s own stack and --font-ws-mono the one for code:
:root {
--font-ws-sans: 'Poppins', ui-sans-serif, system-ui, sans-serif;
}
Dark mode
Dark values live under a .dark selector. Add the class to <html>, or to any wrapper to theme
one part of the page:
document.documentElement.classList.toggle('dark');
useTheme() from @wideset/react reads and sets the class for you: isDarkTheme,
toggleTheme, setDarkTheme and setLightTheme.
Wideset does not follow the system setting. Without the class the components are light, so your
app chooses its theme. To follow the system, set the class before the first paint with an inline
script in <head>:
<script>
{
const system = window.matchMedia('(prefers-color-scheme: dark)');
const apply = () => document.documentElement.classList.toggle('dark', system.matches);
apply();
system.addEventListener('change', apply);
}
</script>
This always follows the system: when the setting changes, it replaces a theme chosen through
useTheme(). To let people choose, store their choice and run this only when none is stored.
In Next.js put it in the root layout with dangerouslySetInnerHTML and add
suppressHydrationWarning to <html>, since the class is set before React hydrates.
Surfaces that draw their own background (Card, Modal, Sidepanel, StatusModal, Popup and
the pop-ups of ComboBox, DatePicker, DateRangePicker and FilterButton) also set their text
color, so their content stays readable on a page whose own text color is
different. Text you place straight on the page takes the page’s color.
One component
Every component passes className to its root, and your classes win any conflict without
!important:
<Button preset="filled" className="rounded-ws-control-full px-ws-8">
Fully rounded
</Button>
Use token classes here too, so the instance still follows the theme and dark mode. For anything app-wide, override the token.