Sliding Nav
ComponentsSliding Nav
NavigationNew

Sliding Nav

An ink pill that follows your attention, then settles back on the place you call home.

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/sliding-nav.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 { SlidingNav } from '@/components/anticraft/SlidingNav';

export function Example() {
  return (
    <SlidingNav
      activeId="work"
      label="Studio sections"
      items={[
        { id: 'work', label: 'Selected work', href: '/#work' },
        { id: 'about', label: 'The studio', href: '/#about' },
        { id: 'contact', label: 'Say hello', href: '/#contact' },
      ]}
    />
  );
}
03

Props

PropTypeDefaultDescription
itemsSlidingNavItem[]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'Primary navigation'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.
04

Motion & accessibility

Considered by default.

Hover or focus moves the shared indicator; leaving the navigation restores activeId. The active page stays separate from the transient preview. Every link remains in the ordinary Tab order, with optional Left/Right, Home, and End shortcuts. Measurements update after resizing, scrolling, and font loading. The strip scrolls horizontally on narrow screens. Reduced motion removes indicator and color transitions. Theme it with --ac-sliding-surface, --ac-sliding-color, --ac-sliding-active-surface, and --ac-sliding-active-color.

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