Skip to Content

Color


Color By Name

You can just write any CSS valid color name after property, or in place of Color Value.

Here are other example class name definition.

ClassnameshorthandCompiled Style
color-redc-redcolor:red
background-color-skyBluebgc-skyBluebackground-color:skyBlue
border-color-bluebc-blueborder-color:blue
background-linear-gradient-135deg-blue-skyBluebg-lg-135deg-blue-skyBluebackground:linear-gradient(135deg,blue,skyBlue)
border-1px-solid-blackb-1px-s-blackborder:1px solid black
box-shadow-0px—2px-2px-orangebxs-0px-0px-2px-orangebox-shadow:0px -2px 2px orange
accent-color-pinkNot Applicableaccent-color:pink

Usage Eg:-

<h1 class="color-blue font-size-3rem">Hello, World</h1>

Color By Hexadecimal

You can just write any CSS valid hexadecimal value omitting ”#”. AliasCSS is smart enough to know the hexadecimal-value without ’#’ hexadecimal value must be either 3,6 or 8 digit.

Here are other example class name definition.

ClassnameshorthandCompiled Style
color-ff0000c-ff0000color:#ff0000
background-color-ff0000bgc-ff0000background-color:#ff0000
border-color-ff0000bc-ff0000border-color:#ff0000
background-linear-gradient-135deg-ff0000-skyBluebg-lg-135deg-ff0000-skyBluebackground:linear-gradient(135deg,#ff0000,skyBlue)
border-1px-solid-ff0000b-1px-s-ff0000border:1px solid #ff0000
box-shadow-0px—2px-2px-ff0000bxs-0px-0px-2px-ff0000box-shadow:0px -2px 2px #ff0000
accent-color-ff0000Not Applicableaccent-color:#ff0000

Usage Eg:-

<h1 class="color-e3e3e3 bgc-01010e55 font-size-3rem">Hello, World</h1>

Color by function rgb/rgba/hsl/hsla/hwb/hwba

Similarly you can use rgb/rgba/hsl/hsla/hwb/hwba,they all follow same syntax :

Here are other example class name definition.

ClassnameshorthandCompiled Style
color-rgb-255-0-0c-rgb-255-0-0color:rgb(255 0 0)
color-rgba-255-0-0-0.4c-rgba-255-0-0-0.4color: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.5b-1px-s-hsl-0-100%-50%-0.5border:1px solid hsl(0 100% 50% / 0.5)
box-shadow-0px—2px-2px-rgba-255-0-0-0.8bxs-0px-0px-2px-rgba-255-0-0-0.8box-shadow:0px -2px 2px rgba(255 0 0 /0.8)
accent-color-rgb-255-0-0Not Applicableaccent-color:rgb(255 0 0)
background-color-rgb—primary-colorbgc-rgb—primary-colorbackground-color:rgb(var(—primary-color))

Usage Eg:-

<h1 class="color-rgb-255-0-0 bgc-hsl-0-100%-0-0.8 font-size-3rem"> Hello, World </h1>

Color by function lab,oklab,lch, oklch

Similarly you can use rgb/rgba/hsl/hsla/hwb/hwba,they all follow same syntax :

Here are other example class name definition.

ClassnameshorthandCompiled Style
color-lab-54.3-106.83-40.85c-lab-54.3-106.83-40.85color:lch(54.3 106.83 40.85)
color-oklab-0.63-0.22-0.13c-oklab-0.63-0.22-0.13color:oklab(0.63 0.22 0.13)
background-color-lch-54.3-106.83-40.85bgc-lch-54.3-106.83-40.85background-color:lch(54.3 106.83 40.85)
border-color-oklch-0.628-0.2577-29.23bc-oklch-0.628-0.2577-29.23border-color:oklch(0.628 0.2577 29.23)
background-color-oklch—primary-colorbgc-oklch—primary-colorbackground-color:oklch(var(—primary-color))

Usage Eg:-

<h1 class="color-rgb-255-255-225 background-color-lch-54.3-106.83-40.85 font-size-3rem"> Hello, World </h1>

Custom Colors

You can extend your color library using aliascss.config.js configuration file . Custom Colors .You can also use custom color provide by default with AliasCSS compiler, please visit Color Reference to know more. AliasCSS also provide some collection of custom color System , which can be used in place of color value out of the box. you can use Radix UI and React Aria Color System which come with auto theming system.

Radix UI Colors

Radix UI use 1-12 token system. We have added Theme token support in radix color system, so you can use both light and dark theme color using same class name.

Visit Radix UI Colors 

ClassnameshorthandCompiled StyleRemarks
color-slate1c-slate1color:#111113
color-slateA11c-slateA11color:#F1F7FEB5
color-slateThemeA11c-slateThemeA11color:light-dark(#0007149f,#f1f7feb5)

React Aria Colors

React Aria use a color system which 0s used their vanilla CSS examples, which is based on 100-1600 token system, we have added Theme token to support in React Aria Example color system, so you can use both light and dark theme.

Visit React Aria Colors 

ClassnameshorthandCompiled StyleRemarks
color-indigoRA100c-indigoRA100color:oklch(from var(--indigoColor,oklch(1 .25049 284.23)) 98.1187% calc(l * c * 0.5) h)uses RA to indicate React Aria colors
color-indigoRATheme100c-indigoRTheme100color: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))use --nameColor to change base color

Usage Eg:-

<h1 class="color-primary200 background-color-primary800 font-size-3rem"> Hello, World </h1>

Alpha Value:

You can also modify alpha value providing alpha value after the color separating by ’/’. Use can only use this method in color by name , color by hexadecimal, css-variables and custom colors . you cannot use it in color function like rgb/hwb/hsl etc. The color will be processed in oklch color space build the color from given color and modifying alpha alpha channel. you can provide value from 0-9 representing to 0-0.9

ClassnameshorthandCompiled Style
color-red/9c-red/9color:oklch(from red l c h/0.9)
color-red/8c-red/8color:oklch(from red l c h/0.8)
color-red/7c-red/7color:oklch(from red l c h/0.7)
color-red/6c-red/6color:oklch(from red l c h/0.6)
color-red/5c-red/5color:oklch(from red l c h/0.5)
color-red/4c-red/4color:oklch(from red l c h/0.4)
color-red/3c-red/3color:oklch(from red l c h/0.3)
color-red/2c-red/2color:oklch(from red l c h/0.2)
color-red/1c-red/1color:oklch(from red l c h/0.1)
color-ffffff/1c-ffffff/1color:oklch(from #ffffff l c h/0.1)
color-primary600/5c-primary600/5color:oklch(from var(—primary600,#7F56D9) l c h/0.5)
color—bg-color/7c—bg-color/7color:oklch(from var(---bg-color) l c h/0.7)

Usage Eg:-

<h1 class="color-primary200/6 background-color-blue/3 font-size-3rem"> Hello, World </h1>

Note

💡

TIPS You can always use css-variables to handle complex color values. for Example

<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>
Last updated on