Colors

Learn how Fluxon UI's semantic color system works.

Starting with Fluxon v2, Fluxon UI uses semantic design tokens instead of hardcoded color values for consistent, maintainable theming across all components. This replaces all the specific color classes used in v1.

Tailwind Utilities

Fluxon extends Tailwind CSS with custom utility classes that use semantic color tokens. Instead of using specific color values like bg-blue-500, you'll use semantic utilities that describe the purpose of the color, such as bg-primary for primary actions, text-foreground for main text, or bg-surface for card backgrounds.

These utilities work just like regular Tailwind classes but reference semantic CSS variables instead of fixed colors. This means the actual color values automatically adapt based on the current theme.

How It Works

When you use a semantic utility class like bg-primary, Tailwind generates CSS that references a CSS variable:

Generated CSS
.bg-primary {
  background-color: var(--primary);
}

.text-foreground {
  color: var(--foreground);
}

These CSS variables are defined by default in Fluxon's theme.css file (imported during installation) but can be customized to match your brand colors. The actual color values can change based on the active theme.

app.css
:root {
  /* Semantic tokens reference actual color values */
  --primary: var(--color-blue-500);
  --foreground: var(--color-zinc-700);
  --background-base: var(--color-white);
  --surface: var(--color-zinc-50);
  --border-base: var(--color-zinc-200);
}

Components then use these semantic tokens through Tailwind classes:

page.html.heex
<!-- Primary button using semantic colors -->
<button class="bg-primary text-foreground-primary hover:opacity-90">
  Click me
</button>

<!-- Card with semantic surface and border colors -->
<div class="bg-surface border border-base rounded-base">
  <h3 class="text-foreground">Card Title</h3>
  <p class="text-foreground-soft">Card description text</p>
</div>

<!-- Alert using semantic danger colors -->
<div class="bg-danger-soft text-danger border border-danger">
  Error message here
</div>

Color Tokens Reference

Below is the complete list of semantic color tokens available in Fluxon UI.

Token Tailwind Class
Brand
--primary
bg-primarytext-primaryborder-primary
--primary-soft
bg-primary-softtext-primary-softborder-primary-soft
Content
--foreground
text-foreground
--foreground-soft
text-foreground-soft
--foreground-softer
text-foreground-softer
--foreground-softest
text-foreground-softest
--foreground-primary
text-foreground-primary
Background
--background-base
bg-base
--background-sunken
bg-sunken
--background-control
bg-control
--surface
bg-surface
--background-input
bg-input
--background-input-disabled
bg-input-disabled
--background-switch
bg-switch
--background-tooltip
bg-tooltip
Border
--border-base
border-base
--border-subtle
border-subtle
--border-input
border-input
Semantic Colors
--danger
bg-dangertext-danger
--danger-soft
bg-danger-softtext-danger-soft
--danger-foreground
text-foreground-danger
--danger-soft-foreground
text-foreground-danger-soft
--danger-border
border-danger
--success
bg-successtext-success
--success-soft
bg-success-softtext-success-soft
--success-foreground
text-foreground-success
--success-soft-foreground
text-foreground-success-soft
--success-border
border-success
--warning
bg-warningtext-warning
--warning-soft
bg-warning-softtext-warning-soft
--warning-foreground
text-foreground-warning
--warning-soft-foreground
text-foreground-warning-soft
--warning-border
border-warning
--info
bg-infotext-info
--info-soft
bg-info-softtext-info-soft
--info-foreground
text-foreground-info
--info-soft-foreground
text-foreground-info-soft
--info-border
border-info
Focus States
--focus
border-focusring-focus
--focus-danger
border-focus-dangerring-focus-danger
Layout
--radius-base
rounded-base
--radius-badge
rounded-badge
--shadow-base
shadow-base

For information on theme switching, dark mode, and creating custom themes, see the Themes guide.