Knit UI
GitHub

Playground

Loading playground…

true
false
false
Playground
<Highlight
  highlight="fox"
  caseInsensitive
  wholeWord={false}
  accentInsensitive={false}
>
  The quick brown fox jumps over the lazy dog
</Highlight>

Examples

Single Term

Highlights a single word inside a longer sentence.

Loading example…

Single TermSourceStorybook

Multiple Terms

Multiple terms are all highlighted simultaneously.

Loading example…

Multiple TermsSourceStorybook

No Match

When no term matches the full text is rendered with no marks.

Loading example…

No MatchSourceStorybook

Case Sensitive

Case-sensitive mode — uppercase search term does not match lowercase text.

Loading example…

Case SensitiveSourceStorybook

Whole Word

Whole-word mode — only standalone words match, not substrings.

Loading example…

Whole WordSourceStorybook

Global Highlight Styles

Global highlightStyles applies the same Mark style to every match.

Loading example…

Global Highlight StylesSourceStorybook

Per Term Highlight Styles

Per-term highlightStyles maps each search term to its own Mark style.

Loading example…

Per Term Highlight StylesSourceStorybook

Styles

Per-slot styles targets individual parts — here the mark applied to every highlight.

Loading example…

StylesSourceStorybook

Accent Insensitive

Accent-insensitive matching treats accented and plain characters as equal.

Loading example…

Accent InsensitiveSourceStorybook

Props

PropTypeDefaultDescription
children requiredstringThe quick brown fox jumps over the lazy dogThe full string to scan and render.
highlight requiredstring | string[]foxSubstring(s) to highlight. Pass a string or an array of strings.
accentInsensitiveboolean | undefinedfalseMatch regardless of diacritics / accents. Default `false`.
caseInsensitiveboolean | undefinedtrueMatch regardless of letter case. Default `true`.
disabled systemboolean | undefinedSpecifies the disabled state of the text view for testing purposes.
highlightStylesHighlightMarkProps | HighlightStylesMap | undefined
size system"xs" | "sm" | "md" | "lg" | "xl" | "xxs" | "xxl" | undefined
styles systemSlotStyles<HighlightStyles> | undefinedPer-slot style sugar. Slot: `mark` — props spread onto every highlighted `Mark`.
theme systemThemeName | null | undefinedApplies a theme to this element
wholeWordboolean | undefinedfalseOnly match whole words (respects `\w` boundaries). Default `false`.

Style slots

Every part of Highlight can be styled through the styles prop. Explicit props on the component always win over slot styles.

SlotUsage
markstyles={{ mark: { … } }}
Accessibility & DOM props (2)
PropType
keyKey | null | undefined
refRef<TamaguiTextElement> | undefined

Plus 506 inherited style props from Box — the full Tamagui/React Native style surface, including token shorthands like p, mx, bg and c. See Tokens for the scales they accept, or the full list.