Clawscale

Tokens

Tokens are CSS variables named --cs-*. Clawscale's styles read them, so one override restyles every component that uses the token.

Usage#

CSS#

@clawscale/react/styles.css declares every token of the default theme, for both color schemes. A theme stylesheet in @clawscale/react/themes/ sets its own values. Read them with var().

.queue-panel {
  background: var(--cs-color-surface);
  border: 1px solid var(--cs-color-border);
  border-radius: var(--cs-radius-lg);
  padding: var(--cs-space-4);
}

Elements styled with tokens follow the theme and the color scheme. Press Shift + T or Shift + D to switch them and watch this panel.

orders-dailyus-east-1Succeeded
events-hourlyeu-west-1Failed
billing-syncap-south-1Succeeded
const runs = [
  { pipeline: "orders-daily", region: "us-east-1", status: "Succeeded", failed: false },
  { pipeline: "events-hourly", region: "eu-west-1", status: "Failed", failed: true },
  { pipeline: "billing-sync", region: "ap-south-1", status: "Succeeded", failed: false },
];

const panel = {
  background: "var(--cs-color-surface)",
  border: "1px solid var(--cs-color-border)",
  borderRadius: "var(--cs-radius-lg)",
  boxShadow: "var(--cs-shadow-1)",
  padding: "var(--cs-space-1) 0",
  width: 340,
};

const row = { display: "flex", gap: "var(--cs-space-3)", padding: "var(--cs-space-2) var(--cs-space-4)" };

export default function TokensCustomElement() {
  return (
    <div style={panel}>
      {runs.map((run) => (
        <div key={run.pipeline} style={row}>
          <span style={{ flex: 1, fontWeight: "var(--cs-font-weight-medium)" }}>{run.pipeline}</span>
          <span style={{ color: "var(--cs-color-text-muted)" }}>{run.region}</span>
          <span style={{ color: run.failed ? "var(--cs-color-danger-text)" : "var(--cs-color-success-text)" }}>
            {run.status}
          </span>
        </div>
      ))}
    </div>
  );
}

JavaScript#

Install @clawscale/tokens to read the values in code, for example for a canvas chart.

npm install @clawscale/tokens
import { dark, light, shared, themes } from "@clawscale/tokens";

light.color.surface; // "#FFFFFF"
dark.color.surface; // "#16171B"
shared.radius.md; // "6px"
themes.default.dark.color.surface; // the same value as dark.color.surface

light, dark and shared are the default theme. themes holds every theme, each with shared, light, dark and sequential. light and dark hold color, shadow and chart. shared holds the groups that do not change with the color scheme. chartPalettes and sequentialBlue hold chart colors. themeVariables(theme, colorScheme) and sharedVariables(theme) return the values keyed by variable name, such as "--cs-radius-md".

Without Clawscale styles#

@clawscale/tokens/tokens.css declares the default theme's variables alone, outside any cascade layer. The dark values apply under [data-cs-color-scheme="dark"]. A theme other than the default ships @clawscale/tokens/themes/<name>.css, which applies under [data-cs-theme="<name>"]. Use them on pages that do not load @clawscale/react/styles.css. @clawscale/tokens/tokens.json holds the same values for other tools.

@import "@clawscale/tokens/tokens.css";

Override a token#

Set the variable in your own CSS. Unlayered CSS beats both Clawscale layers, so you never need !important.

:root {
  --cs-radius-md: 4px;
  --cs-color-primary-text-light: #0b6b5c;
  --cs-color-primary-text-dark: #4fd1b8;
}

Color, shadow and chart tokens have a light and a dark value, such as --cs-color-primary-text-light and --cs-color-primary-text-dark. Set both, and each color scheme picks its own. Theming covers brand colors and scoped overrides.

The tables below list the default theme.

Reference#

Color#

Surfaces, borders, text, controls and intents. Colors shows them as swatches.

TokenLightDark
--cs-color-canvas#F4F5F7#0F1013
--cs-color-surface#FFFFFF#16171B
--cs-color-surface-raised#FFFFFF#1D1F24
--cs-color-surface-sunken#F6F7F9#121316
--cs-color-surface-hoverrgba(20, 24, 31, 0.05)rgba(255, 255, 255, 0.06)
--cs-color-surface-activergba(20, 24, 31, 0.09)rgba(255, 255, 255, 0.10)
--cs-color-surface-selectedrgba(53, 99, 233, 0.10)rgba(99, 136, 255, 0.18)
--cs-color-border#E3E6EA#2A2D33
--cs-color-border-strong#CDD2D9#3A3E46
--cs-color-border-subtle#ECEEF1#212328
--cs-color-text#1A1C21#E7E9EC
--cs-color-text-muted#555D6A#A3AAB4
--cs-color-text-subtle#666F7C#858D99
--cs-color-text-disabled#9AA1AC#5E6570
--cs-color-text-inverse#FFFFFF#0F1013
--cs-color-focus#3563E9#7C9CFF
--cs-color-backdroprgba(15, 16, 19, 0.42)rgba(0, 0, 0, 0.62)
--cs-color-selectionrgba(53, 99, 233, 0.20)rgba(124, 156, 255, 0.32)
--cs-color-tooltip#1F2228#2C2F36
--cs-color-tooltip-text#F4F5F7#F4F5F7
--cs-color-control#FFFFFF#1F2127
--cs-color-control-hover#F6F7F9#262930
--cs-color-control-active#EDEFF2#2D3139
--cs-color-control-border#CDD2D9#363A42
--cs-color-control-border-hover#B7BEC8#464B55
--cs-color-neutral#5F6875#555C68
--cs-color-neutral-hover#4C5460#626A77
--cs-color-neutral-active#3E454F#6E7684
--cs-color-neutral-on#FFFFFF#FFFFFF
--cs-color-primary#3563E9#3563E9
--cs-color-primary-hover#2B55D6#2B55D6
--cs-color-primary-active#2448BD#2448BD
--cs-color-primary-disabled#9DB5F4#2C3F75
--cs-color-primary-on#FFFFFF#FFFFFF
--cs-color-primary-subtle#EEF3FFrgba(92, 130, 255, 0.16)
--cs-color-primary-subtle-hover#E0E9FFrgba(92, 130, 255, 0.24)
--cs-color-primary-border#B8CBFArgba(124, 156, 255, 0.45)
--cs-color-primary-text#2B55D6#8AA8FF
--cs-color-success#1B7F4E#1B7F4E
--cs-color-success-hover#176E43#176E43
--cs-color-success-active#135D39#135D39
--cs-color-success-disabled#8CC4A7#1F4A36
--cs-color-success-on#FFFFFF#FFFFFF
--cs-color-success-subtle#E9F6EFrgba(46, 184, 120, 0.15)
--cs-color-success-subtle-hover#D9EFE3rgba(46, 184, 120, 0.22)
--cs-color-success-border#A8D8BDrgba(76, 195, 138, 0.45)
--cs-color-success-text#17744A#4CC38A
--cs-color-warning#F5A524#F5A524
--cs-color-warning-hover#E8971A#E8971A
--cs-color-warning-active#D48712#D48712
--cs-color-warning-disabled#F9D291#5C4518
--cs-color-warning-on#1A1C21#1A1C21
--cs-color-warning-subtle#FEF6E5rgba(245, 165, 36, 0.14)
--cs-color-warning-subtle-hover#FCEBC6rgba(245, 165, 36, 0.22)
--cs-color-warning-border#F2CD84rgba(245, 181, 74, 0.45)
--cs-color-warning-text#9A5A00#F5B54A
--cs-color-danger#D23535#D23535
--cs-color-danger-hover#BD2D2D#BD2D2D
--cs-color-danger-active#A42626#A42626
--cs-color-danger-disabled#E89A9A#5A2426
--cs-color-danger-on#FFFFFF#FFFFFF
--cs-color-danger-subtle#FDEEEErgba(255, 99, 99, 0.14)
--cs-color-danger-subtle-hover#FADBDBrgba(255, 99, 99, 0.22)
--cs-color-danger-border#F1B0B0rgba(255, 122, 122, 0.45)
--cs-color-danger-text#B42A2A#FF8585

Shadow#

0 to 4 are elevation levels. control sits under buttons and inputs.

TokenLightDark
--cs-shadow-00 0 0 1px rgba(17, 20, 26, 0.08)0 0 0 1px rgba(255, 255, 255, 0.07)
--cs-shadow-10 0 0 1px rgba(17, 20, 26, 0.07), 0 1px 2px rgba(17, 20, 26, 0.06)0 0 0 1px rgba(255, 255, 255, 0.07), 0 1px 2px rgba(0, 0, 0, 0.40)
--cs-shadow-20 0 0 1px rgba(17, 20, 26, 0.07), 0 2px 4px -1px rgba(17, 20, 26, 0.06), 0 4px 12px -2px rgba(17, 20, 26, 0.08)0 0 0 1px rgba(255, 255, 255, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.40), 0 4px 12px -2px rgba(0, 0, 0, 0.45)
--cs-shadow-30 0 0 1px rgba(17, 20, 26, 0.07), 0 4px 8px -2px rgba(17, 20, 26, 0.08), 0 12px 28px -6px rgba(17, 20, 26, 0.14)0 0 0 1px rgba(255, 255, 255, 0.08), 0 4px 8px -2px rgba(0, 0, 0, 0.45), 0 12px 28px -6px rgba(0, 0, 0, 0.55)
--cs-shadow-40 0 0 1px rgba(17, 20, 26, 0.07), 0 8px 16px -4px rgba(17, 20, 26, 0.10), 0 28px 56px -12px rgba(17, 20, 26, 0.22)0 0 0 1px rgba(255, 255, 255, 0.09), 0 8px 16px -4px rgba(0, 0, 0, 0.50), 0 28px 56px -12px rgba(0, 0, 0, 0.65)
--cs-shadow-control0 1px 2px rgba(17, 20, 26, 0.06)0 1px 2px rgba(0, 0, 0, 0.35)

Chart#

Slots 1 to 8 are the categorical palette, in fixed order. grid and axis draw chart chrome. The status colors are the same in every theme and color scheme.

TokenLightDark
--cs-chart-1#3563E9#4A74F0
--cs-chart-2#EB6834#D95926
--cs-chart-3#1BAF7A#199E70
--cs-chart-4#EDA100#C98500
--cs-chart-5#E87BA4#D55181
--cs-chart-6#008300#008300
--cs-chart-7#4A3AA7#9085E9
--cs-chart-8#E34948#E66767
--cs-chart-grid#E3E6EA#26292E
--cs-chart-axis#BCC2CA#3A3E46
--cs-chart-good#0CA30C#0CA30C
--cs-chart-warning#FAB219#FAB219
--cs-chart-serious#EC835A#EC835A
--cs-chart-critical#D03B3B#D03B3B

The sequential ramp shows magnitude, such as heatmap cells. The lightest step means near zero. It is the same in both color schemes.

TokenValue
--cs-chart-seq-100#CDE2FB
--cs-chart-seq-200#9EC5F4
--cs-chart-seq-300#6DA7EC
--cs-chart-seq-400#3987E5
--cs-chart-seq-500#256ABF
--cs-chart-seq-600#184F95
--cs-chart-seq-700#0D366B

Font#

Font stacks. @clawscale/react/fonts.css loads the first family of each.

TokenValuePreview
--cs-font-sans"Inter Variable", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serifRows 12,480
--cs-font-mono"JetBrains Mono Variable", "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospaceRows 12,480

Font size#

The type scale. Body text uses md.

TokenValuePreview
--cs-font-size-xs11pxRows 12,480
--cs-font-size-sm12pxRows 12,480
--cs-font-size-md13pxRows 12,480
--cs-font-size-lg15pxRows 12,480
--cs-font-size-xl18pxRows 12,480
--cs-font-size-2xl22pxRows 12,480
--cs-font-size-3xl28pxRows 12,480
--cs-font-size-4xl36pxRows 12,480

Font weight#

TokenValuePreview
--cs-font-weight-regular400Rows 12,480
--cs-font-weight-medium500Rows 12,480
--cs-font-weight-semibold600Rows 12,480
--cs-font-weight-bold700Rows 12,480

Line height#

TokenValue
--cs-line-height-tight1.25
--cs-line-height-normal1.4
--cs-line-height-relaxed1.6

Radius#

TokenValuePreview
--cs-radius-xs2px
--cs-radius-sm4px
--cs-radius-md6px
--cs-radius-lg8px
--cs-radius-xl12px
--cs-radius-full9999px

Space#

A 4px grid. Use it for padding, margins and gaps.

TokenValuePreview
--cs-space-14px
--cs-space-28px
--cs-space-312px
--cs-space-416px
--cs-space-520px
--cs-space-624px
--cs-space-832px
--cs-space-1040px
--cs-space-unit4px

Corner#

The CSS corner-shape of rounded corners: round, or bevel to cut them where the browser supports it.

TokenValue
--cs-corner-shaperound

Label#

How short labels look: buttons, tabs, column headers and section titles. Text that shows data never takes these.

TokenValue
--cs-label-transformnone
--cs-label-trackingnormal

Control height#

The heights of Blueprint's small, medium and large buttons and inputs. Use them to size your own controls to match.

TokenValuePreview
--cs-control-height-sm24px
--cs-control-height-md30px
--cs-control-height-lg40px

Duration#

TokenValue
--cs-duration-fast100ms
--cs-duration-normal160ms
--cs-duration-slow240ms

Ease#

TokenValue
--cs-ease-standardcubic-bezier(0.2, 0, 0, 1)
--cs-ease-outcubic-bezier(0, 0, 0.2, 1)