Theming

Change Trail UI's variables to give an app its own colours, corners and density.

Every colour, radius, spacing step and control size is a CSS custom property defined by componeer/tokens.css, and every component reads them with var(--…). To theme an app, redefine the variables you want in a stylesheet loaded after Componeer's. Nothing else changes: the same helpers render in the new look.

1. Create a theme stylesheet

Redefine only what changes. For a new brand colour, change the accent family together so hovers, selected rows and open triggers stay coherent.

CSS
/* app/assets/stylesheets/theme.css */
:root {
  --accent: #6d28d9;        /* primary buttons, links, current tab */
  --accent-dark: #5b21b6;   /* primary border and hover */
  --accent-soft: #f3effd;   /* selected rows, current preset */
  --accent-wash: #f7f4fe;   /* open trigger background */
  --accent-chip: #ebe4fc;   /* count chip on the active tab */
  --check: #7c3aed;         /* checked checkboxes and radios */

  --radius: 6px;            /* buttons, inputs */
  --radius-xl: 10px;        /* popovers, dialogs */
}

2. Load it after Componeer

ERB
<%# app/views/layouts/application.html.erb %>
<%= componeer_stylesheets %>
<%= stylesheet_link_tag "theme" %>

Result

The same block rendered three times; only the variables on its wrapper change. A theme can also be scoped to part of a page by setting the variables on an element instead of :root.

Keep contrast when you pick colours: text on accent is white (on-accent), so the accent needs at least 4.5:1 against white, and accent text on accent-soft needs the same. Variables defined as another variable (--toast: var(--ink)) are resolved where they are declared, so override those too when you change their source at a lower level than :root.

Trail UI (padrão)

Mesmos helpers, outras variáveis

Ativa
Nova versão disponível.

Marca roxa

Mesmos helpers, outras variáveis

Ativa
Nova versão disponível.

Verde, cantos retos

Mesmos helpers, outras variáveis

Ativa
Nova versão disponível.

All variables

Defaults are Trail UI's light theme. Changes to the defaults themselves belong in the Trail UI design system, then in a new Componeer release.

Colours 52

VariableDefaultUsed for
--surface #ffffffPage and panel background; ground for every text token.
--surface-2 #f5f6f8Read-only inputs, search fields, code/key boxes inside panels.
--surface-3 #f7f8faTable header row and button hover.
--sidebar #f3f4f6App-shell sidebar background.
--sidebar-hover #e7eaeeSidebar item hover.
--sidebar-active #dde3eaCurrent sidebar item.
--row-hover #f8f9fbClickable table row hover.
--row-group #f2f5f8Group header rows inside a table.
--line #e2e5e9Structural borders: page header bottom, sidebar edge, table header.
--line-soft #edeff2Dividers inside panels, table rows, popover footers.
--field #d5dae0Borders of inputs, selects, buttons, popovers and dialogs.
--ink #1f2328Primary text on surface, surface-2, surface-3 and sidebar.
--ink-2 #3a424bSecondary strong text (mono keys, values) on surface and surface-2.
--sidebar-ink #2b3036Sidebar item text on sidebar and sidebar-hover.
--sidebar-ink-active #0f1720Current sidebar item text on sidebar-active.
--muted #59616bSub-lines, hints, table header labels, empty states on surface.
--muted-2 #4a535dInactive tab labels and secondary counts on surface.
--icon #6b737dLeading and chevron icons inside triggers and search fields (icon, not text).
--check-border #9aa3adUnchecked checkbox and radio border.
--switch-off #b9c0c8Switch track when off.
--chip #eef0f3Neutral count chip and neutral pill background.
--accent #0b5c8aPrimary buttons, links, active tab, focus border, selected markers. White text on it.
--accent-dark #0a5280Primary button border and hover.
--accent-soft #eaf2f8Selected row and selected preset backgrounds; accent text reads on it.
--accent-tint #e4edf5Hover of accent-soft surfaces (notices).
--accent-wash #f0f6fbOpen trigger (popover button) background.
--accent-chip #e1edf6Count chip on an active tab and the +N badge; accent text on it.
--on-accent #ffffffText and icons on accent and check fills.
--check #1773d1Checked checkboxes and radios: lighter and more vivid than accent.
--ok #2f8a55Success dot and success text on ok-soft.
--ok-soft #eef7f1Success pill and notice background.
--warn #d97706Warning dot only: too light for text (3.2:1 on surface).
--warn-text #8a4b00Warning text on surface and warn-soft.
--warn-soft #fdf3e7Warning help box background.
--bad #c2410cDanger dot and danger fill button.
--bad-text #9a3412Danger text on surface and bad-soft; error toast background.
--bad-soft #fbede6Danger pill background.
--red #b42318Invalid field border and hard-error marks.
--neutral #7c8591Neutral status dot only (not text).
--homolog #f5c451Test-environment banner background.
--homolog-ink #3d2a00Text on the homolog banner.
--sandbox #5b3fd1Sandbox (fake data) banner background; on-accent text on it.
--toast var(--ink)Toast background; on-accent text on it.
--scrim rgba(15, 23, 32, 0.32)Backdrop behind modal dialogs.
--code-bg var(--surface)Code area of a code block (its bar sits on surface-3).
--code-ink var(--ink-2)Plain code text and punctuation on code-bg.
--code-keyword #7c2ea3Keywords (def, do, end, if, import) on code-bg.
--code-string #12703fStrings and symbols on code-bg.
--code-comment var(--muted)Comments on code-bg.
--code-number #9a4d00Numbers and constants on code-bg.
--code-name var(--accent)Functions, classes, HTML tags and ERB delimiters on code-bg.
--code-attr var(--warn-text)HTML attributes, instance variables and keys on code-bg.

Spacing 11

VariableDefaultUsed for
--space-2 2pxGap between sidebar items; caption under a title.
--space-4 4pxList padding inside menus.
--space-6 6pxIcon-to-label gap in buttons; popover offset from its trigger.
--space-8 8pxGap between buttons and between filters.
--space-10 10pxHorizontal padding of nav items, inputs, small buttons; gap checkbox-to-label.
--space-12 12pxTable cell padding; menu row padding; gap between tabs-row items.
--space-14 14pxButton horizontal padding; page header bottom; footer padding.
--space-16 16pxPage header top padding.
--space-20 20pxPage gutter: page header, filters, first/last table column, drawer padding.
--space-24 24pxModal padding.
--space-48 48pxEmpty-state vertical padding.

Radii 6

VariableDefaultUsed for
--radius-sm 5pxCheckboxes.
--radius-control 6pxSidebar items and menu/preset rows.
--radius 8pxButtons, inputs, selects, notices.
--radius-lg 10pxToasts, help boxes, switch track.
--radius-xl 12pxPopovers and modal dialogs.
--radius-pill 999pxPills, count chips, dots.

Shadows 4

VariableDefaultUsed for
--shadow-popover 0 12px 32px rgba(15, 23, 32, 0.16)Popovers and menus.
--shadow-modal 0 20px 48px rgba(15, 23, 32, 0.22)Modal dialogs.
--shadow-toast 0 10px 28px rgba(15, 23, 32, 0.24)Toasts.
--shadow-drawer -8px 0 24px rgba(15, 23, 32, 0.1)Side drawer on the right edge.

Sizes 7

VariableDefaultUsed for
--control-h 34pxHeight of buttons, inputs, selects, triggers.
--control-h-sm 30pxSmall buttons and icon buttons.
--nav-item-h 32pxSidebar item and preset row height.
--row-h 38pxTable body row height.
--head-row-h 32pxTable header row height.
--sidebar-w 196pxApp-shell sidebar width.
--drawer-w 460pxSide drawer width (max-width 100%).