Skip to main content

Overview

HuxSidebar is a complete navigation component that provides a consistent sidebar layout with header, navigation items, and optional footer. It handles selection state management automatically and provides a clean API for sidebar navigation in your Flutter applications.

Basic Usage

Simple Sidebar

Basic sidebar with navigation items:
Sidebar with custom header content:
Include footer content like user profile or settings:

HuxSidebarItemData

Define individual navigation items:

Multiple Items

Create a list of navigation items:

Properties

HuxSidebar Properties

HuxSidebarItemData Properties

Styling

Custom Width

Adjust sidebar width for your layout:

Custom Padding

Control spacing around navigation items:

States

Selection State

Items automatically show selected state based on selectedItemId:
  • Selected: Highlighted with primary color background
  • Unselected: Default appearance with hover state
  • Hovered: Subtle background change on mouse hover

Integration Examples

With Routing

Integrate with your app’s routing system:

With Responsive Layout

Make sidebar responsive to screen size:

Best Practices

  • Always maintain a selected state
  • Update selected item when route changes
  • Provide visual feedback for current location
  • Consider highlighting active section in multi-level navigation
  • Hide sidebar on small screens and use drawer instead
  • Adjust sidebar width based on screen size
  • Consider collapsible sidebar for medium screens
  • Ensure touch targets are at least 44x44 pixels
  • Ensure keyboard navigation works smoothly
  • Provide clear focus indicators
  • Use semantic labels for screen readers
  • Maintain sufficient color contrast (WCAG AA)

Theme Integration

HuxSidebar automatically adapts to your app’s theme:
  • Light Mode: Clean white background with subtle borders
  • Dark Mode: Dark background with appropriate contrast
  • Selected State: Uses theme primary color
  • Hover State: Subtle background change based on theme