Tabs
import Tabs from 'frui/Tabs';
Props
Tabs Props
Name | Type | Required | Notes |
---|---|---|---|
vertical | boolean | No | Displays tabs vertically (default: false) |
scrollable | boolean | No | Enables horizontal scrolling (default: false) |
centered | boolean | No | Centers tabs horizontally (default: false) |
fullWidth | boolean | No | Makes tabs full-width (default: false) |
wrap | boolean | No | Allows tab labels to wrap instead of truncate (default: false) |
TabProps (for each tab in tabs array)
Name | Type | Required | Notes |
---|---|---|---|
label | string | Yes | The label displayed on the tab |
icon | ReactNode | No | Icon for the tab (optional) |
disabled | boolean | No | Disables the tab (default: false) |
style | CSS Object | No | Custom CSS styles for the tab |
className | string | No | Custom class names for the tab |
Basic
A simple example of the Tabs component with three tabs.
Content 1
Content 2
Content 3
<Tabs
tabs={[
{ label: 'Tab 1' },
{ label: 'Tab 2' },
{ label: 'Tab 3' },
]}
panels={[
<div key="1">{_('Content for Tab 1')}</div>,
<div key="2">{_('Content for Tab 2')}</div>,
<div key="3">{_('Content for Tab 3')}</div>,
]}
/>
Scrollable
Enables horizontal scrolling when there are more tabs than fit in the container.
Content 1
Content 2
Content 3
Content 4
Content 5
<Tabs
tabs={[
{ label: 'Tab 1' },
{ label: 'Tab 2' },
{ label: 'Tab 3' },
{ label: 'Tab 4' },
{ label: 'Tab 5' },
]}
panels={[
<p key="1">{_('Content 1')}</p>,
<p key="2">{_('Content 2')}</p>,
<p key="3">{_('Content 3')}</p>,
<p key="4">{_('Content 4')}</p>,
<p key="5">{_('Content 5')}</p>,
]}
scrollable
/>
Disabled
Disables a tab, making it unclickable and visually distinct.
Content 1
Content 2 (disabled)
Content 3
<Tabs
tabs={[
{ label: 'Tab 1' },
{ label: 'Tab 2', disabled: true },
{ label: 'Tab 3' },
]}
panels={[
<p key="1">{_('Content 1')}</p>,
<p key="2">{_('Content 2 (disabled)')}</p>,
<p key="3">{_('Content 3')}</p>,
]}
/>
Icons
Adds icons to tabs using the icon prop.
Home Content
User Content
Settings Content
<Tabs
tabs={[
{ label: 'Home', icon: <i className="fas fa-home"></i> },
{ label: 'User', icon: <i className="fas fa-user"></i> },
{ label: 'Settings', icon: <i className="fas fa-cog"></i> },
]}
panels={[
<p key="1">{_('Home Content')}</p>,
<p key="2">{_('User Content')}</p>,
<p key="3">{_('Settings Content')}</p>,
]}
/>
Vertical
Displays tabs vertically instead of horizontally.
Content 1
Content 2
Content 3
<Tabs
tabs={[
{ label: 'Tab 1' },
{ label: 'Tab 2' },
{ label: 'Tab 3' },
]}
panels={[
<p key="1">{_('Content 1')}</p>,
<p key="2">{_('Content 2')}</p>,
<p key="3">{_('Content 3')}</p>,
]}
vertical
/>
Centered
Centers the tabs horizontally within the container.
Content 1
Content 2
Content 3
<Tabs
tabs={[
{ label: 'Tab 1' },
{ label: 'Tab 2' },
{ label: 'Tab 3' },
]}
panels={[
<p key="1">{_('Content 1')}</p>,
<p key="2">{_('Content 2')}</p>,
<p key="3">{_('Content 3')}</p>,
]}
centered
/>
FullWidth
Makes each tab take the full width of the container.
Content 1
Content 2
Content 3
<Tabs
tabs={[
{ label: 'Tab 1' },
{ label: 'Tab 2' },
{ label: 'Tab 3' },
]}
panels={[
<p key="1">{_('Content 1')}</p>,
<p key="2">{_('Content 2')}</p>,
<p key="3">{_('Content 3')}</p>,
]}
fullWidth
/>
Wrap
Allows long tab labels to wrap instead of being truncated.
Content 1
Content 2
Content 3
<Tabs
tabs={[
{ label: 'Tab with a Very Long Label That Needs Wrapping' },
{ label: 'Tab 2' },
{ label: 'Tab 3' },
]}
panels={[
<p key="1">{_('Content 1')}</p>,
<p key="2">{_('Content 2')}</p>,
<p key="3">{_('Content 3')}</p>,
]}
wrap
/>
Custom Styles
You can add your own custom class to the alert component or use thefrui-tab
frui-tab-active
frui-tab-disabled
frui-tab-panels
CSS class.