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
stringPositional
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
integerratioPositional
Question mark

The red component.

green
integerratioPositional
Question mark

The green component.

blue
integerratioPositional
Question mark

The blue component.

alpha
integerratioPositional
Question mark

The alpha component.