Rokkit 1.0.0-next.134

Theming & Design

Skins, color tokens, CSS architecture, and visual customization

Theming

Rokkit separates layout CSS (structural) from theme CSS (visual). Components ship unstyled with data-* attribute hooks. Themes provide the visual layer — colors, radii, shadows — without touching structure.

Overview

Add a data attribute to <html> and import the theme CSS:

<html data-palette="rokkit" data-mode="dark">

Color System

Rokkit uses semantic z-depth color tokens that automatically adapt between light and dark modes. The system provides consistent visual hierarchy without manual color management.

Z-Depth Tokens

Colors use a numbered z-depth system (z1 through z10) where lower numbers are subtle and higher numbers are prominent:

TokenLight ModeDark ModeUsage
z150950Subtle backgrounds
z2100900Borders, dividers
z3200800Hover backgrounds
z4300700Active states
z5400600Muted text
z6500500Body text
z7600400Emphasis text
z8700300Headings
z9800200High contrast
z10900100Maximum contrast

Color Palettes

Rokkit includes these semantic color groups:

  • surface — Neutral grays for backgrounds, text, and borders
  • primary — Brand color for primary actions and focus states
  • secondary — Accent color for highlights and active indicators
  • accent — Additional emphasis color
  • success, warning, danger, info — Status colors

Usage

Use z-depth tokens as UnoCSS utility classes. The token resolves to the correct shade for the current mode (light or dark):

svelte
Highlighting code...

Customizing the Palette

Override the default colors by passing a custom palette to themeRules() in your UnoCSS config:

javascript
Highlighting code...

Dark Mode

Z-depth tokens automatically invert in dark mode. Set data-mode="dark" on your root element, and all z1-z10 values flip to their dark equivalents. No additional CSS needed.

Use the ThemeSwitcherToggle component from @rokkit/app to let users toggle between light, dark, and system modes:

svelte
Highlighting code...

Styling

Rokkit separates layout CSS from visual theme CSS using data-* attribute selectors. This clean architecture makes it easy to customize, override, or build entirely new themes.

Theme Architecture

Every Rokkit component uses two layers of CSS:

  • Base (layout) — Positioning, sizing, spacing. Rarely needs changing.
  • Theme (visual) — Colors, borders, shadows, transitions. Swap or override freely.
css
Highlighting code...

Data-Attribute Hooks

Components expose styling hooks via data-* attributes instead of class names. This avoids naming collisions and makes selectors self-documenting:

css
Highlighting code...

Common State Attributes

Components share a consistent set of state attributes across all components:

AttributeWhen PresentComponents
data-selectedItem is selectedList, Select, Tabs, Toggle
data-focusedItem has keyboard focusAll navigable
data-disabledItem is disabledAll
data-expandedGroup is expandedList, Tree, Select
data-openDropdown is openSelect, Menu

Building a Custom Theme

Create your own theme by writing CSS that targets data attributes. Start by copying the Rokkit theme and modifying colors, borders, and transitions:

css
Highlighting code...

Skins

Rokkit provides pre-built skin sets that bundle color palettes and style variations. Apply a skin by adding a class to your root element:

svelte
Highlighting code...

Component-Level Styling

Every component accepts a class prop for adding custom CSS classes. Use this for one-off adjustments without creating new theme rules:

svelte
Highlighting code...

Density

Coming soon.

Whitelabeling

Coming soon.