parseAnchor

Commons
stable

Decompose a `TAnchor` string (e.g. `"top left"`, `"bottom"`, `"center"`) into a `{side, align}` pair used internally by overlay positioning utilities.

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

anchor
required
TAnchor
A TAnchor value: a single word (e.g. `"top"`, `"left"`, `"center"`) or two space-separated words (e.g. `"top left"`, `"bottom right"`). The first word is the side; the second (optional) word is the alignment.

API

Return value

The value returned by this util.

A `{ side, align }` object. When only one word is provided, `align` is inferred: block sides default to `"left"`, inline sides default to `"top"`, and `"center"` defaults to `"center"`.

Usage

Examples

Ready-to-paste usage snippets.

Parsing single and compound anchors

typescript