@umbra.ui/colors
v0.5.0
Published
Color system for Umbra UI
Downloads
280
Maintainers
Readme
@umbra.ui/colors
Color tokens for Umbra UI.
This package provides:
- 30 color families with 12-step scales
- light + dark tokens
- opaque + alpha variants
- sRGB + Display P3 values
- a semantic token layer (
semantic-colors.css) - fully typed JavaScript/TypeScript exports
Installation
Install with your preferred package manager:
npm install @umbra.ui/colorspnpm add @umbra.ui/colorsyarn add @umbra.ui/colorsbun add @umbra.ui/colorsQuick start
- Install the package.
- Import semantic tokens once in your app entry.
- Toggle
.lightor.darkon a root container.
// main.ts
import "@umbra.ui/colors/semantic-colors.css";<body class="light">
<div id="app"></div>
</body>.panel {
background: var(--background-1);
color: var(--text-1);
border: 1px solid var(--border-2);
}
.panel a {
color: var(--link);
}// Optional: use raw scales from JS/TS
import { blue, blueDark } from "@umbra.ui/colors";
const brandLight = blue.blue9;
const brandDark = blueDark.blue9;How the color system is structured
Each family follows a consistent naming model:
blue1 ... blue12for opaque scale stepsblueA1 ... blueA12for alpha scale stepsblueDark1 ...does not exist as flattened keys; dark tokens are exposed as separate objects likeblueDarkblueP3/blueP3A(and dark P3 variants) contain Display P3 values
In CSS variables:
- Opaque tokens are
--blue-1 ... --blue-12 - Alpha tokens are
--blue-a1 ... --blue-a12
Available families
Neutral families
graymauveslatesageolivesand
Chromatic families
tomato,red,ruby,crimson,pink,plum,purple,violetiris,indigo,blue,cyan,teal,jade,green,grassbrown,bronze,gold,sky,mint,lime,yellow,amber,orange
Utility alpha families
blackA/blackP3AwhiteA/whiteP3A
Theme behavior
The CSS files are authored to respond to standard theme selectors:
- Light selectors:
:root,.light,.light-theme - Dark selectors:
.dark,.dark-theme
This means you can switch token values by toggling a theme class on a parent element.
Using the package
1) Use tokens in JS/TS
import { blue, blueDark, blueA, blueDarkA } from "@umbra.ui/colors";
const buttonBgLight = blue.blue9;
const buttonBgDark = blueDark.blue9;
const focusRing = blueA.blueA8;
const focusRingDark = blueDarkA.blueA8;2) Use semantic CSS tokens
Import once:
import "@umbra.ui/colors/semantic-colors.css";Then consume semantic variables in your styles:
.card {
background: var(--background-1);
border: 1px solid var(--border-2);
color: var(--text-1);
}
.card a {
color: var(--link);
}semantic-colors.css includes:
- Accent and neutral ramps (
--accent-*,--neutral-*) - Surface/control/border/text aliases
--background-0..2--control-1..3--border-1..3--text-1..3
- Status/intent aliases
--link,--info,--success,--warning,--error
Scale guidance (1-12)
The 12-step ramp is intentionally role-based:
| Step | Typical use | | --- | --- | | 1 | App/page background | | 2 | Subtle background areas | | 3 | Component background (rest) | | 4 | Component background (hover) | | 5 | Component background (active/selected) | | 6 | Subtle borders and separators | | 7 | Interactive borders | | 8 | Stronger interactive borders / focus rings | | 9 | Solid fills (primary color block) | | 10 | Hovered solid fills | | 11 | Lower-contrast text | | 12 | High-contrast text |
Notes:
- Steps
9and10are for strong fills and accents. - Steps
11and12are text-oriented values. - On a step
2background from the same scale, steps11and12are designed for readable text contrast targets.
Palette composition guidance
Choose an accent scale
Scales generally suited for light foreground text on step 9/10:
bronze,gold,brown,orange,tomato,red,ruby,crimsonpink,plum,purple,violet,iris,indigo,blue,cyanteal,jade,green,grass
Scales generally suited for dark foreground text on step 9/10:
sky,mint,lime,yellow,amber
Choose a neutral scale
gray: pure neutralmauve: purple-leaning neutralslate: blue-leaning neutralsage: green-leaning neutralolive: yellow-green-leaning neutralsand: warm yellow-leaning neutral
Practical rule:
- Use
grayfor a cleaner, less saturated foundation. - Use a tinted neutral (for example
slatewith blue accents) when you want a more atmospheric palette.
Choose semantic scales
Common pairings:
- Error:
red,ruby,tomato,crimson - Success:
green,teal,jade,grass,mint - Warning:
yellow,amber,orange - Info:
blue,indigo,sky,cyan
API surface summary
- Root JS/TS import:
@umbra.ui/colors- Exposes all token objects (
blue,blueA,blueP3,blueDark,blueDarkA,blueDarkP3, etc.) - Exposes
blackA,blackP3A,whiteA,whiteP3A
- Exposes all token objects (
- CSS semantic entry:
@umbra.ui/colors/semantic-colors.css
Tips and best practices
- Prefer semantic tokens (
--text-1,--border-2,--error) in component code. - Use raw scale tokens (
--blue-9,blue.blue9) for brand/accent-specific UI. - Keep neutral backgrounds conservative if your UI already has many saturated badges/labels.
- Treat token ramps as system primitives; if you need brand-specific colors, add custom tokens alongside Umbra tokens rather than modifying these scales directly.
