elements
Start Docs Blog Demos UI Pricing
Elements Manual
  • Getting Started
  • CLI
  • Build
  • Browser
  • Packages
  • TypeScript
  • Elements HTML
  • Assets
  • RPC
  • Router
  • Session
  • Database
  • Migrations
  • LiveTable
  • Channel
  • Jobs
  • Email
  • Payments
  • JSON
  • Async
  • Style
    • Install
    • Tokens
    • Base elements
    • Typography
    • Layout
    • Components
    • Utilities
    • Theming
    • Overriding
    • Email
    • Reference
  • UI
  • JSOC
  • Config
  • Tests
  • Logs
  • Deploy
  • Editors
  • Recipes
  • Licenses
  • Issues
  • Changelog
Manual / Style/ Overriding

Overriding

elements man style/overriding

On This Page

  • The layer order
  • Three levels of override: token, component, one-off
  • Always use semantic tokens, not hex
  • Where app CSS goes

Your app's CSS overrides the package's CSS. The package puts its rules in cascade layers, and a rule of yours in a later layer, or outside any layer, applies over them. Semantic tokens let you change a value once for every component that reads it. You never need !important, and you never need to out-specify a component selector.

The layer order

The root entry declares one layer order:

Layer order
@layer reset, tokens, base, components, templates, utilities, overrides;

The component classes are in the components layer, and the stylesheets of the @elements/ui templates put their rules in the templates layer. templates is declared after components, so a template's rule applies over a component class's rule. utilities is declared after both, so a utility class on the template's markup applies over both.

A rule in a later layer applies over a rule in an earlier layer regardless of selector specificity. Every override on this page follows from that order:

  • A low-specificity body rule of yours in a later layer applies over a high-specificity component selector, because the browser compares layer order before it compares specificity.
  • The overrides layer is reserved for your app and is declared last, so a rule you put in overrides applies over every rule in the package.
  • Unlayered CSS applies over all layers. The cascade ranks a rule written outside any layer above every layered rule, so app CSS that is in no layer applies over the entire package.

This is why bare-element styling and components never need !important to be overridden. The browser compares layer order before specificity, and your rules are in a later layer than the package's, or in no layer.

Three levels of override: token, component, one-off

Pick the first level that does the job, in this order.

1. Retarget a token (system-wide). Change a value once and every component that reads it follows. This is the primary mechanism, so use it first.

Token override
:root { --accent: #4a7bc4; /* rebrand every button, link, ring, selection */ --radius: 8px; /* rounder controls and surfaces everywhere */ --ink: #0f172a; /* shift the primary text color */ }

In a scaffolded app, app/shared/styles/vars.css is exactly this file. It's imported by both the page and email baselines, so a token you set there applies across the whole app.

2. Restyle a component family (targeted). Write a rule against the component class in the overrides layer (or unlayered). overrides is declared after components, so your rule applies over the component's rule:

Component override
@layer overrides { .card { box-shadow: var(--shadow-md); border-radius: var(--radius-lg); } }

3. One-off tweaks (local). Use a utility class, an is- modifier, or a page-scoped rule for a single element. The utilities layer comes after the components layer, so they win; a page's own style.css rule wins as app CSS.

Utility classes
<div class="card shadow-lg rounded-xl">…</div>

Always use semantic tokens, not hex

When you override, use the semantic token, not a raw value or ramp step:

Semantic tokens
/* Do this: stays correct in light and dark mode */ .note { color: var(--ink-soft); background: var(--bg-soft); } /* Not this: a hardcoded value opts out of theming and breaks dark mode */ .note { color: #475569; background: #f8fafc; }

A hardcoded color won't flip in dark mode and won't follow a rebrand. The semantic tokens (--ink*, --bg*, --rule*, --accent*, the status triples) exist so your overrides inherit theming automatically.

Where app CSS goes

  • App-wide tokens → app/shared/styles/vars.css (imported by the page and email baselines).

  • App-wide rules → app/shared/styles/page.css, after @import "@elements/ui".

  • A full brand theme → copy themes/customer-example.css into app/shared/styles/ and import it from page.css after the package. See branding (opens in a new tab).

  • Page-specific rules → the page's own style.css, which imports #app/shared/styles/page.css and adds .<page-name>-* rules built on tokens.

  • Template rules → the template's own style.css, with no imports. It uses the tokens and classes the page already loaded. Only a top-level page's style.css imports page.css.

All of these are either in the overrides layer, which is declared last, or outside any layer, so their rules apply over the package's rules without !important.

Prev Dark modeNext Email
Product
Manual Pricing Compare
Company
History Contact
Legal
Privacy Policy Acceptable Use Terms License Agreement
© Elements Dev Corporation 2026