Tabs
This is a pass through component from React-Bootstrap.
See React-Bootstrap for documentation.
Uncontrolled usage
<Tabs
variant="tabs"
defaultActiveKey="profile"
id="uncontrolled-tab-example"
>
<Tab eventKey="home" title="Home">
Hello I am the first panel.
</Tab>
<Tab eventKey="profile" title="Profile">
Hello I am the second panel.
</Tab>
<Tab eventKey="contact" title="Contact" disabled>
Hello I am third first panel.
</Tab>
</Tabs>
Controlled usage
() => {
const [key, setKey] = useState('home');
return (
<Tabs
id="controlled-tab-example"
activeKey={key}
onSelect={(k) => setKey(k)}
>
<Tab eventKey="home" title="Home">
Hello I am the first panel.
</Tab>
<Tab eventKey="profile" title="Profile">
Hello I am the second panel.
</Tab>
<Tab eventKey="contact" title="Contact" disabled>
Hello I am third first panel.
</Tab>
</Tabs>
);
}
Button group usage
<Tabs
defaultActiveKey="profile"
id="uncontrolled-pills-tab-example"
variant="button-group"
>
<Tab eventKey="home" title="Home">
Hello I am the first panel.
</Tab>
<Tab eventKey="profile" title="Profile">
Hello I am the second panel.
</Tab>
<Tab eventKey="contact" title="Contact" disabled>
Hello I am third first panel.
</Tab>
</Tabs>
Pills usage
<Tabs
defaultActiveKey="profile"
id="uncontrolled-pills-tab-example"
variant="pills"
>
<Tab eventKey="home" title="Home">
Hello I am the first panel.
</Tab>
<Tab eventKey="profile" title="Profile">
Hello I am the second panel.
</Tab>
<Tab eventKey="contact" title="Contact" disabled>
Hello I am third first panel.
</Tab>
</Tabs>
Inverse-Pills usage
<Stack className="bg-dark-700 p-4">
<Tabs
variant="inverse-pills"
defaultActiveKey="profile"
id="uncontrolled-pills-tab-example"
>
<Tab eventKey="home" title="Home">
Hello I am the first panel.
</Tab>
<Tab eventKey="profile" title="Profile">
Hello I am the second panel.
</Tab>
<Tab eventKey="contact" title="Contact" disabled>
Hello I am third first panel.
</Tab>
</Tabs>
</Stack>
Inverse Tabs usage
<Stack className="bg-dark-700 p-4">
<Tabs
variant="inverse-tabs"
defaultActiveKey="profile"
id="uncontrolled-pills-tab-example"
>
<Tab eventKey="home" title="Home">
Hello I am the first panel.
</Tab>
<Tab eventKey="profile" title="Profile">
Hello I am the second panel.
</Tab>
<Tab eventKey="contact" title="Contact" disabled>
Hello I am third first panel.
</Tab>
</Tabs>
</Stack>
With notification
<Tabs defaultActiveKey="profile" id="tab-example-with-notification">
<Tab eventKey="home" title="Home">
Hello I am the first panel.
</Tab>
<Tab eventKey="profile" title="Profile" notification={1}>
Hello I am the second panel.
</Tab>
</Tabs>
With screen reader text in notification
<Tabs defaultActiveKey="profile" id="tab-example-with-sr-notification">
<Tab eventKey="home" title="Home">
Hello I am the first panel.
</Tab>
<Tab
eventKey="profile"
title="Profile"
notification={(
<span>
1
<span className="sr-only">notification</span>
</span>
)}
>
Hello I am the second panel.
</Tab>
</Tabs>
Responsive support
<Tabs
variant="tabs"
defaultActiveKey="profile"
id="uncontrolled-tab-example"
>
<Tab eventKey="home" title="Home">
Hello I am the first panel.
</Tab>
<Tab eventKey="dashboard" title="Dashboard">
Hello I am the second panel.
</Tab>
<Tab eventKey="profile" title="Profile" notification={1}>
Hello I am the third panel.
</Tab>
<Tab eventKey="products" title="Products">
Hello I am the fourth panel.
</Tab>
<Tab eventKey="help" title="Help">
Hello I am the fifth panel.
</Tab>
<Tab eventKey="about" title="About">
Hello I am the sixth panel.
</Tab>
<Tab eventKey="updates" title="Updates">
Hello I am the seventh panel.
</Tab>
<Tab eventKey="forum" title="Forum">
Hello I am the eighth panel.
</Tab>
<Tab eventKey="job" title="Job">
Hello I am the ninth panel.
</Tab>
<Tab eventKey="team" title="Our team">
Hello I am the tenth panel.
</Tab>
</Tabs>
Conditional rendering
() => {
const librariesEnabled = true;
const visibleTabs = useMemo(() => {
const tabs = [];
tabs.push(
<Tab
key="courses"
eventKey="courses"
title="Courses"
>
Hello I am the courses panel.
</Tab>
);
tabs.push(
<Tab
key="programs"
eventKey="programs"
title="Programs"
>
Hello I am the programs panel.
</Tab>
);
if (librariesEnabled) {
tabs.push(
<Tab
key="libraries"
eventKey="libraries"
title="Libraries"
>
Hello I am the libraries panel.
</Tab>
);
}
return tabs;
}, [librariesEnabled]);
return (
<Tabs
id="tabs"
defaultActiveKey="courses"
>
{visibleTabs}
</Tabs>
);
}
Tabs.Deprecated
(Deprecated) basic usage
<Tabs.Deprecated
labels={[
'Panel 1',
'Panel 2',
'Panel 3'
]}
>
<div>Hello I am the first panel</div>
<div>Hello I am the second panel</div>
<div>Hello I am the third panel</div>
</Tabs.Deprecated>
Dependencies
Repository | Usage Count |
---|---|
frontend-app-course-authoring | 1 |
Detailed usage locations:
frontend-app-course-authoring
src/generic/configure-modal/ConfigureModal.jsx