Getting started

Styling

How Trame UI is styled: tokens, themes, light and dark, moods, and the one CSS import that brings them.

Trame UI has no styles of its own beyond its tokens. Every component and block reads CSS variables, through Tailwind utilities mapped to them. Change the variables, and everything follows.

Tokens

A token is a named design decision: a colour role, a radius, a font, a duration. Trame’s tokens have one definition, in the DTCG format (the W3C design tokens format). The CSS is generated from it, never written by hand.

The names are roles, not colours. You will see them in the blocks’ classes:

Kind Examples
Surfaces and text bg-background, bg-card, bg-muted, text-foreground, text-muted-foreground, border-border
Brand bg-brand, bg-brand-soft, text-brand-foreground
States bg-info-soft with text-info-foreground, and the same for the other states
Radii rounded-card, rounded-panel, rounded-control, rounded-pill
Type text-punchline, text-display-lg, text-display-md, text-display-sm, text-lead, text-eyebrow

Blocks never use a Tailwind palette class (gray-500, white…), a fixed colour or the dark: variant. Light, dark and the moods all come from the tokens.

The CSS import

The first item you install copies the theme’s CSS into components/trame/styles/. Import its index.css once, in your app’s main CSS, in place of your own @import 'tailwindcss':

@import './components/trame/styles/index.css';

It brings, in this order: Tailwind, tw-animate-css, the tokens, light, dark, moods, type, controls, motion, and tailwind-theme.css. That last file maps the utilities above (bg-brand, rounded-pill, text-eyebrow…) to the variables. Without it, those classes match nothing.

In a project with a src/ folder, the path is ./src/components/trame/styles/index.css, or relative to where your CSS file lives. See Installation.

Themes

Trame UI comes with 26 themes, from the quiet minimal and graphite to the loud citrus and vermilion. Each one is a full set of tokens generated from a few decisions: a brand colour, a neutral temperature, an accent, a radius and fonts.

Browse them on the themes page. To switch from the default theme to another one, follow Themes.

Light and dark

Light is the default. For dark, set the dark class on the <html> element:

<html class="dark">

Inside a dark page, a container with the light class stays light. Use it for an illustration or a preview that must keep its light colours.

Trame does not pick the mode for you. To follow the visitor’s system setting, toggle the dark class from your app, for example from prefers-color-scheme.

Moods

A mood is a band of the page with its own colours. Put a mood-* class on a container:

Mood What it is
inverse A dark band on a light page
brand A band in the brand colour
warm A quiet band tinted by the accent: for a story, a promise, a newsletter
tint A light band in the brand’s palest tints
<section class="mood-inverse">…</section>

A mood redefines the tokens inside the container, so every component in it stays right. Many blocks take the mood as a prop (options.mood) and put the class on their section for you.

A block’s root is a plain <section>: it writes no data-* attribute of its own. To style or find a block from your app, wrap it in your own element and select that wrapper. The tr-* classes inside blocks are internal and can change in any release.

Contrast

Every theme is checked. Each text pair reads at 4.5:1 or more against its background, in light, dark and every mood. Indicators (icons, dots, borders) aim for 3:1.

When you add your own text on a soft state background, use that state’s foreground: text-info-foreground on bg-info-soft. text-warning and text-success are for icons and indicators, not for words.

Your own theme

You have three ways, from the smallest change to the largest:

  1. Override a few variables. Import index.css, then set the variables you want to change in your own CSS, after the import. Keep the text pairs readable.
  2. Use another predefined theme, as Themes shows.
  3. Bring a theme of your own, for example one made with Trame’s token generator, which builds a full theme from a brand colour, a neutral temperature, an accent, a radius and fonts, and checks its contrast.

With a theme of your own, do not import index.css. Keep Tailwind and your theme’s CSS files, then import only Trame’s tailwind-theme.css after them, so the blocks’ utilities map to your variables:

@import './components/trame/styles/tailwind-theme.css';

Your theme must define the same variable names as Trame’s tokens.css, theme-light.css and theme-dark.css: the blocks read those names. Adjust the paths to where your files live.