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

type

Describes a kind of value.

To style your document, you need to work with values of different kinds: Lengths specifying the size of your elements, colors for your text and shapes, and more. Typst categorizes these into clearly defined types and tells you where it expects which type of value.

Apart from basic types for numeric values and typical types known from programming languages, Typst provides a special type for content. A value of this type can hold anything that you can enter into your document: Text, elements like headings and shapes, and style information.

Example

#let x = 10
#if type(x) == int [
  #x is an integer!
] else [
  #x is another value...
]

An image is of type
#type(image("glacier.jpg")).
Preview

The type of 10 is int. Now, what is the type of int or even type?

#type(int) \
#type(type)
Preview

Unlike other types like int, none and auto do not have a name representing them. To test if a value is one of these, compare your value to them directly, e.g:

#let val = none
#if val == none [
  Yep, it's none.
]
Preview

Note that type will return content for all document elements. To programmatically determine which kind of content you are dealing with, see content.func.

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

Determines a value's type.

type(
any
)->
#type(12) \
#type(14.7) \
#type("hello") \
#type(<glacier>) \
#type([Hi]) \
#type(x => x + 1) \
#type(type)
Preview

value
any
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 value whose type's to determine.

Open official docs

Search