# Side navigation usage guidelines

> Discover Cimpress UI's side navigation component for building persistent navigation in applications.

Source: https://ui.cimpress.io/components/side-nav/

The side nav component enables persistent navigation within your application.

### When to use

- For applications with multiple sections or pages that need persistent navigation.
- For complex applications with hierarchical navigation structure.

### When not to use

- For temporary or contextual navigation.
- When screen real estate is extremely limited and every pixel counts.

## Usage

```tsx
import { SideNav, SideNavList, SideNavListItem } from '@cimpress-ui/react';
import { IconPlaceholder } from '@cimpress-ui/react/icons';

export default function Demo() {
  return (
    <SideNav>
      <SideNavList>
        <SideNavListItem href="#1" isActive={true} icon={<IconPlaceholder />}>
          Menu item 1
        </SideNavListItem>
        <SideNavListItem href="#2" isActive={false} icon={<IconPlaceholder />}>
          Menu item 2
        </SideNavListItem>
        <SideNavListItem href="#3" isActive={false} icon={<IconPlaceholder />}>
          Menu item 3
        </SideNavListItem>
        <SideNavListItem href="#4" isActive={false} icon={<IconPlaceholder />}>
          Menu item 4
        </SideNavListItem>
      </SideNavList>
    </SideNav>
  );
}
```

Side nav provides a simple list of navigation items with icons and labels. We recommend using side nav inside [app shell](/components/app-shell), which handles the mobile drawer, header toggle, and layout offsets for you.

### Within app shell

```tsx
import { AppHeader, AppShell, AppShellBody, SideNav, SideNavList, SideNavListItem, Text } from '@cimpress-ui/react';
import { IconPlaceholder } from '@cimpress-ui/react/icons';

export default function Demo() {
  return (
    <AppShell>
      <AppHeader title="My app" titleLink={{ href: '#', target: '_self' }} />
      <SideNav>
        <SideNavList>
          <SideNavListItem href="#1" isActive={true} icon={<IconPlaceholder />}>
            Menu item 1
          </SideNavListItem>
          <SideNavListItem href="#2" isActive={false} icon={<IconPlaceholder />}>
            Menu item 2
          </SideNavListItem>
          <SideNavListItem href="#3" isActive={false} icon={<IconPlaceholder />}>
            Menu item 3
          </SideNavListItem>
        </SideNavList>
      </SideNav>
      <AppShellBody>
        <Text as="p" margin={16}>
          Hello, world!
        </Text>
      </AppShellBody>
    </AppShell>
  );
}
```

Inside [app shell](/components/app-shell), side nav connects to the [app header](/components/app-header). App shell manages open and close state, shows a navigation toggle on smaller screens, and keeps the side nav expanded on large viewports by default.

### With sections

```tsx
import { SideNav, SideNavList, SideNavListItem, SideNavListSection } from '@cimpress-ui/react';
import { IconPlaceholder } from '@cimpress-ui/react/icons';

export default function Demo() {
  return (
    <SideNav>
      <SideNavList>
        <SideNavListItem href="#1" isActive={true} icon={<IconPlaceholder />}>
          Menu item 1
        </SideNavListItem>
        <SideNavListItem href="#2" isActive={false} icon={<IconPlaceholder />}>
          Menu item 2
        </SideNavListItem>
        <SideNavListSection label="Section 1">
          <SideNavListItem href="#3" isActive={false} icon={<IconPlaceholder />}>
            Menu item 3
          </SideNavListItem>
          <SideNavListItem href="#4" isActive={false} icon={<IconPlaceholder />}>
            Menu item 4
          </SideNavListItem>
        </SideNavListSection>
        <SideNavListSection label="Section 2">
          <SideNavListItem href="#5" isActive={false} icon={<IconPlaceholder />}>
            Menu item 5
          </SideNavListItem>
          <SideNavListItem href="#6" isActive={false} icon={<IconPlaceholder />}>
            Menu item 6
          </SideNavListItem>
        </SideNavListSection>
      </SideNavList>
    </SideNav>
  );
}
```

Sections can be used to organize related navigation items.

### With groups (unstable)

```tsx
import {
  SideNav,
  SideNavList,
  SideNavListItem,
  UNSTABLE_SideNavListGroup as SideNavListGroup,
} from '@cimpress-ui/react';
import { IconPlaceholder } from '@cimpress-ui/react/icons';

export default function Demo() {
  return (
    <SideNav>
      <SideNavList>
        <SideNavListItem href="#1" isActive={false} icon={<IconPlaceholder />}>
          Menu item 1
        </SideNavListItem>
        <SideNavListGroup label="Group 1" icon={<IconPlaceholder />} defaultExpanded>
          <SideNavListItem href="#2" isActive={true}>
            Menu item 2
          </SideNavListItem>
          <SideNavListGroup label="Nested group" defaultExpanded>
            <SideNavListItem href="#3" isActive={false}>
              Menu item 3
            </SideNavListItem>
            <SideNavListItem href="#4" isActive={false}>
              Menu item 4
            </SideNavListItem>
          </SideNavListGroup>
        </SideNavListGroup>
        <SideNavListGroup label="Group 2" icon={<IconPlaceholder />}>
          <SideNavListItem href="#5" isActive={false}>
            Menu item 5
          </SideNavListItem>
          <SideNavListItem href="#6" isActive={false}>
            Menu item 6
          </SideNavListItem>
        </SideNavListGroup>
      </SideNavList>
    </SideNav>
  );
}
```

Groups are expandable sections for nested navigation.

### Collapsible (unstable)

:::caution
This feature is currently unstable and may change in future releases. We recommend using it with caution and only when
necessary.
:::

```tsx
import { AppHeader, AppShell, AppShellBody, SideNav, SideNavList, SideNavListItem, Text } from '@cimpress-ui/react';
import { IconPlaceholder } from '@cimpress-ui/react/icons';

export default function Demo() {
  return (
    <AppShell>
      <AppHeader title="My app" titleLink={{ href: '#', target: '_self' }} />
      <SideNav UNSTABLE_isCollapsible>
        <SideNavList>
          <SideNavListItem href="#1" isActive={true} icon={<IconPlaceholder />}>
            Menu item 1
          </SideNavListItem>
          <SideNavListItem href="#2" isActive={false} icon={<IconPlaceholder />}>
            Menu item 2
          </SideNavListItem>
          <SideNavListItem href="#3" isActive={false} icon={<IconPlaceholder />}>
            Menu item 3
          </SideNavListItem>
        </SideNavList>
      </SideNav>
      <AppShellBody>
        <Text as="p" margin={16}>
          Hello, world!
        </Text>
      </AppShellBody>
    </AppShell>
  );
}
```

Side nav supports a collapsible mode, letting users reduce it to an icon-only rail for more screen space. In this mode, ensure every top-level navigation item includes a clear and meaningful icon.

## Best practices

### Navigation organization

- Use sections to visually separate unrelated areas of the navigation.
- Use groups for nested navigation that users can expand and collapse.
- Use clear, concise labels that describe the destination.

### Icon selection

- Use consistent icon styles throughout your navigation.
- Choose icons that clearly represent their destination.

### Active state management

- Always indicate the current page.

### Expansion state

- Consider persisting the expanded state for better user experience.
