Server Component · 0 KB client JS

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
childrenstringNoneThe plain text to scan. Required.
querystring | string[]NoneThe substring or substrings to wrap in mark elements. Required.
variant"subtle" | "solid""subtle"Tinted or fully filled marks.
ignoreCasebooleantrueMatch regardless of letter case.
markClassNamestringNoneExtra class for each mark element.