Tabs
Tabs
: Provides context and state for all componentsTabList
: Wrapper for the Tab componentsTab
: element that serves as a label for one of the tab panels and can be activated to display that panel.TabPanels
: Wrapper for the TabPanel components TabPanel: element that contains the content associated with a tabThese components can be imported as follows:
Examples
Default Settings
The Tabs component in Chakra UI is quite flexible when it comes to ordering. You are allowed to place TabList and TabPanels in any order within the Tabs component. For instance, you could place the TabList at the bottom, or even have multiple TabLists. Despite this flexibility, remember to maintain a consistent layout for an optimal user experience.
one!
two!
three!
Code
Variants and Colors
line
: displays an underline below the active tab.enclosed
: adds a border around the active tab and the tab panel.enclosed-colored
: is similar to the enclosed variant but with a colored background on the active tab.soft-rounded
: gives the active tab a rounded outline and a slightly shaded background.solid-rounded
: gives the active tab a solid background and rounded corners.unstyled
: doesn't apply any styles to the tabs. This is particularly useful when you want to build a completely custom tab design from scratch.one!
two!
Code
one!
two!
Code
Tab Sizing
one!
two!
Code
Changing Alignment
one!
two!
Code
Fitted Tabs
one!
two!
three!
four!
five!
Code
TabIndicator: Styling the tab states via props
In Chakra UI's Tabs component, the TabIndicator represents a visual indicator that highlights the currently active tab. It is a visual element that helps users identify the active tab and provides visual feedback as they navigate through different tab options.
The TabIndicator is typically a horizontal line or a bar that appears below or above the active tab, indicating its selected state. It visually separates the active tab from the rest of the tabs and provides a clear visual cue of the user's current selection.
Chakra UI's Tabs component automatically manages the positioning and appearance of the TabIndicator based on the selected tab. It updates its position and size when the active tab changes, providing a smooth transition between tabs. You can customize the appearance of the TabIndicator by modifying the styles associated with the active tab. Chakra UI provides a range of styling options to customize the TabIndicator's color, size, position, and animation using its theme and style props.
The TabIndicator in Chakra UI's Tabs component serves as a visual guide to help users navigate and understand the current state of the tabbed interface.
one!
two!
three!
Code
Customizing individual tabs
one!
two!
three!
four!
Code
The onChange Property
Code
Focus a specific tab by default:
Code
Disable a Tab
Code
Manually activate tabs
one!
two!
Code
Lazy Tab Mounting
one!
Code
Controlled Tabs
Slide or click tabs
Just tabbing along...
I am some rad tab content.
Code
Custom Tab Components
Code
DataTabs
Code
Did you know?
Creative Idea No. 1
Nested Tab 1 Content
Nested Tab 2 Content
Tab 2 Content
Code
Creative Idea No. 2
Tab 1 Content
Tab 2 Content
Code
Creative Idea No. 3
Code
copyright © 2023 IHeartComponents | evanmarie.com
created with love by the I♥️Components team using
Special thanks to Stefan Bohacek / Generative Placeholders.