Components › Get started

On this page

clarusjs ui

Styled components for clarusjs. Copy a component's file into your project: it's yours to change. Nothing to install but @clarusjs/ui-primitives, for the parts that need behaviour.

1. Copy the theme #

Every component styles itself with the --ui- tokens. Save this as theme.css once, link it on every page (or @import it from your layout), and change the values to change the look:

css
/*
  clarusjs ui: the tokens every component styles itself with (light, and dark from the OS setting or
  data-theme="dark" on <html>). Copy this file once, link it on every page, and change the values to change the look.
  The same tokens as @clarusjs/ui.
*/

:root {
  --ui-font: system-ui, sans-serif;
  --ui-font-heading: var(--ui-font);
  --ui-font-mono: ui-monospace, monospace;
  --ui-font-size: 14px;
  --ui-radius: 8px;
  --ui-bg: #ffffff;
  --ui-fg: #17202a;
  --ui-muted: #5b6670;
  --ui-border: #c9d1d9;
  --ui-accent: #0b6e70;
  --ui-accent-fg: #ffffff;
  --ui-accent-soft: #e3f2f2;
  --ui-danger: #b42318;
  --ui-shadow: 0 8px 24px rgb(0 0 0 / 0.14);
  --ui-card: #ffffff;
  --ui-card-fg: #17202a;
  --ui-popover: #ffffff;
  --ui-popover-fg: #17202a;
  --ui-secondary: #e3f2f2;
  --ui-secondary-fg: #17202a;
  --ui-muted-bg: #e3f2f2;
  --ui-accent-soft-fg: #17202a;
  --ui-danger-fg: #ffffff;
  --ui-input: #c9d1d9;
  --ui-ring: #0b6e70;
  --ui-sidebar: #ffffff;
  --ui-sidebar-fg: #17202a;
  --ui-sidebar-accent: #e3f2f2;
  --ui-sidebar-accent-fg: #17202a;
  --ui-sidebar-border: #c9d1d9;
  --ui-success: #067647;
  --ui-success-fg: #ffffff;
  --ui-warning: #b54708;
  --ui-warning-fg: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --ui-bg: #121a1b;
    --ui-fg: #e6eded;
    --ui-muted: #9aa8a9;
    --ui-border: #2c3a3b;
    --ui-accent: #4cc9cb;
    --ui-accent-fg: #0b1415;
    --ui-accent-soft: #173233;
    --ui-danger: #ff8a80;
    --ui-shadow: 0 8px 24px rgb(0 0 0 / 0.5);
    --ui-card: #121a1b;
    --ui-card-fg: #e6eded;
    --ui-popover: #121a1b;
    --ui-popover-fg: #e6eded;
    --ui-secondary: #173233;
    --ui-secondary-fg: #e6eded;
    --ui-muted-bg: #173233;
    --ui-accent-soft-fg: #e6eded;
    --ui-danger-fg: #0b1415;
    --ui-input: #2c3a3b;
    --ui-ring: #4cc9cb;
    --ui-sidebar: #121a1b;
    --ui-sidebar-fg: #e6eded;
    --ui-sidebar-accent: #173233;
    --ui-sidebar-accent-fg: #e6eded;
    --ui-sidebar-border: #2c3a3b;
    --ui-success: #47cd89;
    --ui-success-fg: #0b1415;
    --ui-warning: #fdb022;
    --ui-warning-fg: #0b1415;
  }
}
:root[data-theme='dark'] {
  --ui-bg: #121a1b;
  --ui-fg: #e6eded;
  --ui-muted: #9aa8a9;
  --ui-border: #2c3a3b;
  --ui-accent: #4cc9cb;
  --ui-accent-fg: #0b1415;
  --ui-accent-soft: #173233;
  --ui-danger: #ff8a80;
  --ui-shadow: 0 8px 24px rgb(0 0 0 / 0.5);
  --ui-card: #121a1b;
  --ui-card-fg: #e6eded;
  --ui-popover: #121a1b;
  --ui-popover-fg: #e6eded;
  --ui-secondary: #173233;
  --ui-secondary-fg: #e6eded;
  --ui-muted-bg: #173233;
  --ui-accent-soft-fg: #e6eded;
  --ui-danger-fg: #0b1415;
  --ui-input: #2c3a3b;
  --ui-ring: #4cc9cb;
  --ui-sidebar: #121a1b;
  --ui-sidebar-fg: #e6eded;
  --ui-sidebar-accent: #173233;
  --ui-sidebar-accent-fg: #e6eded;
  --ui-sidebar-border: #2c3a3b;
  --ui-success: #47cd89;
  --ui-success-fg: #0b1415;
  --ui-warning: #fdb022;
  --ui-warning-fg: #0b1415;
}

2. Copy a component #

Pick one below or in the sidebar. Its page shows it working, how to use it, and its file to copy. Components with behaviour (a dialog, tabs) build on @clarusjs/ui-primitives:

sh
pnpm add @clarusjs/ui-primitives

Using Tailwind CSS #

The components work as they are with Tailwind (v4). To use your theme in Tailwind's classes too (bg-primary, text-muted-foreground, border-input, rounded-lg), save this as tailwind.css and import it after theme.css. Classes you pass to a component, on its tag or in parts, override its own rules: those sit in @layer components, below Tailwind's utilities.

css
/*
  Using Tailwind CSS (v4) with clarusjs ui: import this after theme.css. Tailwind's colours, radius and fonts then
  follow the --ui- tokens (shadcn's names: bg-primary, text-muted-foreground, border-input, rounded-lg…), so a theme
  you build changes both. The components keep their rules in @layer components, so Tailwind's utilities win.
*/
@import 'tailwindcss';

@theme inline {
  --color-background: var(--ui-bg);
  --color-foreground: var(--ui-fg);
  --color-card: var(--ui-card);
  --color-card-foreground: var(--ui-card-fg);
  --color-popover: var(--ui-popover);
  --color-popover-foreground: var(--ui-popover-fg);
  --color-primary: var(--ui-accent);
  --color-primary-foreground: var(--ui-accent-fg);
  --color-secondary: var(--ui-secondary);
  --color-secondary-foreground: var(--ui-secondary-fg);
  --color-muted: var(--ui-muted-bg);
  --color-muted-foreground: var(--ui-muted);
  --color-accent: var(--ui-accent-soft);
  --color-accent-foreground: var(--ui-accent-soft-fg);
  --color-destructive: var(--ui-danger);
  --color-destructive-foreground: var(--ui-danger-fg);
  --color-border: var(--ui-border);
  --color-input: var(--ui-input);
  --color-ring: var(--ui-ring);
  --color-sidebar: var(--ui-sidebar);
  --color-sidebar-foreground: var(--ui-sidebar-fg);
  --color-sidebar-accent: var(--ui-sidebar-accent);
  --color-sidebar-accent-foreground: var(--ui-sidebar-accent-fg);
  --color-sidebar-border: var(--ui-sidebar-border);
  --color-success: var(--ui-success);
  --color-success-foreground: var(--ui-success-fg);
  --color-warning: var(--ui-warning);
  --color-warning-foreground: var(--ui-warning-fg);
  --radius-lg: var(--ui-radius);
  --radius-md: calc(var(--ui-radius) - 2px);
  --radius-sm: calc(var(--ui-radius) - 4px);
  --font-sans: var(--ui-font);
  --font-heading: var(--ui-font-heading);
  --font-mono: var(--ui-font-mono);
}