Bounce Sidebar

Sidebar nav whose active dot jumps between items on a curved path.

Preview

"use client";

import { useState } from "react";
import { BounceSidebar } from "@/components/motion/bounce-sidebar";

const destinations = [
  { id: "overview", label: "Overview" },
  { id: "components", label: "Components" },
  { id: "motion", label: "Motion" },
  { id: "templates", label: "Templates" },
  { id: "changelog", label: "Changelog" },
];

export function BounceSidebarPreview() {
  const [active, setActive] = useState("components");

  return (
    <div className="flex min-h-[360px] w-full items-center justify-center">
      <BounceSidebar
        items={destinations}
        value={active}
        onValueChange={setActive}
        ariaLabel="beUI sections"
        className="w-52"
        listClassName="w-full"
        itemClassName="text-base"
      />
    </div>
  );
}

Install

Add it with the shadcn CLI, or copy the source manually.

$ bunx --bun shadcn add @beui/bounce-sidebar

API Reference

items
BounceSidebarItem[]

Links or buttons listed in the sidebar, in order.

value?
string

Id of the active item, for controlled use.

defaultValue?
string

The initial active item id when uncontrolled. Defaults to the first item.

onValueChange?
((value: string) => void)

Called with the item id when an item is picked.

ariaLabel?
string

Accessible name for the nav. Default: "Sidebar navigation"

labels?
Partial<{ label: string; }>

Override any built-in string.

className?
string

Classes merged onto the root nav element.

listClassName?
string

Classes merged onto the list element.

itemClassName?
string

Classes merged onto each item's link or button.

indicatorClassName?
string

Classes merged onto the bouncing dot.

Updated