Theming
One layer of --newt-* custom properties drives every component in every flavour. Override a variable rather than a component.
Every colour, radius, shadow, font and duration in newt/ui is a CSS custom property. There is no theme object, no provider and no build step involved in changing one: the components read variables, so the variables are the theme.
The values live in one file,
packages/cli/registry/html/tokens.css, and everything else reads from it —
the Tailwind theme maps its namespaces onto the same variables, and the plain
CSS components use var(--newt-brand) directly.
Token convention
A token name says what the value is for, not what it looks like. --newt-danger
rather than --newt-red, --newt-bg-elevated rather than --newt-grey-700. That
is what lets a light palette override the same names without any component
knowing a palette changed.
| Group | Tokens |
|---|---|
| Surfaces | --newt-bg-base, --newt-bg-surface, --newt-bg-elevated, --newt-bg-floating, --newt-bg-input, --newt-bg-input-elevated, --newt-bg-hover, --newt-bg-active |
| Borders | --newt-border, --newt-border-subtle, --newt-border-strong, --newt-focus-ring |
| Text | --newt-text-primary, --newt-text-secondary, --newt-text-message, --newt-text-muted, --newt-text-link, --newt-text-danger, --newt-text-brand |
| Brand | --newt-brand, --newt-brand-hover, --newt-brand-active |
| Status | --newt-online, --newt-success, --newt-idle, --newt-dnd, --newt-offline, --newt-streaming, --newt-danger, --newt-danger-hover |
| Shape | --newt-radius-sm, --newt-radius-md, --newt-radius-lg, --newt-radius-xl, --newt-radius-full |
| Size | --newt-space-1 to --newt-space-6, --newt-space-8, --newt-control-xs, --newt-control-sm, --newt-control-md |
| Type | --newt-font-sans, --newt-font-mono, --newt-font-display, --newt-font-size-xs, --newt-font-size-sm, --newt-font-size-md, --newt-font-size-lg, --newt-line-height-tight, --newt-line-height-normal, --newt-font-weight-normal, --newt-font-weight-medium, --newt-font-weight-semibold |
| Elevation | --newt-shadow-low, --newt-shadow-high |
| Motion | --newt-duration-instant, --newt-duration-fast, --newt-duration-base, --newt-duration-slow, --newt-ease, --newt-ease-in, --newt-ease-out, --newt-ease-overlay |
Every value in the dark palette, with its light counterpart, is listed on the colours page.
Override a token
Put the override after the token block in your own stylesheet. It reaches every component that reads it, in all three flavours, at once.
:root {
/* one brand hue, and every button, link and focus ring follows */
--newt-brand: #7a5af8;
--newt-brand-hover: #6b4ce0;
--newt-brand-active: #5a3fc0;
}
Scope it to a subtree instead, and only that subtree changes:
.support-panel {
--newt-brand: var(--newt-online);
}
The light palette
A light surface set ships alongside the dark one and is opt-in. It overrides the surface, text, status and shadow tokens; everything else is shared.
<html data-newt-theme="light">
<body class="newt-root">
…
</body>
</html>
.newt-light on any wrapper does the same thing for a subtree. This site uses
the attribute — the toggle in the header sets it, which is why the chrome and
the live demos change together.
See Dark mode for wiring a persisted toggle in your own project.
Tailwind v3 and v4
The registry ships the theme three ways so one registry serves both majors, and
newtui init writes whichever your project needs.
On Tailwind v3 the tokens arrive as a preset merged into theme.extend:
import { newtPreset } from "./newt-preset"
export default {
presets: [newtPreset],
content: ["./app/**/*.{ts,tsx}", "./components/**/*.{ts,tsx}"],
}On Tailwind v4 there is no JS config. The tokens are an @theme block, and the
utilities are generated from the namespaced properties in it:
@import "tailwindcss";
@theme {
--color-newt-brand: var(--newt-brand);
--color-newt-bg-base: var(--newt-bg-base);
/* … */
}Either way the utilities are the same: bg-newt-brand, text-newt-text-muted,
border-newt-border, shadow-elevation-high, duration-fast, ease-newt.
The theme newtui init writes maps only names Tailwind does not already use:
the newt-* colours, font-display, the elevation-* shadows, the newt
easing and the fast and base durations. It never redefines --radius-*,
--font-sans or --font-mono, which would restyle every page of the app that
installs it.
If a component uses a theme name your stylesheet does not declare, add lists
it and prints the block to paste. npx newtui tokens writes that block for you.
See the CLI.
Radii and type in a host app
The components read their radii and their sans and mono stacks from the tokens
directly, not from Tailwind’s rounded-* and font-* scale:
<div
class="rounded-[var(--newt-radius-md)] font-[family-name:var(--newt-font-sans)]"
></div>
The host’s scale therefore leaves them alone. In an app with Nuxt UI,
rounded-md is 12px, but a newt/ui popout keeps the 8px of
--newt-radius-md. The same holds on Tailwind v3, where rounded-md is a
fixed 6px. Your own pages keep your scale.
To give newt/ui components your scale instead, set the tokens to it. Put the block after the newt/ui tokens:
:root {
--newt-radius-sm: 6px;
--newt-radius-md: 12px;
--newt-radius-lg: 16px;
--newt-font-sans: "Your Sans", system-ui, sans-serif;
}
To change one surface only, set the same properties on a selector of that
surface. A popout renders at the end of <body>, outside that selector, so
pass the element to its container prop to keep it inside.
Adding a token
If a value you need has no token, add the token rather than the value. Edit
tokens.css first — it is the source — then run node scripts/gen-registry.mjs
so the Tailwind v3 and v4 projections and the registry theme item pick it up.
A hardcoded hex is the one way to end up with a component that no longer follows
the rest.