Expanding Menu
ComponentsExpanding Menu
NavigationNew

Expanding Menu

One compact capsule unfolds into an editorial index. A small entrance to a bigger world.

React + CSS
Live component. Go ahead, interact.
01

Installation

Run this in your shadcn-configured React project. The component and stylesheet are added together.

TERMINAL
npx shadcn@latest add http://localhost:5173/r/expanding-menu.json

This command uses the current site address. For localhost, keep this preview running on the same computer. Files follow your configured components alias.

02

Usage

Import the component and make the details your own.

TypeScript
import { ExpandingMenu } from '@/components/anticraft/ExpandingMenu';

export function Example() {
  return (
    <ExpandingMenu
      label="Find your way"
      activeId="work"
      items={[
        { id: 'work', label: 'Selected work', href: '/#work', description: 'A few things we put into the world.' },
        { id: 'about', label: 'The studio', href: '/#about', description: 'People, process, and a point of view.' },
        { id: 'contact', label: 'Start something', href: '/#contact', description: 'Good things begin with a conversation.' },
      ]}
    />
  );
}
03

Props

PropTypeDefaultDescription
itemsExpandingMenuItem[]RequiredDestinations with a unique id, visible label, and real href. Replace the example URLs with destinations in your project.
activeIdstringundefinedThe controlled id of the current destination. Only that link receives aria-current="page". Update this from your route or selected section.
labelstring'Menu'The accessible navigation label. Disclosure components also use it for their visible trigger.
onNavigate(id: string, event: MouseEvent<HTMLAnchorElement>) => voidundefinedRuns when a destination is activated. Anchors navigate normally; call event.preventDefault() only when handling navigation yourself, such as a local preview or router adapter.
classNamestring''Additional classes for sizing and CSS custom properties. Each component imports its matching stylesheet; keep both files together.
items[].descriptionstringundefinedOptional supporting text beneath a destination label.
onOpenChange(open: boolean) => voidundefinedReceives changes to the internal disclosure state when visitors open, dismiss, or navigate.
04

Motion & accessibility

Considered by default.

Click, tap, Enter, or Space toggles the disclosure. Up/Down on its trigger opens and focuses the last/first link. Ordinary Tab order reaches the revealed links; Escape returns focus to the trigger. Outside presses, focus leaving the component, and link activation dismiss it. Closed links are hidden and removed from the focus order. The disclosure expands in normal document flow and leaves the rest of the page available. Reduced motion removes the opening animation. Set --ac-surface, --ac-ink, --ac-accent, and --ac-serif to match your site.

Use semantic content and meaningful labels in your composition. Check contrast and keyboard behavior with your own styles and content.