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.
/* 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
<%# 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
Marca roxa
Mesmos helpers, outras variáveis
Verde, cantos retos
Mesmos helpers, outras variáveis
<% themes = {
"Trail UI (padrão)" => "",
"Marca roxa" => "--accent: #6d28d9; --accent-dark: #5b21b6; --accent-soft: #f3effd; --accent-wash: #f7f4fe; --accent-chip: #ebe4fc; --check: #7c3aed;",
"Verde, cantos retos" => "--accent: #116b47; --accent-dark: #0d5739; --accent-soft: #e9f5ef; --accent-wash: #f1f9f5; --accent-chip: #dcefe5; --check: #15803d; --radius: 3px; --radius-control: 3px; --radius-lg: 4px; --radius-xl: 6px;"
} %>
<div class="doc-themes">
<% themes.each do |name, overrides| %>
<div style="<%= overrides %>">
<%= card(title: name, subtitle: "Mesmos helpers, outras variáveis") do |c| %>
<% c.with_action { status_pill "Ativa", status: :accent } %>
<%= stack(gap: "12px") do %>
<%= tabs(label: "Situação — #{name}") do |t| %>
<% t.with_tab "Ativas", count: 7, selected: true %>
<% t.with_tab "Concluídas", count: 2 %>
<% end %>
<%= segmented(label: "Visão — #{name}") do |views| %>
<% views.with_item "Dia", pressed: true %>
<% views.with_item "Semana" %>
<% end %>
<label class="tr-cluster"><%= check_box_tag "done", "1", true, class: "tr-check", id: nil %> Missão concluída</label>
<%= callout "Nova versão disponível.", icon: "refresh" %>
<% end %>
<% c.with_footer do %>
<%= button "Cancelar", size: :sm %>
<%= button "Salvar", size: :sm, variant: :primary, icon: "check" %>
<% end %>
<% end %>
</div>
<% end %>
</div>
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
| Variable | Default | Used for |
|---|---|---|
--surface
| #ffffff | Page and panel background; ground for every text token. |
--surface-2
| #f5f6f8 | Read-only inputs, search fields, code/key boxes inside panels. |
--surface-3
| #f7f8fa | Table header row and button hover. |
--sidebar
| #f3f4f6 | App-shell sidebar background. |
--sidebar-hover
| #e7eaee | Sidebar item hover. |
--sidebar-active
| #dde3ea | Current sidebar item. |
--row-hover
| #f8f9fb | Clickable table row hover. |
--row-group
| #f2f5f8 | Group header rows inside a table. |
--line
| #e2e5e9 | Structural borders: page header bottom, sidebar edge, table header. |
--line-soft
| #edeff2 | Dividers inside panels, table rows, popover footers. |
--field
| #d5dae0 | Borders of inputs, selects, buttons, popovers and dialogs. |
--ink
| #1f2328 | Primary text on surface, surface-2, surface-3 and sidebar. |
--ink-2
| #3a424b | Secondary strong text (mono keys, values) on surface and surface-2. |
--sidebar-ink
| #2b3036 | Sidebar item text on sidebar and sidebar-hover. |
--sidebar-ink-active
| #0f1720 | Current sidebar item text on sidebar-active. |
--muted
| #59616b | Sub-lines, hints, table header labels, empty states on surface. |
--muted-2
| #4a535d | Inactive tab labels and secondary counts on surface. |
--icon
| #6b737d | Leading and chevron icons inside triggers and search fields (icon, not text). |
--check-border
| #9aa3ad | Unchecked checkbox and radio border. |
--switch-off
| #b9c0c8 | Switch track when off. |
--chip
| #eef0f3 | Neutral count chip and neutral pill background. |
--accent
| #0b5c8a | Primary buttons, links, active tab, focus border, selected markers. White text on it. |
--accent-dark
| #0a5280 | Primary button border and hover. |
--accent-soft
| #eaf2f8 | Selected row and selected preset backgrounds; accent text reads on it. |
--accent-tint
| #e4edf5 | Hover of accent-soft surfaces (notices). |
--accent-wash
| #f0f6fb | Open trigger (popover button) background. |
--accent-chip
| #e1edf6 | Count chip on an active tab and the +N badge; accent text on it. |
--on-accent
| #ffffff | Text and icons on accent and check fills. |
--check
| #1773d1 | Checked checkboxes and radios: lighter and more vivid than accent. |
--ok
| #2f8a55 | Success dot and success text on ok-soft. |
--ok-soft
| #eef7f1 | Success pill and notice background. |
--warn
| #d97706 | Warning dot only: too light for text (3.2:1 on surface). |
--warn-text
| #8a4b00 | Warning text on surface and warn-soft. |
--warn-soft
| #fdf3e7 | Warning help box background. |
--bad
| #c2410c | Danger dot and danger fill button. |
--bad-text
| #9a3412 | Danger text on surface and bad-soft; error toast background. |
--bad-soft
| #fbede6 | Danger pill background. |
--red
| #b42318 | Invalid field border and hard-error marks. |
--neutral
| #7c8591 | Neutral status dot only (not text). |
--homolog
| #f5c451 | Test-environment banner background. |
--homolog-ink
| #3d2a00 | Text on the homolog banner. |
--sandbox
| #5b3fd1 | Sandbox (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
| #7c2ea3 | Keywords (def, do, end, if, import) on code-bg. |
--code-string
| #12703f | Strings and symbols on code-bg. |
--code-comment
| var(--muted) | Comments on code-bg. |
--code-number
| #9a4d00 | Numbers 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
| Variable | Default | Used for |
|---|---|---|
--space-2
| 2px | Gap between sidebar items; caption under a title. |
--space-4
| 4px | List padding inside menus. |
--space-6
| 6px | Icon-to-label gap in buttons; popover offset from its trigger. |
--space-8
| 8px | Gap between buttons and between filters. |
--space-10
| 10px | Horizontal padding of nav items, inputs, small buttons; gap checkbox-to-label. |
--space-12
| 12px | Table cell padding; menu row padding; gap between tabs-row items. |
--space-14
| 14px | Button horizontal padding; page header bottom; footer padding. |
--space-16
| 16px | Page header top padding. |
--space-20
| 20px | Page gutter: page header, filters, first/last table column, drawer padding. |
--space-24
| 24px | Modal padding. |
--space-48
| 48px | Empty-state vertical padding. |
Radii 6
| Variable | Default | Used for |
|---|---|---|
--radius-sm
| 5px | Checkboxes. |
--radius-control
| 6px | Sidebar items and menu/preset rows. |
--radius
| 8px | Buttons, inputs, selects, notices. |
--radius-lg
| 10px | Toasts, help boxes, switch track. |
--radius-xl
| 12px | Popovers and modal dialogs. |
--radius-pill
| 999px | Pills, count chips, dots. |
Shadows 4
| Variable | Default | Used 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
| Variable | Default | Used for |
|---|---|---|
--control-h
| 34px | Height of buttons, inputs, selects, triggers. |
--control-h-sm
| 30px | Small buttons and icon buttons. |
--nav-item-h
| 32px | Sidebar item and preset row height. |
--row-h
| 38px | Table body row height. |
--head-row-h
| 32px | Table header row height. |
--sidebar-w
| 196px | App-shell sidebar width. |
--drawer-w
| 460px | Side drawer width (max-width 100%). |