Tab Group
Tabs organize related content into distinct sections and provide users with a navigational interface to switch between these sections.
Basic
Selected Index: 3
Source Code
import {
TabHeader,
TabList,
TabListGroup,
TabListItem,
TabPanel,
TabPanels,
Tabs,
Text,
} from '@ocean-network-express/magenta-ui/react';
import React from 'react';
Uncontrolled
- By default, the group is closed. To have it open initially, use the
defaultOpenprop:
Source Code
import * as React from 'react';
import {
TabPanel,
TabPanels,
Tabs,
TabListItem,
TabList,
TabHeader,
TabListGroup,
Text
} from '@ocean-network-express/magenta-ui/react';
Controlled
- To manage the open state of the group, use the
openandonOpenChangeprops:
Source Code
import * as React from 'react';
import {
TabPanel,
TabPanels,
Tabs,
TabListItem,
TabList,
TabHeader,
TabListGroup,
Text
} from '@ocean-network-express/magenta-ui/react';
Colors
- TabGroup supports 6 colors:
blue,green,orange,red,royal, andpurple. The default color isblue. - The active tab’s color matches the color of its group. For standalone tabs (not in a group), the active color defaults to
primary.
Group 1
Group 2
Group 3
Group 4
Group 5
Group 6
Source Code
import {
TabHeader,
TabList,
TabListGroup,
TabListGroupProps,
TabListItem,
TabPanel,
TabPanels,
Tabs,
Text,
} from '@ocean-network-express/magenta-ui/react';
import React from 'react';Default value
- The
TabGroupcomponent allows you to set a default color for the entire group using thedefaultColorprop. - The
defaultColorprop accepts a value of typeColorOption, which defines the available color options in the design system.
Source Code
<TabListGroup defaultColor="orange">
{/* Tab items */}
</TabListGroup>
Controlled value
- You can control the color of a group by using the
colorandonColorChangeprops. - The
colorprop sets the current color, andonColorChangeis called when the user selects a new color.
Source Code
const [color, setColor] = React.useState<ColorOption>('orange');
return (
<div style={{ width: '700px' }}>
<Text size="lg" style={{ marginBottom: 16 }} >
Current Color Of Group 1: {color}
</Text>
<Tabs defaultIndex={0} size="lg">
<TabHeader>
<TabList>
<TabListGroupSizes
- TabGroup supports 4 sizes
sm,md,lgandresponsiveand can be changed by passing thesizeprop. - Default size is
lg.
Group name
Group name
Group name
Source Code
import {
TabHeader,
TabList,
TabListGroup,
TabListGroupProps,
TabListItem,
TabPanel,
TabPanels,
Tabs,
Text,
TextProps,
} from '@ocean-network-express/magenta-ui/react';- With size
responsive, the component will be responsive to the viewport.
Screen prefix | Screen width | Component size |
|---|---|---|
xs → xl | 0px → 1279px | sm |
xl → 3xl | 1280px → 1919px | md |
3xl → ∞ | 1920px → ∞ | lg |
Group name
Source Code
import {
TabHeader,
TabList,
TabListGroup,
TabListItem,
TabPanel,
TabPanels,
Tabs,
Text,
} from '@ocean-network-express/magenta-ui/react';
import React from 'react';
Accessibility
TabGroup component follows WAI-ARIA recommendations on accessibility.
Keyboard interactions
Key | Description | Condition |
|---|---|---|
Enter / Space | Open/Collapse the TabGroup items | Focused to TabGroup element |
Was this page helpful?
Tab Bar
Navigation Tabs
TabsGroup
Tab Group - Examples