Themes and customization

Start with a built-in theme, add your brand palette and customize individual components through their public API.

Apply a brand layer to a complete theme

Import base.css, fonts/gavia.css and themes/gavia.css, then your brand CSS. Keep data-wl-theme="gavia" and data-wl-brand="my-brand" on the same element, including for a nested theme: inherited aliases can otherwise retain the parent palette. The custom-theme starter supplies theme.css with palette roles for primary actions, links, focus and selected states; the full guide explains each role.

Show Vue code
import "legato-ui/styles/base.css";
import "legato-ui/styles/fonts/gavia.css";
import "legato-ui/themes/gavia.css";
import "./theme.css";

document.documentElement.dataset.wlTheme = "gavia";
document.documentElement.dataset.wlBrand = "my-brand";

Select a theme before mounting

Set data-wl-theme on the document root or a containing element. The public theme composable can resolve light, dark and system preferences; use its early initialization script to avoid a flash of the wrong mode.

Show Vue code
import { useWlTheme } from "legato-ui/composables";
const theme = useWlTheme({ themes: { light: "gavia", dark: "gavia-dark" } });

Keep application transitions under your control

The themes option also accepts a reactive getter. Map both light and dark to the user's explicit selection to keep it independent of OS changes. With target: () => null, useWlTheme only resolves the choice, so your application can apply it inside its own snapshot transition. resolveWlTheme is the pure SSR/early-resolution helper; wlThemeInitScript accepts a static pair.

Choose a stable decorative color

getWlColorFromString maps the same trimmed NFC name to the same palette entry during SSR and in the browser. Its default palette returns foundation token references; pass an ordered nonempty palette for your brand. Keep the person's name and check contrast separately: the mapping does not guarantee unique or accessible foreground colors.

Show Vue code
import { getWlColorFromString } from "legato-ui/utils";
const outline = getWlColorFromString("Anna Mikhailova");
const brandOutline = getWlColorFromString("Anna Mikhailova", ["coral", "indigo"] as const);

Choose props, slots and pass-through sections

Use props for documented variants and behavior, tokens for shared visual roles, and slots for application content. WlConfig.pt sets app defaults; a local pt prop customizes one instance. Class and style values merge in default → app → instance order. Add your own class through class or a documented pt section, then style that class in application CSS. Preserve accessible names, focus and event handlers. Icon buttons use their own iconButton configuration.

Check the colors your application uses

Check normal, hover and active action text, links on each surface, selected text and focus against adjacent surfaces. Aim for 4.5:1 for ordinary text and 3:1 for relevant control boundaries and focus indicators. The starter records specific color pairs; those checks do not certify every component state, custom content or dark mode. Use a separate palette and repeat the checks for each supported base theme.

Generate CSS from user settings

createWlTheme from legato-ui/theme returns CSS, computed overrides and a report for selected contrast pairs. Palette changes follow the base theme, then manual overrides win. Full mode creates a complete custom theme; delta keeps the base and brand on the same element. The function has no Vue, DOM or Node runtime imports.

Show Vue code
import { createWlTheme } from "legato-ui/theme";

const result = createWlTheme({
  schemaVersion: 2,
  name: "my-brand",
  baseTheme: "gavia",
  palette: { primary: "#245bd1" },
  overrides: { "--wl-card-padding-inline": "1.25rem" },
  mode: "delta"
});
// result.css, result.overrides, result.contrast

Keep a config for builds and CI

Download JSON v2 from Theme Builder and pass it unchanged to gavia-theme. The config contains user inputs; generated bindings remain output. The CLI needs Node 22.13+. Its --check mode writes nothing and fails on stale CSS or failed contrast pairs. Old v1 exports retain palette-only import behavior; their derived fields do not become manual overrides.

Show Vue code
pnpm exec gavia-theme --config my-brand.theme.json --output src/theme.css
pnpm exec gavia-theme --config my-brand.theme.json --output src/theme.css --check
Source and guide