Guide
Theming
Override design tokens, create brand themes, and understand the light-dark() color system.
On this page
- Token hierarchy
- Light and dark
- System preference (default)
- Explicit theme
- Creating a brand theme
- Advanced: full brand ramp
- Three tokens to update together
- Corporate vs. consumer feel
- Density modes
- Built-in enterprise palette presets
- Dark-first midnight preset
- Applying a palette globally
- Scoping a palette to a sub-tree
- Reduced motion
- Contrast preference
- Forced colors (high contrast)
- Component-level theming
- Token reference
- Visual language
Porchlight is fully token-driven. Every color, spacing value, font size, radius, and motion duration is a CSS custom property you can override. This guide covers the token architecture, how to create a brand theme, and how the light/dark system works.
Token hierarchy
Tokens are split into two layers:
| Layer | Prefix | Purpose |
|---|---|---|
Primitive (02-tokens.css) |
--pl-* |
Raw design scales: font sizes, spacing steps, OKLCH color ramp, radii, motion, shadows |
Semantic (02-tokens.css) |
--pl-color-* |
Foreground/background pairs: bg, surface, text, border, accent, danger-*, success-*, warning-* |
| Component-local | --pl-c-* |
Per-component tokens defined inside @scope (e.g., --pl-c-alert-tone) |
Semantic tokens use light-dark() so they automatically adapt to the
user’s color scheme. Override primitives to retheme the entire system;
override semantic tokens to fine-tune specific roles.
Light and dark
Porchlight uses the CSS color-scheme property to drive light-dark()
color pairs. Two ways to control the active scheme:
System preference (default)
Omit the data-pl-theme attribute. The browser follows the OS setting:
<html>
<!-- follows prefers-color-scheme -->
</html>
Explicit theme
Set data-pl-theme on the root element:
<html data-pl-theme="dark">
<!-- always dark -->
</html>
Valid values: light, dark, or omit for system.
Creating a brand theme
Override the accent color pair to instantly rebrand. Both the accent and its text color need to meet WCAG-AA contrast (4.5:1 minimum):
@layer app {
:root {
/* Your brand color in OKLCH */
--pl-color-accent: oklch(55% 0.22 290deg);
--pl-color-accent-text: oklch(98% 0.01 290deg);
/* For a full custom ramp, override the brand scale. Accent tokens
resolve from --pl-brand-7 (light) and --pl-brand-4 (dark). */
/* --pl-brand-7: oklch(48% 0.18 290deg); */
/* --pl-brand-4: oklch(70% 0.14 290deg); */
}
/* Dark theme brand override */
:root[data-pl-theme="dark"] {
--pl-color-accent: oklch(70% 0.18 290deg);
--pl-color-accent-text: oklch(20% 0.05 290deg);
}
}
To go deeper, override the semantic surface/text tokens:
@layer app {
:root {
--pl-color-bg: oklch(99% 0.005 260deg);
--pl-color-surface: oklch(97% 0.008 260deg);
--pl-color-text: oklch(25% 0.02 260deg);
}
}
Advanced: full brand ramp
The accent color is derived from a 9-step brand ramp:
--pl-brand-1 (lightest) → --pl-brand-9 (darkest)
--pl-color-accent = light-dark(var(--pl-brand-7), var(--pl-brand-4))
To retheme with your brand hue, override the ramp steps. Each step varies lightness while keeping the same hue and chroma direction:
@layer app {
:root {
/* Target red: hue 25° */
--pl-brand-1: oklch(96% 0.02 25deg);
--pl-brand-2: oklch(88% 0.05 25deg);
--pl-brand-3: oklch(79% 0.09 25deg);
--pl-brand-4: oklch(69% 0.17 25deg); /* dark-mode accent */
--pl-brand-5: oklch(62% 0.19 25deg);
--pl-brand-6: oklch(55% 0.2 25deg);
--pl-brand-7: oklch(47% 0.21 25deg); /* light-mode accent */
--pl-brand-8: oklch(38% 0.16 25deg);
--pl-brand-9: oklch(29% 0.1 25deg);
}
}
Three tokens to update together
When you change the brand hue, three tokens need attention:
-
Brand ramp (
--pl-brand-1through--pl-brand-9): sets the accent. -
Focus ring (
--pl-focus-color): a separate token, not derived from the brand ramp. It defaults to hue82°(amber). Override it to match:--pl-focus-color: light-dark(oklch(50% 0.18 25deg), oklch(70% 0.15 25deg)); -
Danger hue (
--pl-color-danger): defaults tooklch(60% 0.22 25deg). If your brand is red/orange (hue ~25°), the danger state will visually collide with primary actions. Shift danger to a different hue to maintain semantic clarity:--pl-color-danger: oklch(57% 0.23 12deg); --pl-color-danger-text: light-dark( oklch(36% 0.2 12deg), oklch(90% 0.08 12deg) );
Corporate vs. consumer feel
The large-surface radius tokens control how “rounded” the framework feels:
@layer app {
:root {
/* Corporate / enterprise: tighter corners */
--pl-radius-xl: 0.5rem;
--pl-radius-2xl: 0.75rem;
/* Consumer / playful: more rounded */
/* --pl-radius-xl: 1.5rem; */
/* --pl-radius-2xl: 2rem; */
}
}
These drive card corners, dialog radius, table wrap radius, and toast radius.
Density modes
Four density presets control component geometry:
| Tier | Control height | Best for |
|---|---|---|
compact |
2rem (32px) | Admin panels, settings |
comfortable |
2.5rem (40px) | Default: most SaaS apps |
touch |
2.75rem (44px) | Mobile, tablets, kiosks |
dense |
1.75rem (28px) | SIEM, analytics, log viewers |
<div data-pl-density="compact">Tighter controls</div>
<div data-pl-density="comfortable">Default</div>
<div data-pl-density="touch">Larger touch targets</div>
<div data-pl-density="dense">Maximum information density</div>
Set on any ancestor. compact, comfortable, and touch change only
--pl-control-block-size, --pl-control-padding-inline, and
--pl-control-gap: type, spacing, and radius are unchanged.
The dense tier goes further: it also compresses the --pl-space-* scale
(~30% reduction) and small text sizes (--pl-text-sm, --pl-text-xs) for
maximum information density. See the Data-dense mode reference for details.
Built-in enterprise palette presets
Porchlight provides seven pre-baked enterprise palette presets via the data-pl-palette attribute. Each preset configures brand ramps, surfaces, text, borders, and accent colors with tested WCAG AA contrast in both light and dark modes:
| Palette | Aesthetic | Best Suited For | Accent Tone (Light / Dark) |
|---|---|---|---|
slate |
Cool neutral gray | B2B SaaS, developer tooling, workflow engines | Indigo steel (oklch(46% 0.1 250deg) / oklch(70% 0.1 250deg)) |
zinc |
Crisp monochromatic | Technical analytics, hardware consoles, terminal views | High-contrast neutral (oklch(22% 0 0deg) / oklch(92% 0 0deg)) |
midnight |
Deep nocturnal blue-gray | SOC/SIEM cockpits, dark-first monitoring dashboards | Electric cobalt (oklch(44% 0.15 275deg) / oklch(68% 0.15 275deg)) |
emerald |
Warm emerald green | Fintech, banking, sustainability, wealth management | Emerald green (oklch(43% 0.12 155deg) / oklch(71% 0.13 155deg)) |
amethyst |
Vibrant deep purple | AI / LLM observability, data science, evaluation consoles | Vibrant purple (oklch(44% 0.14 305deg) / oklch(71% 0.14 305deg)) |
crimson |
Vivid ruby/crimson | Security, incident response, high-risk SOC triage | Ruby crimson (oklch(43% 0.15 25deg) / oklch(71% 0.15 25deg)) |
cyan |
Electric cyan/teal | Cloud infrastructure, Kubernetes clusters, telemetry | Electric cyan (oklch(42% 0.11 195deg) / oklch(71% 0.12 195deg)) |
Dark-first midnight preset
Use data-pl-preset="midnight" when the product should open dark-first without
requiring two attributes. It is equivalent to data-pl-theme="dark" plus
data-pl-palette="midnight", including the derived accent, focus ring, and
contrast behavior:
<html data-pl-preset="midnight">
...
</html>
Use the explicit data-pl-theme and data-pl-palette pair when the user can
choose light mode or another palette. Use the preset when the product identity
is intentionally nocturnal, such as a SOC, telemetry, or trading console.
Applying a palette globally
Set data-pl-palette on the <html> or <body> element:
<html data-pl-palette="slate" data-pl-theme="dark">
...
</html>
Scoping a palette to a sub-tree
Palettes can be scoped to any container or card to highlight specific operational domains:
<!-- Sustainability widget using the emerald palette -->
<section class="pl-c-card" data-pl-palette="emerald">
<header class="pl-c-card__header">
<h3 class="pl-c-card__title">Carbon Offset Metrics</h3>
<span class="pl-c-badge" data-tone="success">Optimal</span>
</header>
<div class="pl-c-card__body">
<button class="pl-c-button" data-tone="primary" type="button">
View Allocation
</button>
</div>
</section>
Reduced motion
Porchlight respects prefers-reduced-motion: reduce automatically:
--pl-motion-scaledrops to0, which zeroes all duration tokens- A universal
transition-duration: 1ms !importantclamp fires on every element, guaranteeing no stray transitions outlast the preference - Scroll behavior reverts to
auto
You don’t need to do anything. This is one of the few places !important
is used (it’s an accessibility guarantee).
Contrast preference
When the browser reports prefers-contrast: more, Porchlight strengthens
the structural tokens components already use:
--pl-color-borderbecomes more visible--pl-color-surface-2separates stronger from the page background--pl-focus-sizeincreases to3px--pl-focus-glow-opacitymakes field glow rings easier to see
This is a token-level adjustment, not a separate component mode. Apps can still override these tokens in their own layer when a brand needs different contrast behavior.
Forced colors (high contrast)
Under Windows High Contrast mode, key surface, text, border, accent, and focus tokens remap to system
colors (Canvas, CanvasText, ButtonBorder, Highlight). Keep native controls and test your custom colors, borders, and icons in
forced-colors mode; framework defaults do not guarantee every app override remains legible.
Component-level theming
Each component defines --pl-c-* tokens inside its @scope. Override these
to fine-tune a specific component without touching the global palette:
@layer app {
.pl-c-card {
--pl-c-card-padding: var(--pl-space-6);
--pl-c-card-radius: var(--pl-radius-xl);
}
}
Token reference
For the complete list of tokens with live values, see the token reference pages.
Visual language
Porchlight’s visual identity is carried by tokens rather than one-off classes. Use these as the signature when customizing a product:
- Focus:
--pl-focus-color,--pl-focus-size, and--pl-shadow-glow. Keep the focus ring visible over every surface; do not remove it. - Accent:
--pl-color-accent,--pl-color-accent-hover, and--pl-color-accent-subtle. The accent is functional: primary action, active navigation, and focus. It is not a decorative fill. - Elevation:
--pl-shadow-1through--pl-shadow-3, plus the surface ladder--pl-color-bgto--pl-color-surface-2. Depth should separate layers, not decorate every card. - Motion:
--pl-duration-*,--pl-ease-*, and--pl-motion-scale. Motion confirms an action or guides attention. It should not run ambiently. - Density:
compact,comfortable, andtouch. Choose density from the workflow, not the screen size alone.
A distinctive Porchlight surface should feel calm and dense: one obvious primary action, quiet borders, tabular numbers, and a focus ring that is always visible.