SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

Highlight

Text with the stretches a search matched marked.

View code
tsx
<Link href="/examples/guides/routing">
	<Highlight
		segments={[
			{ text: "Typed ", match: false },
			{ text: "routes", match: true },
			{ text: " for every ", match: false },
			{ text: "route", match: true },
		]}
	/>
</Link>

Installation

An ordinary dependency: install it, import the theme once, and import the component where it is used.

Terminal
npm add @sdxc/ui remix
typescript
import "@sdxc/ui/theme.css";

Or copy it into your project to edit it:

Terminal
sdxc ui add highlight

Usage

typescript
import { Highlight } from "@sdxc/ui";

Renders the segments inline, each match as a <mark> with a quiet tint behind text that keeps the surrounding color and weight, so a match inside a link still reads as the link. A mark broken across lines keeps its rounded tint on every fragment.

Examples

In a search result link

View code
tsx
<Link href="/examples/guides/routing">
	<Highlight
		segments={[
			{ text: "Nested ", match: false },
			{ text: "layouts", match: true },
			{ text: " with shared ", match: false },
			{ text: "layout", match: true },
			{ text: " data", match: false },
		]}
		color="warning"
	/>
</Link>

Props

Read from the component's own types, so every prop, every default and every allowed value is listed.

PropTypeDefaultRequiredDescription
segmentsReadonlyArray<Segment>—YesThe text in order, split where the matches start and end.
color"brand" | "neutral" | "success" | "warning" | "danger"—NoSemantic color role of the marks. Defaults to DEFAULT_COLOR.

Also accepts everything in Omit<TagProps<"span">, "children">.

Types

NameValuesWhat it decides
Color"brand" | "neutral" | "success" | "warning" | "danger"Semantic color role the marks are tinted with.
@sdxc/ui

Can’t find it? Contact us