Igloo branding

Tabs

Use to alternate among related views within the same context.

Installation

To install @igloo-ui/tabs in your project, you will need to run the following command using npm:

npm install @igloo-ui/tabs

If you prefer Yarn, use the following command instead:

yarn add @igloo-ui/tabs

Usage

Then to use the component in your code just import it!

import Tabs from '@igloo-ui/tabs';

<Tabs
  tabs={[
    {
      label: 'Premium Tab',
      premium: true,
      children: 'Content of premium tab',
    },
    {
      label: 'Notification Tab',
      notification: true,
      children: 'Content of notification tab',
    },
    {
      label: 'Premium Notification Tab',
      notification: true,
      premium: true,
      children: 'Content of premium notification tab',
    },
  ]}
/>;

Variation

Pass the onClick with the navlink when using react router

<BrowserRouter>
  <Tabs
    selected={selected}
    tabs={[
      {
        label: (
          <NavLink to={'/home'} onClick={() => handleTabChange(0)}>
            Home
          </NavLink>
        ),
        children: (
          <Routes>
            <Route path="/home" element={<div>Home page</div>} />
          </Routes>
        ),
      },
      {
        label: (
          <NavLink to={'/about'} onClick={() => handleTabChange(1)}>
            About
          </NavLink>
        ),
        children: (
          <Routes>
            <Route path="/about" element={<div>About page</div>} />
          </Routes>
        ),
      },
    ]}
  />
</BrowserRouter>

API

PropTypeDescription
onSelectTab(index: number) => voidThe function that's called when a tab is clicked
selectednumberThe index number of the tab that should be selected on load
dataTeststringAdd a data-test tag for automated tests
classNamestringAdd a specific class to the tabs component
isInlinebooleanAdd an inline style to the tabs
tabsTabInterface[]An array of objects that specify the props of the tab buttons