Highlight

A shared background that slides to the active item.

highlight.tsx

Installation

1

Install the packages

npm install @prequelui/react motion

@prequelui/react reuses the primitive library your components already depend on.

2

Add the component

npx shadcn@latest add https://animate.prequelui.terravidhal.me/r/highlight.json

npx shadcn@latest add https://animate.prequelui.terravidhal.me/r/highlight.json

3

Turn on the motion

npx @prequelui/cli@latest animate highlight

The CLI finds the component through components.json, swaps the import and removes the CSS animation classes that Motion replaces.

Usage

Import the component and compose it exactly like the primitive it wraps. Motion is enabled by default; the tempo prop scales every duration and softens every spring.

highlight.tsx
import { Highlight, HighlightItem } from "@/components/prequelui/effects/highlight";

export default function Demo() {
  return (
    <Highlight hover defaultValue="Weekly" className="inline-flex rounded-xl bg-accent p-1">
      {["Daily", "Weekly", "Monthly"].map((item) => (
        <HighlightItem key={item} value={item} className="rounded-lg px-4 py-2 text-[13px]">
          {item}
        </HighlightItem>
      ))}
    </Highlight>
  );
}
import { Highlight } from "@/components/prequelui/highlight";

export function Variant() {
  return (
    <Highlight tempo={1.2}>
      …
    </Highlight>
  );
}

Animation

One background element is shared by every item in the group. When the active value changes, the background is re-parented to the new item and a layout animation carries its position, width and height across, so it glides instead of blinking.

  • Highlight spring: stiffness 500, damping 40.
  • Both hover and click can drive the value; hover is ignored on touch pointers.
  • The value can be controlled, uncontrolled or changed from outside.
  • Reduced motion moves the surface instantly and keeps the colour change.
spring 500 / 40shared layoutIdhover + clickcontrollable value

API Reference

Each part accepts the usual HTML props in addition to the motion props below. No accessibility prop is hidden behind the animation layer.

Highlight

PropTypeDefault
valuestring | null—
defaultValuestring | nullnull
onValueChange(value: string | null) => void—
hoverbooleanfalse
clickbooleantrue
disabledbooleanfalse
activeClassNamestring"bg-background shadow-sm"
transitionTransitioncomponent spring or tween
classNamestring—

HighlightItem

PropTypeDefault
valuestring—
childrenReactNode—
disabledbooleanfalse
activeClassNamestring—
classNamestring—

Built by Vidhal. The source is available on GitHub.

Last updated: 11/17/2026