Info
This site is generated using the static site generator developed by the Typst Community. Please adjust the text content of this banner according to your usage requirements. At Typst GmbH's request, when publishing documentation, you must clearly indicate that it is non-official and display the version of Typst being documented. For details, refer to Issue #874 on typst/typst.
TypstDocumentEnglish
v0.dev.2025-09-12

highlight
Element
Element
Element functions can be customized with set and show rules.

Highlights text with a background color.

Example

This is #highlight[important].
Preview

Parameter
Parameter
Parameters are input values for functions. Specify them in parentheses after the function name.

fill
Settable
Settable
Settable parameters can be set using the set rule, changing the default value used thereafter.

The color to highlight the text with.

Default value:

rgb("#fffd11a1")

Show example
This is #highlight(
  fill: blue
)[highlighted with blue].
Preview

stroke
Settable
Settable
Settable parameters can be set using the set rule, changing the default value used thereafter.

The highlight's border color. See the rectangle's documentation for more details.

Default value:

(:)

Show example
This is a #highlight(
  stroke: fuchsia
)[stroked highlighting].
Preview

top-edge
Settable
Settable
Settable parameters can be set using the set rule, changing the default value used thereafter.

The top end of the background rectangle.

Available string values:
  • ascender

    The font's ascender, which typically exceeds the height of all glyphs.

  • cap-height

    The approximate height of uppercase letters.

  • x-height

    The approximate height of non-ascending lowercase letters.

  • baseline

    The baseline on which the letters rest.

  • bounds

    The top edge of the glyph's bounding box.

Default value:

"ascender"

Show example
#set highlight(top-edge: "ascender")
#highlight[a] #highlight[aib]

#set highlight(top-edge: "x-height")
#highlight[a] #highlight[aib]
Preview

bottom-edge
Settable
Settable
Settable parameters can be set using the set rule, changing the default value used thereafter.

The bottom end of the background rectangle.

Available string values:
  • baseline

    The baseline on which the letters rest.

  • descender

    The font's descender, which typically exceeds the depth of all glyphs.

  • bounds

    The bottom edge of the glyph's bounding box.

Default value:

"descender"

Show example
#set highlight(bottom-edge: "descender")
#highlight[a] #highlight[ap]

#set highlight(bottom-edge: "baseline")
#highlight[a] #highlight[ap]
Preview

extent
Settable
Settable
Settable parameters can be set using the set rule, changing the default value used thereafter.

The amount by which to extend the background to the sides beyond (or within if negative) the content.

Default value:

0pt

Show example
A long #highlight(extent: 4pt)[background].
Preview

radius
Settable
Settable
Settable parameters can be set using the set rule, changing the default value used thereafter.

How much to round the highlight's corners. See the rectangle's documentation for more details.

Default value:

(:)

Show example
Listen #highlight(
  radius: 5pt, extent: 2pt
)[carefully], it will be on the test.
Preview

body
Required
Required
Required parameters must be specified when calling the function.
Positional
Positional
Positional parameters can be set by specifying them in order, omitting the parameter name.

The content that should be highlighted.

Open official docs

Search