Highlight

An animated highlight component that tracks elements with smooth spring animations.

Open in
React
Vue
Svelte
Next.js
demo-primitives-effects-highlight.tsx
"use client";

import {
  Highlight,
  HighlightItem,
} from "@/components/unlumen-ui/primitives/effects/highlight";

const ITEMS = [
  { id: "react", label: "React" },
  { id: "vue", label: "Vue" },
  { id: "svelte", label: "Svelte" },
  { id: "next", label: "Next.js" },
];

export const HighlightDemo = ({ hover = true }: { hover?: boolean }) => {
  return (
    <div className="flex items-center justify-center min-h-[300px] w-full p-8">
      <Highlight
        mode="parent"
        hover={hover}
        defaultValue={hover ? undefined : "react"}
        className="rounded-lg bg-muted"
        containerClassName="flex gap-3 p-4 flex-wrap justify-center"
      >
        {ITEMS.map((item) => (
          <HighlightItem
            key={item.id}
            value={item.id}
            className="px-4 py-2 rounded-md font-medium cursor-pointer"
          >
            <div>{item.label}</div>
          </HighlightItem>
        ))}
      </Highlight>
    </div>
  );
};

Installation

Install the following dependencies:

Install the following registry dependencies:

Copy and paste the following code into your project:

components/unlumen-ui/highlight.tsx
// This file is deprecated. Import from primitives instead:
// import { Highlight, HighlightItem } from "@/components/unlumen-ui/primitives/effects/highlight"

export {
  Highlight,
  HighlightItem,
  useHighlight,
  type HighlightProps,
  type HighlightItemProps,
} from "@/components/unlumen-ui/primitives/effects/highlight";

Update the import paths to match your project setup.

Usage

import {
  Highlight,
  HighlightItem,
} from "@/components/unlumen-ui/primitives/effects/highlight";
<Highlight
  mode="parent"
  className="rounded-lg bg-muted"
  containerClassName="flex gap-2 p-2"
>
  <HighlightItem value="a">
    <div className="px-4 py-2 cursor-pointer">Option A</div>
  </HighlightItem>
  <HighlightItem value="b">
    <div className="px-4 py-2 cursor-pointer">Option B</div>
  </HighlightItem>
</Highlight>

API Reference

Highlight

PropTypeDefault
mode?
"children" | "parent"
"children"
hover?
boolean
false
value?
string | null
-
defaultValue?
string | null
-
onValueChange?
(value: string | null) => void
-
className?
string
-
containerClassName?
string
-
transition?
Transition
{ type: 'spring', stiffness: 350, damping: 35 }
exitDelay?
number
0.2
enabled?
boolean
true
disabled?
boolean
false
controlledItems?
boolean
false

HighlightItem

PropTypeDefault
value?
string
-
disabled?
boolean
false
activeClassName?
string
-
className?
string
-
transition?
Transition
-
exitDelay?
number
-
asChild?
boolean
false
forceUpdateBounds?
boolean
-

Built by Léo from Unlumen :3

Last updated: 3/15/2026