---
title: TabBar
---

import LibraryInfo from '@theme/LibraryInfo'
import { Feedback, TokensTable, PropsTable } from '../../src/components'
import { TabBar } from '@telus-uds/components-base'
import { TabBar as BaseDocs } from 'docs/@telus-uds/components-base'
import AvailableOnBoth from '../../partials/_platform-considerations-both.mdx'
import NoStylisticVariants from '../../partials/_variants-none.mdx'

# TabBar

<LibraryInfo figmaLink="https://www.figma.com/design/4zJn2Qn6uXOqPP1GVDipy6/%F0%9F%8D%80-UDS-TELUS-Components?node-id=107060-23291&t=MlFCtTqI5XysTtfc-0" />

:::caution

Intended for mobile use only. TabBar allows the user to navigate to other areas of the mobile application. It appears at the bottom of the viewport and expands 100% of the width.

:::

```jsx live
function TabBarExample() {
  const [selectedTab, setSelectedTab] = useState('one')

  const {
    Settings,
    SettingsSolid,
    Shop,
    Receipt,
    Download,
    Add,
    Refresh,
    Close,
    ChevronLeft,
    ChevronRight
  } = Icons || {}

  return (
    <TabBar
      items={[
        {
          label: 'Tab one',
          id: 'one',
          icon: Settings,
          iconActive: SettingsSolid
        },
        {
          label: 'Tab two',
          id: 'two',
          icon: Shop,
          iconActive: Receipt
        },
        {
          label: 'Tab three',
          id: 'three',
          icon: Download,
          iconActive: Add
        },
        {
          label: 'Tab Four',
          id: 'Four',
          icon: Refresh,
          iconActive: Close
        },
        {
          label: 'Tab Five',
          id: 'Five',
          icon: ChevronLeft,
          iconActive: ChevronRight
        }
      ]}
      initialValue="one"
      onChange={setSelectedTab}
    />
  )
}
```

## Introduction

The TabBar component is used for navigating between different sections of a mobile application. It is designed to expand horizontally to fit the viewport width and is fixed to the bottom of the screen. The component shows up to 5 tabs, each of which should always have a short and concise label. Each tab supports two icon states: `default` and `active`.

#### Default State: Indicates the tab is selectable.

#### Active State: Indicates the currently selected tab and is not interactive.

Note: The component does not support notification badges or disabled items.

To integrate the TabBar into your application, [follow the appropriate instructions](importing-components).

```jsx live
<TabBar
  items={[
    {
      label: 'Tab one',
      id: 'one',
      icon: Icons.Settings,
      iconActive: Icons.SettingsSolid
    },
    {
      label: 'Tab two',
      id: 'two',
      icon: Icons.Shop,
      iconActive: Icons.Receipt
    },
    {
      label: 'Tab three',
      id: 'three',
      icon: Icons.Download,
      iconActive: Icons.Add
    },
    {
      label: 'Tab Four',
      id: 'Four',
      icon: Icons.Refresh,
      iconActive: Icons.Close
    },
    {
      label: 'Tab Five',
      id: 'Five',
      icon: Icons.ChevronLeft,
      iconActive: Icons.ChevronRight
    }
  ]}
  initialValue="one"
/>
```

## Guidance

- Use for Mobile Applications: Designed specifically for mobile applications to facilitate navigation between different areas.
- Maximum Items: Displays up to 5 items to keep the navigation manageable.
- Labels: Each tab must have a short and concise label.
- Icons: Icons should visually support the navigation and should be used alongside labels.
- Expansion: Tab bar items expand based on available space and are spread horizontally. On larger viewports, they expand up to the maximum width of the content.

### Accessibility

Ensure that the `TabBar` is accessible, allowing users to navigate using various methods including touch and keyboard interactions.
Implement assertive focus management to assist screen readers in announcing the correct content when tabs change.

### Controlled Usage

To control the active tab programmatically:

Use the `initialValue` prop to specify the default active tab based on the `id` property.
Provide an `onChange` callback to update the state when a tab is selected. This function should manage the selected tab state and integrate with URL hashes if needed.

### Platform Considerations

<AvailableOnBoth />

The tab bar supports touch gestures for scrolling through tabs and is fixed at the bottom of the screen. On the web, URL hashes can be used to retain tab selection across page reloads.

## Props

### TabBar

<PropsTable base={BaseDocs} />

### TabBarItem

<PropsTable base={BaseDocs.Item} />

## Tokens

<TokensTable base={BaseDocs} component="TabBar" />

## Variants

Theres no variants for TabBar component at the moment

## Feedback

<Feedback component="TabBar" />
