---
title: React Navs & Tabs Components
name: Navs & Tabs
description: Documentation and examples for how to use CoreUI's included React navigation components.
route: /components/navs-tabs/
other_frameworks: navs-tabs
---

## Base nav

Navigation available in CoreUI for React share general markup and styles, from the base `.nav` class to the active and disabled states. Swap modifier classes to switch between each style.

The base `<CNav>` component is built with flexbox and provide a strong foundation for building all types of navigation components. It includes some style overrides (for working with lists), some link padding for larger hit areas, and basic disabled styling.

<ExampleSnippet component="NavExample" componentName="React Nav" />

Classes are used throughout, so your markup can be super flexible. Use `<ul>`s like above, `<ol>` if the order of your items is important, or roll your own with a `<nav>` element. Because the .nav uses display: flex, the nav links behave the same as nav items would, but without the extra markup.

<ExampleSnippet component="Nav2Example" componentName="React Nav" />

## Available styles

Change the style of `<CNav>`'s component with modifiers and utilities. Mix and match as needed, or build your own.

### Horizontal alignment

Change the horizontal alignment of your nav with [flexbox utilities](https://coreui.io/bootstrap/docs/layout/grid/#horizontal-alignment). By default, navs are left-aligned, but you can easily change them to center or right aligned.

Centered with `.justify-content-center`:

<ExampleSnippet component="NavHorizontalAlignmentExample" componentName="React Nav" />

Right-aligned with `.justify-content-end`:

<ExampleSnippet component="NavHorizontalAlignment2Example" componentName="React Nav" />

### Vertical

Stack your navigation by changing the flex item direction with the `.flex-column` utility. Need to stack them on some viewports but not others? Use the responsive versions (e.g., `.flex-sm-column`).

<ExampleSnippet component="NavVerticalExample" componentName="React Nav" />

### Tabs

Takes the basic nav from above and adds the `variant="tabs"` class to generate a tabbed interface

<ExampleSnippet component="NavTabsExample" componentName="React Nav" />

### Pills

Take that same code, but use `variant="pills"` instead:

<ExampleSnippet component="NavPillsExample" componentName="React Nav" />

### Underline

Take that same code, but use `variant="underline"` instead:

<ExampleSnippet component="NavUnderlineExample" componentName="React Nav" />

### Underline border

Take that same code, but use `variant="underline-border"` instead:

<ExampleSnippet component="NavUnderlineBorderExample" componentName="React Nav" />

### Enclosed

Use the `variant="enclosed"` class to give your navigation items a subtle border and rounded styling.

<ExampleSnippet component="NavEnclosedExample" componentName="React Nav" />

### Enclosed pills 

Use the `variant="enclosed-pills"` to achieve a pill-style appearance for each nav item, using pill-shaped borders and smoother outlines.

<ExampleSnippet component="NavEnclosedPillsExample" componentName="React Nav" />


### Fill and justify

Force your `<CNav>`'s contents to extend the full available width one of two modifier classes. To proportionately fill all available space with your `.nav-item`s, use `layout="fill"`. Notice that all horizontal space is occupied, but not every nav item has the same width.

<ExampleSnippet component="NavFillAndJustifyExample" componentName="React Nav" />

For equal-width elements, use `layout="justified"`. All horizontal space will be occupied by nav links, but unlike the .nav-fill above, every nav item will be the same width.

<ExampleSnippet component="NavFillAndJustify2Example" componentName="React Nav" />

## Working with flex utilities

If you need responsive nav variations, consider using a series of [flexbox utilities](https://coreui.io/bootstrap/docs/utilities/flex). While more verbose, these utilities offer greater customization across responsive breakpoints. In the example below, our nav will be stacked on the lowest breakpoint, then adapt to a horizontal layout that fills the available width starting from the small breakpoint.

<ExampleSnippet component="NavWorkingWithFlexUtilitiesExample" componentName="React Nav" />

## Regarding accessibility

If you're using navs to provide a navigation bar, be sure to add a `role="navigation"` to the most logical parent container of the `<ul>`, or wrap a `<nav>` element around the whole navigation. Do not add the role to the `<ul>` itself, as this would prevent it from being announced as an actual list by assistive technologies.

Note that navigation bars, even if visually styled as tabs with the `.nav-tabs` class, should **not** be given `role="tablist"`, `role="tab"` or `role="tabpanel"` attributes. These are only appropriate for dynamic tabbed interfaces, as described in the [<abbr title="Web Accessibility Initiative">WAI</abbr> <abbr title="Accessible Rich Internet Applications">ARIA</abbr> Authoring Practices](https://www.w3.org/TR/wai-aria-practices/#tabpanel). See [JavaScript behavior](#javascript-behavior) for dynamic tabbed interfaces in this section for an example. The `aria-current` attribute is not necessary on dynamic tabbed interfaces since our JavaScript handles the selected state by adding `aria-selected="true"` on the active tab.

## Using dropdowns

Add dropdown menus with a little extra HTML.

### Tabs with dropdowns

<ExampleSnippet component="NavTabsWithDropdownExample" componentName="React Nav" />

### Pills with dropdowns

<ExampleSnippet component="NavPillsWithDropdownExample" componentName="React Nav" />

## Tab panes

Dynamic tabbed interfaces, as described in the [<abbr title="Web Accessibility Initiative">WAI</abbr> <abbr title="Accessible Rich Internet Applications">ARIA</abbr> Authoring Practices](https://www.w3.org/TR/wai-aria-practices/#tabpanel), require `role="tablist"`, `role="tab"`, `role="tabpanel"`, and additional `aria-` attributes in order to convey their structure, functionality and current state to users of assistive technologies (such as screen readers).

Note that dynamic tabbed interfaces should not contain dropdown menus, as this causes both usability and accessibility issues. From a usability perspective, the fact that the currently displayed tab's trigger element is not immediately visible (as it's inside the closed dropdown menu) can cause confusion. From an accessibility point of view, there is currently no sensible way to map this sort of construct to a standard WAI ARIA pattern, meaning that it cannot be easily made understandable to users of assistive technologies.

<ExampleSnippet component="NavTabPanesExample" componentName="React Nav" />

The tabs also works with pills.

<ExampleSnippet component="NavTabPanes2Example" componentName="React Nav" />

## API

Check out the documentation below for a comprehensive guide to all the props you can use with the components mentioned here.

- [&lt;CNav /&gt;](./api/#cnav)
- [&lt;CNavItem /&gt;](./api/#cnavitem)
- [&lt;CNavLink /&gt;](./api/#cnavlink)
- [&lt;CTabContent /&gt;](./api/#ctabcontent)
- [&lt;CTabPane /&gt;](./api/#ctabpane)