TypstDocumentation

rgb

Create an RGB(A) color.

The color is specified in the sRGB color space.

Note: While you can specify transparent colors and Typst's preview will render them correctly, the PDF export does not handle them properly at the moment. This will be fixed in the future.

Example

#square(fill: rgb("#b1f2eb"))
#square(fill: rgb(87, 127, 230))
#square(fill: rgb(25%, 13%, 65%))
Preview

Parameters
Question mark

hex
string
RequiredPositional
Question mark

The color in hexadecimal notation.

Accepts three, four, six or eight hexadecimal digits and optionally a leading hashtag.

If this string is given, the individual components should not be given.

#text(16pt, rgb("#239dad"))[
  *Typst*
]
Preview

red
integer or ratio
RequiredPositional
Question mark

The red component.

green
integer or ratio
RequiredPositional
Question mark

The green component.

blue
integer or ratio
RequiredPositional
Question mark

The blue component.

alpha
integer or ratio
RequiredPositional
Question mark

The alpha component.