ValyroUI Русская версия

Highlight

Search hits marked in text: case and accents ignored, several terms in their own tones, ready-made ranges, the current hit. Free, MIT · Basics › Text and icons

Text with the hits of a search marked. Matching ignores case and accents and still marks the original letters ("Орёл" for "орел", "Zürich" for "zurich"); several terms can take their own tones; ready-made ranges serve fuzzy and server search; current marks the hit a find-in-page bar is on.

Installation

npx valyro-cli@latest add highlight
npx shadcn@latest add https://valyro.xyz/r/highlight.json
npm install valyro-ui

import 'valyro-ui/styles.css';
import { Highlight } from 'valyro-ui';

Props

PropTypeDefault
children *stringThe text to search in.
querystring | readonly string[]One term or several (each may get its own tone). Empty or blank: plain text.
rangesreadonly TextRange[]Ready-made hit ranges [start, end] (a fuzzy search, server hits); they win over query.
ignoreCasebooleantrueDefault true.
ignoreAccentsbooleantrue"елка" finds "Ёлка", "cafe" finds "Café". Default true, as the kit's Select and Combobox filter.
wholeWordbooleanfalseOnly whole words (any script).
firstbooleanfalseMark only the first hit.
toneHighlightTone | readonly HighlightTone[]'accent'Colour of the marks; an array gives each query term its own (cycling). Default accent.
currentnumberIndex of the current hit (find in page): it gets the strong colour and data-current.
localestringLocale for case folding (Turkish İ).
announcebooleanfalseScreen readers do not announce <mark>: wrap each hit in hidden "highlight start / end" words.
labelsPartial<HighlightLabels>Overrides for the built-in English text; keys left out keep their defaults.

Related components

  • Icon — Any icon on the kit’s rules: size from the text, the theme’s stroke, RTL mirroring, an accessible name; createIcon and a gallery of 111 icons
  • Kbd — Keyboard keys and shortcuts: one "mod+k" string shows ⌘K on a Mac and Ctrl+K elsewhere, read aloud as words
  • Button — Buttons in every variant
  • Icon Button — Icon-only button
  • Color Mode Switch — Light, dark or system: the choice is saved, painted before the first frame, synced across tabs and cross-faded
  • Button Group — Grouped buttons
  • Copy to Clipboard — Copy with confirmation
  • Badge — Status labels and tags
  • Tag — Removable and clickable tags, groups with +N
  • Avatar — User avatars
  • Tooltip — Hover and focus hints
  • Separator — Dividers

Previous: Kbd · Next: Skeleton · All Basics