Styling and texts
This guide shows how to make a theme look like the brand. It also covers the theme's own words and how they are translated.
How styling works
Your theme's look is a set of design tokens, and each token becomes a --eldra-* CSS variable. The @eldrajs/ui components read those variables, so changing a token restyles every button, field and card. Your own markup in blocks uses Tailwind classes that point at the same variables.
Change the look
Colours live in tokens.json at the theme root. Each colour id becomes --eldra-color-<id>. Here is the brand group from the starter:
{
"colors": {
"primary": {
"label": "Primary",
"value": "#1e4646",
"group": "Brand",
"allowSiteOverride": true
},
"primary-contrast": {
"label": "Primary contrast",
"value": "#f7f4ee",
"group": "Brand",
"allowSiteOverride": true
}
}
}Change value and rebuild. The theme's markup and the kit's components both follow.
Keep the colour ids
The ids must match the role names @eldrajs/ui reads: background, surface, surface-strong, border, border-strong, overlay, text, muted, primary, primary-contrast, accent, accent-contrast, success, warning, danger, focus and focus-inner. A renamed id connects to nothing.
Fonts, corner radius and control height are set in CSS, not in tokens.json. Put them on :root in app/assets/main.css. This is the starter's version, shortened:
:root {
--eldra-font-heading: 'Iowan Old Style', Palatino, Georgia, serif;
--eldra-font-body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
--eldra-radius-xl: 1.25rem;
--eldra-control-height: 2.75rem;
}The package names fonts but never downloads them. To use a brand face, load it yourself and put it first in the stack.
What the merchant can change
| Setting | Who sets it | Where |
|---|---|---|
| Colours | You set the defaults. A merchant can override any colour with allowSiteOverride: true. | tokens.json, then Studio |
Container widths and gutters (narrow, content, wide, full) | Same as colours. | tokens.json, then Studio |
| Fonts, radius, spacing, type sizes | Only you. | main.css |
A merchant's change shows in the open preview at once. The live site gets it at the next rebuild, which Studio starts for them.
Design tokens has the full detail.
Tailwind setup
The starter's app/assets/main.css starts with these four lines:
@import 'tailwindcss';
@import '@eldrajs/ui/tailwind.css';
@import '@eldrajs/ui/components.css';
@source '../../blocks';tailwindcssis Tailwind v4.@eldrajs/ui/tailwind.cssmaps the tokens to Tailwind classes:bg-primary,text-muted,border-border,rounded-md,font-heading,text-bodyand more.@eldrajs/ui/components.cssis the kit's prebuilt components.
Register Tailwind's Vite plugin yourself in nuxt.config.ts:
import tailwindcss from '@tailwindcss/vite';
export default defineNuxtConfig({
vite: { plugins: [tailwindcss()] },
});Don't drop the @source line
Nuxt's root is app/, so Tailwind never looks in blocks/ on its own. Without @source '../../blocks', classes used only in blocks are missing from the live site. Storybook still looks right, because it scans blocks/ itself. To check a build, search the emitted _nuxt/entry.*.css for a class only a block uses.
Write classes as literal text in your source. Never build a class name from a field value.
Starter kit §1 explains the rest of the CSS entry.
Restyle a kit component
Try the component's CSS variables first. Use the classes prop when a variable does not cover it.
CSS variables. Set one on :root and every instance follows. For example, Button reads --eldra-button-radius:
:root {
--eldra-button-radius: var(--eldra-radius-full);
}Set variables on :root, not on a wrapper. Menus and panels from Select or SearchBar render outside your wrapper, so they would not see it.
The classes prop. It styles one named part inside a component. class styles the outermost element. Your classes win over the component's own, so you only write what you change:
<Button class="px-8" :classes="{ label: 'font-bold' }">Checkout</Button>A plain class replaces every state. bg-red-600 on a Button also replaces its hover colour, so write bg-red-600 hover:bg-red-700.
Each component's parts and variables are on its page in Components. The UI components page covers the stylesheets.
Layout and container queries
A block can sit in a full-width row or a narrow column. So blocks respond to their own width, not the screen's. Every block root is a query container, and you style with container variants:
<script setup lang="ts">
import { Container, Section } from '@eldrajs/ui';
</script>
<template>
<Section>
<Container width="wide">
<ul class="grid grid-cols-1 gap-4 @tablet:grid-cols-2 @content:grid-cols-3">
<slot />
</ul>
</Container>
</Section>
</template>| Variant | Applies when the block is at least |
|---|---|
@tablet: | 48rem |
@content: | 64rem |
@wide: | 80rem |
Use @min-[…]: for a one-off width. Section and Container give a block its spacing, maximum width and gutters, so a block writes none of its own.
Theme reference explains how a content-sized block is measured.
Texts and translations
Your theme's own words live in i18n/<locale>.json at the theme root. These are labels, button text and empty states, not the merchant's content. One file per language:
{ "breadcrumbs": { "home": "Home" } }{ "breadcrumbs": { "home": "Heim" } }A block reads them with plain vue-i18n:
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
const { t } = useI18n();
</script>
<template>
<a href="/">{{ t('breadcrumbs.home') }}</a>
</template>The default language is set in package.json, and its file holds the full set of keys:
{ "eldra": { "defaultLocale": "en-US" } }Other files may leave keys out, and those keys fall back. A key that is not in the default file fails the build.
Escape the @ sign
vue-i18n treats @ as syntax. Write a literal one as {'@'}, as in "name{'@'}example.com".
What the merchant can do. In Studio, Content → Theme texts lists every key. A merchant can change any text, or translate it into a language you ship no file for. The preview updates at once, and the live site at the next rebuild. Studio can also export a language as a JSON file, so you can commit their wording into i18n/.
Theme texts has the fallback order and the rules for keys. Starter kit §5 shows how the starter organises them.
Prices and dates
The page's language decides the words. The shop's regional format, set in Studio, decides how money, numbers and dates are written. So an English page for an Icelandic shop can still print "4.790 kr.". Render prices with the kit's <Price> and they follow the regional format on their own. For money inside a sentence, use formatCurrency from @eldrajs/ui, not Intl.NumberFormat. For your own dates, read the format with useEldraRegion(), or copy the starter's useFormatDate() from app/composables/useRegionalFormat.ts.
See Regional format and Money and number formatting.
More
- Design tokens: how tokens and overrides reach a build.
- Theme texts: the message files in depth.
- Starter kit conventions: the starter's styling, strings and languages.
- Theme reference: layout, languages and regional format.
- UI components and the component pages.
- Pages, routes and menus: languages in URLs and links.
- Deploy: how a change reaches the live site.