Color
AliasCSS provides a flexible color syntax that works across plain CSS color names, hexadecimal values, color functions, CSS variables, custom colors, and token-based color systems. The goal is to let developers express color in class names without losing access to modern CSS color features.
Color by name
You can write any valid CSS color name after the property name, or in place of a color value inside compound properties.
Examples
| Classname | Shorthand | Compiled style |
|---|---|---|
color-red | c-red | color:red |
background-color-skyBlue | bgc-skyBlue | background-color:skyBlue |
border-color-blue | bc-blue | border-color:blue |
background-linear-gradient-135deg-blue-skyBlue | bg-lg-135deg-blue-skyBlue | background:linear-gradient(135deg,blue,skyBlue) |
border-1px-solid-black | b-1px-s-black | border:1px solid black |
box-shadow-0px--2px-2px-orange | bxs-0px--2px-2px-orange | box-shadow:0px -2px 2px orange |
accent-color-pink | Not applicable | accent-color:pink |
Usage
<h1 class="color-blue font-size-3rem">Hello, World</h1>This syntax is the easiest starting point because it stays close to regular CSS naming while still fitting the AliasCSS class model.
Color by hexadecimal
You can also use hexadecimal values without writing the leading #. AliasCSS detects the value and compiles it as a hex color.
Hex values must be 3, 6, or 8 digits.
Examples
| Classname | Shorthand | Compiled style |
|---|---|---|
color-ff0000 | c-ff0000 | color:#ff0000 |
background-color-ff0000 | bgc-ff0000 | background-color:#ff0000 |
border-color-ff0000 | bc-ff0000 | border-color:#ff0000 |
background-linear-gradient-135deg-ff0000-skyBlue | bg-lg-135deg-ff0000-skyBlue | background:linear-gradient(135deg,#ff0000,skyBlue) |
border-1px-solid-ff0000 | b-1px-s-ff0000 | border:1px solid #ff0000 |
box-shadow-0px--2px-2px-ff0000 | bxs-0px--2px-2px-ff0000 | box-shadow:0px -2px 2px #ff0000 |
accent-color-ff0000 | Not applicable | accent-color:#ff0000 |
Usage
<h1 class="color-e3e3e3 bgc-01010e55 font-size-3rem">Hello, World</h1>The 8-digit form is especially useful when you want alpha directly in the hex value.
Color by function: rgb, rgba, hsl, hsla, hwb, hwba
AliasCSS also supports common CSS color functions by encoding the function name and arguments into the class name.
Examples
| Classname | Shorthand | Compiled style |
|---|---|---|
color-rgb-255-0-0 | c-rgb-255-0-0 | color:rgb(255 0 0) |
color-rgba-255-0-0-0.4 | c-rgba-255-0-0-0.4 | color:rgba(255 0 0 / 0.4) |
background-color-hsl-0-100%-50% | bgc-hsl-0-100%-50% | background-color:hsl(0 100% 50%) |
border-color-hwb-0-0%-0% | bc-hwb-0-0%-0% | border-color:hwb(0 0% 0%) |
border-1px-solid-hsl-0-100%-50%-0.5 | b-1px-s-hsl-0-100%-50%-0.5 | border:1px solid hsl(0 100% 50% / 0.5) |
box-shadow-0px--2px-2px-rgba-255-0-0-0.8 | bxs-0px--2px-2px-rgba-255-0-0-0.8 | box-shadow:0px -2px 2px rgba(255 0 0 / 0.8) |
accent-color-rgb-255-0-0 | Not applicable | accent-color:rgb(255 0 0) |
background-color-rgb--primary-color | bgc-rgb--primary-color | background-color:rgb(var(--primary-color)) |
Usage
<h1 class="color-rgb-255-0-0 bgc-hsl-0-100%-0-0.8 font-size-3rem">
Hello, World
</h1>This form is useful when you want precision or want to pass CSS variables into color functions.
Color by function: lab, oklab, lch, oklch
AliasCSS also supports perceptual color spaces such as lab, oklab, lch, and oklch, which are increasingly useful for modern design systems and token workflows.
Examples
| Classname | Shorthand | Compiled style |
|---|---|---|
color-lab-54.3-106.83-40.85 | c-lab-54.3-106.83-40.85 | color:lab(54.3 106.83 40.85) |
color-oklab-0.63-0.22-0.13 | c-oklab-0.63-0.22-0.13 | color:oklab(0.63 0.22 0.13) |
background-color-lch-54.3-106.83-40.85 | bgc-lch-54.3-106.83-40.85 | background-color:lch(54.3 106.83 40.85) |
border-color-oklch-0.628-0.2577-29.23 | bc-oklch-0.628-0.2577-29.23 | border-color:oklch(0.628 0.2577 29.23) |
background-color-oklch--primary-color | bgc-oklch--primary-color | background-color:oklch(var(--primary-color)) |
Usage
<h1 class="color-rgb-255-255-225 background-color-lch-54.3-106.83-40.85 font-size-3rem">
Hello, World
</h1>oklch and related perceptual color spaces are especially useful for token-driven design systems because they make lightness and chroma adjustments more predictable than older color formats.
Custom colors
You can extend the available color library through aliascss.config.js. This is the recommended approach when your project has design tokens, brand colors, semantic UI colors, or theme variables.
const config = {
custom: {
colors: {
themeTextColor: 'var(--theme-text-color,#c3c3c3)',
themeBgcolor: 'var(--theme-bg-color,#0e0e0e)',
primary: 'rgba(124,143,234,1)',
},
},
}
export default configIt is safest to use camelCase for custom color names. The AliasCSS npm guide notes that using - or _ in custom color keys may cause errors.
You can read more in the advanced customization docs section for custom colors.
Built-in color systems
AliasCSS can also work with predefined tokenized color systems, which is useful when you want a consistent scale-based naming model instead of raw values. Primary Color System , ---this color system is desgned at untitled.com UI Kit
Radix UI colors
Radix Colors is an open-source, accessible color system designed for UI work. It provides 12-step color scales, matching alpha variants, automatic dark mode support, and guidance for backgrounds, borders, solid fills, and accessible text.
| Classname | Shorthand | Compiled style | Remarks |
|---|---|---|---|
color-slate1 | c-slate1 | color:#111113 | Base Radix scale token |
color-slateA11 | c-slateA11 | color:#F1F7FEB5 | Alpha scale token |
color-slateThemeA11 | c-slateThemeA11 | color:light-dark(#0007149f,#f1f7feb5) | Theme-aware token |
Radix documents that each scale has twelve steps, each scale includes transparent variants, and dark mode can be switched by applying a class to a container.
React Aria example colors
React Aria itself is style-free by default and is meant to work with any styling system. AliasCSS can expose a React Aria-inspired token system so you can use scale-based color utilities inside a headless component workflow.
| Classname | Shorthand | Compiled style | Remarks |
|---|---|---|---|
color-indigoRA100 | c-indigoRA100 | color:oklch(from var(--indigoColor,oklch(1 .25049 284.23)) 98.1187% calc(l * c * 0.5) h) | RA indicates React Aria-style token naming |
color-indigoRATheme100 | c-indigoRATheme100 | color:light-dark(oklch(from var(--indigoColor,oklch(1 .25049 284.23)) 98.1187% calc(l * c * 0.5) h),oklch(from var(--indigoColor,oklch(1 .25049 284.23)) 29.6725% calc(l * c * 0.5) h)) | Theme-aware token based on a base color variable |
Usage
<h1 class="color-primary200 background-color-primary800 font-size-3rem">
Hello, World
</h1>React Aria does not ship styles by default. Its components accept standard className and style props, and expose state through data attributes, which makes token-driven systems like AliasCSS a natural fit for styling them.
Alpha values with /
You can also apply alpha by appending /value after a color token. This works with color names, hex values, CSS variables, and custom colors.
It does not apply to function-style colors such as rgb(...), hsl(...), or hwb(...), because those formats already carry their own function-based syntax.
AliasCSS processes this by converting the color through oklch and adjusting the alpha channel.
Examples
| Classname | Shorthand | Compiled style |
|---|---|---|
color-red/9 | c-red/9 | color:oklch(from red l c h / 0.9) |
color-red/8 | c-red/8 | color:oklch(from red l c h / 0.8) |
color-red/7 | c-red/7 | color:oklch(from red l c h / 0.7) |
color-red/6 | c-red/6 | color:oklch(from red l c h / 0.6) |
color-red/5 | c-red/5 | color:oklch(from red l c h / 0.5) |
color-red/4 | c-red/4 | color:oklch(from red l c h / 0.4) |
color-red/3 | c-red/3 | color:oklch(from red l c h / 0.3) |
color-red/2 | c-red/2 | color:oklch(from red l c h / 0.2) |
color-red/1 | c-red/1 | color:oklch(from red l c h / 0.1) |
color-ffffff/1 | c-ffffff/1 | color:oklch(from #ffffff l c h / 0.1) |
color-primary600/5 | c-primary600/5 | color:oklch(from var(--primary600,#7F56D9) l c h / 0.5) |
color--bg-color/7 | c--bg-color/7 | color:oklch(from var(--bg-color) l c h / 0.7) |
Usage
<h1 class="color-primary200/6 background-color-blue/3 font-size-3rem">
Hello, World
</h1>This is especially handy for overlays, muted text, translucent borders, and token-based UI states.
CSS variables for complex colors
For advanced cases, CSS variables are still the best escape hatch. This is useful when you need color-mix(), relative color syntax, or custom computed values that would be too complex to express directly in an AliasCSS class.
You can always use CSS variables to handle complex color values, then reference those variables from AliasCSS class names.
<h1
class="color--fg1-custom-color background--bg1-custom-color font-size-3rem"
style="
--fg1-custom-color: color-mix(in srgb, red, white 20%);
--bg1-custom-color: hsl(from var(--primary) h s calc(l - 20%));
"
>
Hello, World
</h1>Guidance
A practical way to think about color in AliasCSS is:
- Use named colors for quick prototyping.
- Use hex values for direct palette work.
- Use color functions when precision matters.
- Use
oklchand tokens for design-system work. - Use custom colors for project-level semantics.
- Use
/alphafor quick opacity control on token-based colors. - Use CSS variables when the color logic becomes too dynamic for inline class syntax.
This progression keeps the API easy for beginners while still giving advanced teams access to modern color work