CSS Value Functions

Yamada UI provides various functions that make CSS value functions more convenient.

Calculation & Comparison

Yamada UI provides functions that make CSS calculation and comparison functions more convenient.

calc

You can use CSS's calc to reference and calculate tokens from the theme.

Calc
Use interpolated token

min

Use CSS's min to set the smallest value from the given arguments.

If there is only one argument, a second value of "100%" is set.

Min
Omitted Min

max

Use CSS's max to set the largest value from the given arguments.

If there is only one argument, a second value of "100%" is set.

Max
Omitted Max

clamp

Use CSS's clamp to constrain a value between an upper and lower bound.

If there are two arguments, a recommended value of "100%" is set.

Clamp
Omitted Clamp

Color

Yamada UI provides functions that easily mix colors together, lighten, and darken colors.

mix

Use CSS's color-mix to mix colors together.

You can specify two or three arguments. The method can be omitted, and the default is in srgb.

"in srgb" + "red.500" + "blue.500"

You can change the ratio by specifying a percentage.

"in lab" + "orange.500 80%" + "purple.500 20%"

tint

Use mix to lighten a color by mixing it with #FFFFFF.

Tint color

shade

Use mix to darken a color by mixing it with #000000.

Shade color

transparentize

Use mix to make a color transparent by mixing it with transparent. A shorthand notation like bg="red.500 / 50" is also available.

Transparentize color

tone

Use mix to create a color based on a specified color and tone.

Tone 50
Tone 100
Tone 200
Tone 300
Tone 400
Tone 500
Tone 600
Tone 700
Tone 800
Tone 900
Tone 950

Gradient

Yamada UI provides functions that easily create gradients. To add a gradient, set functions and values to bgGradient.

  • linear(<direction>, <from>, <to>)
  • radial(<from>, <to>)

You can also use other CSS gradient functions like repeating-linear or conic.

Shortcuts are available for <direction>.

{
  'to-t': 'to top',
  'to-tr': 'to top right',
  'to-r': 'to right',
  'to-br': 'to bottom right',
  'to-b': 'to bottom',
  'to-bl': 'to bottom left',
  'to-l': 'to left',
  'to-tl': 'to top left',
}

Customize Colors

You can use both theme tokens and CSS color values.

Text Gradient

To add a gradient to text, set bgGradient and bgClip to text.

クリリンのことか……クリリンのことかーーーっ!!!!!