TypstDocumentation

stroke

Defines how to draw a line.

A stroke has a paint (typically a solid color), a thickness, a line cap, a line join, a miter-limit, and a dash pattern. All of these values are optional and have sensible defaults.

Example

#set line(length: 100%)
#stack(
  spacing: 1em,
  line(stroke: 2pt + red),
  line(stroke: (paint: blue, thickness: 4pt, cap: "round")),
  line(stroke: (paint: blue, thickness: 1pt, dash: "dashed")),
)
Preview

Simple strokes

You can create a simple solid stroke from a color, a thickness, or a combination of the two. Specifically, wherever a stroke is expected you can pass any of the following values:

Complex strokes

For full control, you can also pass a dictionary to any function that expects a stroke. This dictionary has the following keys:

Fields

On a stroke object, you can access any of the fields mentioned in the dictionary format above. For example, (2pt + blue).thickness is 2pt. Meanwhile, (2pt + blue).cap is auto because it's unspecified.