JGuang

Highlighter

Highlighter · Magic UI

Preview
npx shadcn@latest add https://jiguang132.com/r/magic-ui/highlighter.json

Some upstream demos use online images, videos or tweets. That content depends on network access and third-party services.

Highlighter

Install: npx shadcn@latest add https://jiguang132.com/r/magic-ui/highlighter.json

Use case

Annotate child content with a rough hand-drawn mark.

Native props used by the examples

Extracted from all local examples for this entry, grouped by imported module and native owner, including other Magic components used by compound demos. This is not an exhaustive API or a universal host variant. Inspect spread object declarations and the source types/defaults below.

Owning component propExplanationExample source
Highlighter.action (highlighter)Native rough-notation annotation shape.examples/highlighter-demo.tsx
Highlighter.color (highlighter)The owning effect's native color; preserve any restricted color format.examples/highlighter-demo.tsx
Highlighter.children (highlighter)Native child content; keep the owning component's text/element constraints.examples/highlighter-demo.tsx

Interaction and state checks

  • Highlighter Demo — highlighter-demo

These names identify real example entries, not new component props or extra components. Check pointer/keyboard behavior, themes, small screens and failures for the selected example. Decorative effects must not invent disabled/error/submission states. Complete example installation includes the actual dependency closure.

Business integration boundary

action selects the rough-notation shape. Recompute/remove the annotation on content/layout changes; it does not alter source text.

Host and motion setup

Initialize Tailwind CSS v4, semantic CSS variables and the dark variant; import the independent local Registry namespace. Reuse an existing next-themes Provider without substituting JGuang UI/Base UI/HeroUI APIs. Mount effects in view and unmount offscreen; provide static alternatives for unavailable Canvas/WebGL or failed remote media. Respect prefers-reduced-motion and verify timer/RAF/observer/listener cleanup: stopping CSS alone does not prove the engine stopped. Examples provide no backend, login, payment or real AI stream. This practical guide is bilingual; detailed upstream references and demo text retain their original language.

Available examples

highlighter-demo

Demo state and mock data do not provide a backend service. Inspect the component props before wiring real data.

Installation

<Tabs defaultValue="cli"> <TabsList> <TabsTrigger value="cli">CLI</TabsTrigger> <TabsTrigger value="manual">Manual</TabsTrigger> </TabsList> <TabsContent value="cli">
npx shadcn@latest add @magicui/highlighter
</TabsContent> <TabsContent value="manual"> <Steps>

<Step>Install the following dependencies:</Step>

pnpm add motion rough-notation

<Step>Copy and paste the following code into your project.</Step>

</Steps> </TabsContent> </Tabs>

Usage

import { Highlighter } from "@/components/ui/highlighter"
<p>
  The{" "}
  <Highlighter action="underline" color="#FF9800">
    Magic UI Highlighter
  </Highlighter>{" "}
  makes important{" "}
  <Highlighter action="highlight" color="#87CEFA">
    text stand out
  </Highlighter>{" "}
  effortlessly.
</p>

Props

Here's the updated props table with units specified for the numerical values:

PropTypeDefaultDescription
childrenReact.ReactNodeRequiredThe content to be highlighted/annotated.
colorstring"#ffd1dc"The color of the highlight.
action"highlight" | "circle" | "box" | "bracket" | "crossed-off" | "strike-through" | "underline""highlight"The type of annotation effect to apply.
strokeWidthnumber1.5pxThe width of the annotation stroke.
animationDurationnumber500msDuration of the animation in milliseconds.
iterationsnumber2Number of times to draw the annotation (adds a sketchy effect when > 1).
paddingnumber2pxPadding between the element and the annotation.
multilinebooleantrueWhether to annotate across multiple lines or treat content as a single line.
isViewbooleanfalseControls whether the animation starts only when the element enters viewport.

Credits

Complete example installation

The component command installs the component. Each example command also includes its actual imported components, native support UI, utilities and pinned dependencies. Helpers are not additional catalog components.

Highlighter Demo

npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/highlighter/highlighter-demo.json

Default import: @/components/magicui/examples/highlighter-demo

Dependencies: clsx@2.1.1, motion@12.42.2, rough-notation@0.5.1, tailwind-merge@3.6.0

Minimal usage and theme

import Demo from '@/components/magicui/examples/highlighter-demo';
import { ThemeProvider } from 'next-themes';
export default function Example() {
  return <ThemeProvider attribute="class" defaultTheme="system" enableSystem><Demo /></ThemeProvider>;
}

Initialize Tailwind CSS v4, semantic color variables and the dark variant first. Reuse an existing next-themes provider rather than nesting another. Next Link examples require a Next.js environment; in static Vite projects adapt the demo links to your router without changing the native component API. Some media and tweets require network access. Examples do not supply authentication or backend services.

Source-backed parameter reference

Implementation signatures and types are generated from the pinned local source. Optional props, native inherited types, union branches and never exclusions are preserved. A forwardRef implementation's ref is a React reference, not an additional business prop.

Highlighter({
  children,
  action = "highlight",
  color = "#ffd1dc",
  strokeWidth = 1.5,
  animationDuration = 600,
  iterations = 2,
  padding = 2,
  multiline = true,
  isView = false,
}: HighlighterProps)
type AnnotationAction =
  | "highlight"
  | "underline"
  | "box"
  | "circle"
  | "strike-through"
  | "crossed-off"
  | "bracket"

interface HighlighterProps {
  children: React.ReactNode
  action?: AnnotationAction
  color?: string
  strokeWidth?: number
  animationDuration?: number
  iterations?: number
  padding?: number
  multiline?: boolean
  isView?: boolean
}

Destructuring defaults in source

Only defaults written directly in parameter/props destructuring are listed. Conditional expressions, runtime theme and computed values require source inspection; this is not an exhaustive behavior-default list.

// Highlighter
action = "highlight"

// Highlighter
color = "#ffd1dc"

// Highlighter
strokeWidth = 1.5

// Highlighter
animationDuration = 600

// Highlighter
iterations = 2

// Highlighter
padding = 2

// Highlighter
multiline = true

// Highlighter
isView = false

Native and external types

External types remain defined by React or native dependencies, not manually expanded into guessed props. The installed version's TypeScript definitions are authoritative.

React.ReactNode