Ballmac UI home

Highlighter

Hand-drawn marks around inline text: highlight, underline, box, circle, strike-through and brackets, drawn in when the phrase scrolls into view.

The fastest way to ship a good interface is to start from components that already handle keyboard and screen readers, then change only what you must.

Installation

$ pnpm dlx shadcn@latest add @ballmac/highlighter

Usage

import { Highlighter } from "@/components/ballmac/highlighter"

The full example is in the Code tab above.

Examples

All six marks

  • highlight
  • underline
  • box
  • circle
  • strike
  • bracket

API reference

PropTypeDefault
children*

The phrase to mark. Short phrases work best because the mark is drawn around one box.

React.ReactNode—
action

The kind of mark.

HighlighterAction"highlight"
tone

Mark color.

HighlighterTone"chart-3"
strokeWidth

Stroke width in pixels (not used by "highlight").

number2.5
padding

Extra space around the text in pixels, so the mark does not touch the letters.

number4
duration

Seconds the drawing takes.

number0.7
delay

Seconds before it starts.

number0
inView

Wait until the phrase scrolls into view.

booleantrue

Also accepts the standard attributes of its root element.

Accessibility

KeyAction
Screen readersThe mark is decorative (aria-hidden); the text is unchanged
ContrastText keeps the foreground color on a translucent highlight
Reduced motionMarks are drawn instantly

Use with AI

<Highlighter action='highlight|underline|box|circle|strike|bracket' tone padding duration delay>phrase</Highlighter>. Short phrases only: the mark is drawn around one box. With the shadcn MCP server set up (guide), ask your agent:

Add the Ballmac UI Highlighter (@ballmac/highlighter) to this project with the shadcn MCP, then use it where it fits.

Use it for

  • Drawing attention to a key phrase in copy
  • Editorial and tutorial text

Not for

  • Multi-line passages
  • Search-result highlighting (use a plain mark element)

Registry JSON: https://ui.ballmac.com/r/highlighter.json

Credits

Free to use in personal and commercial projects.

Registry
shadcn/utils