Highlight

Wraps matches of a query in styled <mark> elements — search-result emphasis in prose.

Astralis paints every component with semantic tokens, so one brand color and a dark-mode class restyle the whole library.

Import#

import { Highlight } from "astralis-ui";

Usage#

Give it a plain string as children plus a query (string or array), and each match becomes a real <mark> — semantic emphasis that screen readers can announce. Matching is case-insensitive by default.

Multiple queries: eight planets, hundreds of moons.

The solid variant fills the mark with the full yellow.

Set ignoreCase to false and only exact CASE matches — not case — light up.

Props#

PropTypeDefaultDescription
childrenstringrequiredThe plain text to scan.
querystring | string[]requiredSubstring(s) to mark.
ignoreCasebooleantrueCase-insensitive matching.
variant"subtle" | "solid""subtle"Tinted or fully filled marks.
markClassNamestringExtra class for each <mark>.