TypstDocumentation

highlightElement
Question mark

Highlights text with a background color.

Example

This is #highlight[important].
Preview

Parameters
Question mark

fill
color or gradient or pattern
Settable
Question mark

The color to highlight the text with.

Default: rgb("#fffd11a1")

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

stroke
none or length or color or gradient or stroke or pattern or dictionary
Settable
Question mark

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

Default: (:)

top-edge
length or str
Settable
Question mark

The top end of the background rectangle.

VariantDetails
"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: "ascender"

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

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

bottom-edge
length or str
Settable
Question mark

The bottom end of the background rectangle.

VariantDetails
"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: "descender"

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

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

extent
length
Settable
Question mark

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

Default: 0pt

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

radius
relative or dictionary
Settable
Question mark

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

Default: (:)

body
content
RequiredPositional
Question mark

The content that should be highlighted.