Skip to main content

Tabs

Displays a tab bar with your content.

Props

Tabs

NameTypeRequiredDefaultDescription
childrenReact.ReactNodeYes-The content of the tabs

TabsBar

NameTypeRequiredDefaultDescription
childrenReact.ReactNodeYes-The tabs

TabsContent

NameTypeRequiredDefaultDescription
childrenReact.ReactNodeYes-The content of the active tab

Tab

NameTypeRequiredDefaultDescription
childrenReact.ReactNodeYes-The label of the tab
activebooleanNo-The active state of the tab
onClick(event: React.MouseEvent<HTMLButtonElement>) => voidNo-The click event handler of the tab
classNamestringNo-Additional class name

Example

Result
Loading...
Live Editor
function Example() {
    const [activeTab, setActiveTab] = React.useState("one");
    return (
        <Tabs>
            <TabsBar>
                <Tab
                    active={activeTab === "one"}
                    onClick={() => setActiveTab("one")}
                >
                    One
                </Tab>
                <Tab
                    active={activeTab === "two"}
                    onClick={() => setActiveTab("two")}
                >
                    Two
                </Tab>
                <Tab
                    active={activeTab === "three"}
                    onClick={() => setActiveTab("three")}
                >
                    Three
                </Tab>
                <Tab
                    active={activeTab === "four"}
                    onClick={() => setActiveTab("four")}
                >
                    Four
                </Tab>
            </TabsBar>
            <TabsContent>Active tab: {activeTab}</TabsContent>
        </Tabs>
    );
}