Components

Navigation

Sidebar navigation based on React Router NavLink

Overview

Navigation is a sidebar navigation compound component. Based on React Router's NavLink, it automatically tracks the active state based on URL.

  • Compound — Container, List, Item
  • Auto active — Automatic active state detection based on URL
  • Match strategy — exact, startsWith, endsWith matching
  • Render prop — Access { isActive, isPending } in Item's children, className, style

Basic Usage

import { Navigation } from '@illog/ui'
 
<Navigation.Container>
  <Navigation.List match="startsWith">
    <Navigation.Item to="/dashboard" iconName="home">
      Dashboard
    </Navigation.Item>
    <Navigation.Item to="/tasks" iconName="check-square">
      Tasks
    </Navigation.Item>
    <Navigation.Item to="/analytics" iconName="bar-chart">
      Analytics
    </Navigation.Item>
    <Navigation.Item to="/settings" iconName="settings">
      Settings
    </Navigation.Item>
  </Navigation.List>
</Navigation.Container>

Render Prop Pattern

<Navigation.Item to="/tasks">
  {({ isActive, isPending }) => (
    <Inline gap="300" align="center">
      <Icon name="check-square" color={isActive ? 'iconBrandDefault' : 'iconDefaultTertiary'} />
      <Text color={isActive ? 'textBrandDefault' : 'textDefaultDefault'}>
        Tasks
      </Text>
      {isPending && <Spinner size="sm" />}
    </Inline>
  )}
</Navigation.Item>

Match Strategy

// Active only when URL matches exactly
<Navigation.List match="exact">
  <Navigation.Item to="/tasks">Tasks</Navigation.Item>
</Navigation.List>
 
// Active when URL starts with /tasks (includes /tasks/123)
<Navigation.List match="startsWith">
  <Navigation.Item to="/tasks">Tasks</Navigation.Item>
</Navigation.List>
 
// Override on individual Item
<Navigation.Item to="/tasks" match="exact">Tasks</Navigation.Item>

Sub-components

PropTypeDescription
childrenReactNodeNavigation.List elements

Fixed sidebar: position: fixed, width: 256px, padding: 600.

PropTypeDefaultDescription
match'exact' | 'startsWith' | 'endsWith''exact'Match strategy
...sprinklesSprinklesDesign token props

Wrapped with <nav aria-label="Main navigation">.

PropTypeDefaultDescription
tostringrequiredRoute path
iconNameIconNameIcon (default children mode)
childrenReactNode | ((props) => ReactNode)Content or render prop
classNamestring | ((props) => string)CSS class or render prop
styleCSSProperties | ((props) => CSSProperties)Style or render prop
matchMatchStrategyOverride List's match strategy
endbooleanNavLink end prop
disabledbooleanDisabled state
onClick(e: MouseEvent) => voidClick handler

Render Prop Type

type ItemRenderProps = {
  isActive: boolean   // Whether current URL matches
  isPending: boolean  // React Router pending state
}

Guidelines

  • Container uses position: fixed, so apply margin-left: 256px to adjacent content
  • match="startsWith" is suitable for most nested routes
  • Requires React Router dependency — use only in React Router projects