Role-Based Navigation

Role-Based Navigation

Navigation
AI
Layout

Adaptive navigation component that changes menu items and quick actions based on the selected user role.

Preview

Navigation adapts based on selected role

Role-Based Nav

Adapts to your role

Primary Navigation
Quick Actions
Navigation order optimized based on your usage frequency

Custom Roles

Provide custom role configurations

Role-Based Nav

Adapts to your role

Primary Navigation
Quick Actions
Layout personalized based on your recent activity

Without AI Message

Hide the AI optimization footer

Role-Based Nav

Adapts to your role

Primary Navigation
Quick Actions

Props

Component API reference

PropTypeDefaultDescription
defaultRoleRoleKey'product-manager'Default selected role (uncontrolled)
roleRoleKey—Controlled role value
onRoleChange(role: RoleKey) => void—Callback when role changes
rolesRole[][...defaultRoles]Available roles with nav items and quick actions
onNavClick(item: string, roleId: RoleKey) => void—Callback when a nav item is clicked
onQuickActionClick(action: string, roleId: RoleKey) => void—Callback when a quick action is clicked
aiMessagestring'Navigation order optimized...'AI optimization message in footer (empty to hide)
classNamestring—Additional CSS classes

Usage

Import and implementation example

import { RoleBasedNavigation } from '@/components/ui/role-based-navigation'
import type { Role, RoleKey } from '@/components/ui/role-based-navigation'
export default function Example() {
const handleNavClick = (item: string, roleId: RoleKey) => {
console.log(`Navigating to ${item} as ${roleId}`)
}
return (
<RoleBasedNavigation
defaultRole="developer"
onRoleChange={(role) => console.log('Role:', role)}
onNavClick={handleNavClick}
onQuickActionClick={(action) => console.log('Action:', action)}
/>
)
}

Features

Built-in functionality

  • Role switching: Tab-based role selector with three default roles
  • Adaptive navigation: Primary nav and quick actions change per role
  • Most used indicator: First nav item highlighted as most frequently used
  • Quick actions: Gradient action buttons for common tasks
  • AI footer: Optional AI optimization message
  • Controlled/uncontrolled: Supports both controlled and uncontrolled role state
  • Customizable roles: Provide custom roles with nav items and actions

Accessibility

Accessibility considerations

ARIA Attributes

Role tabs use button elements for keyboard accessNavigation items are interactive buttons

Keyboard Navigation

KeyAction
TabNavigate between role tabs, nav items, and quick actions
Enter / SpaceSelect a role, nav item, or quick action

Notes

  • Active role tab has distinct visual styling
  • Most used badge provides extra context for the primary nav item
  • Quick actions use gradient styling for visual prominence

Related Components

TabsNavigationSidebar