React Navs & Tabs Components
Navs & Tabs
Limited-time offer for the first 100 customers in 2025. Use code 2025SKY25 at checkout.
Documentation and examples for how to use CoreUI's included React navigation components.
Other Frameworks
CoreUI components are available as native Angular, Bootstrap (Vanilla JS), and Vue components. To learn more please visit the following pages.
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.
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.
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. By default, navs are left-aligned, but you can easily change them to center or right aligned.
Centered with .justify-content-center
:
Right-aligned with .justify-content-end
:
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
).
Tabs#
Takes the basic nav from above and adds the variant="tabs"
class to generate a tabbed interface
Pills#
Take that same code, but use variant="pills"
instead:
Underline#
Take that same code, but use variant="underline"
instead:
Underline border#
Take that same code, but use variant="underline-border"
instead:
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.
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.
Working with flex utilities#
If you need responsive nav variations, consider using a series of flexbox utilities. 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.
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 WAI ARIA Authoring Practices. See 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#
Pills with dropdowns#
Tab panes#
Dynamic tabbed interfaces, as described in the WAI ARIA Authoring Practices, 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.
The tabs also works with pills.
API#
Check out the documentation below for a comprehensive guide to all the props you can use with the components mentioned here.