Docs
Toolbar Expandable

Toolbar Expandable

Expandable toolbar component with step-based navigation, smooth animations, and enhanced scrolling

References

Installation

npx shadcn@latest add https://cult-ui.com/r/toolbar-expandable.json

Usage

import ToolbarExpandable from "@/components/ui/toolbar-expandable"

Basic Usage

const steps = [
  {
    id: "step1",
    title: "First Step",
    description: "Description of the first step",
    icon: Settings,
    content: <div>Step 1 content</div>,
  },
  // ... more steps
]
 
<ToolbarExpandable steps={steps} badgeText="WORKFLOW" />

Controlled Usage

import { useState } from "react"
 
const [expanded, setExpanded] = useState(false)
const [activeStep, setActiveStep] = useState<string | null>(null)
 
<ToolbarExpandable
  steps={steps}
  badgeText="CONTROLLED"
  expanded={expanded}
  onExpandedChange={setExpanded}
  activeStep={activeStep}
  onActiveStepChange={setActiveStep}
/>

API Reference

Props

PropTypeDefaultDescription
stepsDynamicStep[]-Array of step objects defining the toolbar content
badgeTextstring-Text displayed in the badge
classNamestring-Additional CSS classes
expandedboolean-Controlled expanded state
onExpandedChange(expanded: boolean) => void-Callback for expanded state changes
activeStepstring | null-Controlled active step ID
onActiveStepChange(stepId: string | null) => void-Callback for active step changes

DynamicStep Interface

interface DynamicStep {
  id: string
  title: string
  description: string
  icon:
    | React.ComponentType<{ className?: string }>
    | React.ReactElement<{ className?: string }>
  content: React.ReactNode
}
PropertyTypeDescription
idstringUnique identifier for the step
titlestringDisplay title for the step
descriptionstringDescription text for the step
iconReact.ComponentType or React.ReactElementIcon component or element
contentReact.ReactNodeContent to display when step is active

Examples

Deployment Workflow

const deploymentSteps = [
  {
    id: "setup",
    title: "Project Setup",
    description: "Initialize your project with the required dependencies.",
    icon: Settings,
    content: <ProjectSetupForm />,
  },
  {
    id: "configure",
    title: "Configuration",
    description: "Set up environment variables and project settings.",
    icon: Database,
    content: <ConfigurationForm />,
  },
  {
    id: "deploy",
    title: "Deploy",
    description: "Deploy your application to production.",
    icon: Rocket,
    content: <DeploymentForm />,
  },
]
 
<ToolbarExpandable steps={deploymentSteps} badgeText="DEPLOYMENT" />

Download Configuration

const downloadSteps = [
  {
    id: "format",
    title: "Choose Format",
    description: "Select the download format that best suits your needs.",
    icon: Download,
    content: <FormatSelector />,
  },
  {
    id: "options",
    title: "Download Options",
    description: "Configure additional options for your download.",
    icon: Settings,
    content: <OptionsForm />,
  },
]
 
<ToolbarExpandable steps={downloadSteps} badgeText="DOWNLOAD" />

Dependencies

The component requires the following dependencies:

  • motion - For animations
  • @radix-ui/react-scroll-area - For enhanced scrolling
  • @/components/ui/badge - For the badge component

Accessibility

The component includes several accessibility features:

  • Proper ARIA roles and descriptions
  • Keyboard navigation support
  • Screen reader friendly
  • Focus management
  • Touch-friendly interactions

Performance

The component is optimized for performance with:

  • Memoized components to prevent unnecessary re-renders
  • Efficient state management
  • Optimized animations
  • Lazy loading of content
  • Minimal DOM updates

Browser Support

The component supports all modern browsers and includes:

  • Touch device optimization
  • Fallbacks for older browsers
  • Progressive enhancement
  • Responsive design patterns