Tabs

The Tabs component from pol-ui can be used to show a list of tab items that you can click on to change the content inside of the main tabs component using React state reactivity.

Importation

Import the component from pol-ui to use the Tabs element:

import { Tabs } from "pol-ui";

Default Tabs

Default Tabs

import { Tabs } from "pol-ui";
 
const tabs = [
  {
    name: "Product",
    content: (
      <div className="bg-secondary-200 p-6 rounded-2xl">
        <h2 className="text-3xl text-secondary-900 font-bold">Product Tab</h2>
        <p>
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur
        </p>
      </div>
    ),
  },
  {
    name: "Features",
    content: (
      <div className="bg-secondary-200 p-6 rounded-2xl">
        <h2 className="text-3xl text-secondary-900 font-bold">Features Tab</h2>
        <p>
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem
        </p>
      </div>
    ),
  },
  {
    name: "Reviews",
    content: (
      <div className="bg-secondary-200 p-6 rounded-2xl">
        <h2 className="text-3xl text-secondary-900 font-bold">Reviews Tab</h2>
        <p>
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur
        </p>
      </div>
    ),
  },
  {
    name: "Customers",
    content: (
      <div className="bg-secondary-200 p-6 rounded-2xl">
        <h2 className="text-3xl text-secondary-900 font-bold">Customers Tab</h2>
        <p>
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
        </p>
      </div>
    ),
  },
];
 
export const TabsExample = (): JSX.Element => (
  <div className=" relative flex flex-col mx-auto w-full  items-start justify-start">
    <Tabs tabs={tabs} />
  </div>
);

Props

Prop nameTypeDefaultDescription
tabsTab[]-The tabs to display
containerClassNamestring-The class name of the
container
activeTabClassNamestring-The class name of the
active tab
tabClassNamestring-The class name of the tab
contentClassNamestring-The class name of the
content
hasMotionbooleanfalseIf the tabs have motion
hasNavMotionbooleantrueIf the tabs have nav
motion
modecontained / underlinedTabMode.underlinedThe mode of the tabs
themeTabsTheme-The theme of the tabs

Tabs

Prop nameTypeDefaultDescription
namestring-The name of the tab
contentReact.ReactNode-The content of the tab
disabledbooleanfalseIf the tab is disabled

Examples

Contained Tabs

Contained Tabs

import { Tabs } from "pol-ui";
 
const tabs = [
  {
    name: "Product",
    content: (
      <div className="bg-secondary-200 p-6 rounded-2xl">
        <h2 className="text-3xl text-secondary-900 font-bold">Product Tab</h2>
        <p>
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur
        </p>
      </div>
    ),
  },
  {
    name: "Features",
    content: (
      <div className="bg-secondary-200 p-6 rounded-2xl">
        <h2 className="text-3xl text-secondary-900 font-bold">Features Tab</h2>
        <p>
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem
        </p>
      </div>
    ),
  },
  {
    name: "Reviews",
    content: (
      <div className="bg-secondary-200 p-6 rounded-2xl">
        <h2 className="text-3xl text-secondary-900 font-bold">Reviews Tab</h2>
        <p>
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur
        </p>
      </div>
    ),
  },
  {
    name: "Customers",
    content: (
      <div className="bg-secondary-200 p-6 rounded-2xl">
        <h2 className="text-3xl text-secondary-900 font-bold">Customers Tab</h2>
        <p>
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
        </p>
      </div>
    ),
  },
];
 
export const TabsExample = (): JSX.Element => (
  <div className=" relative flex flex-col mx-auto w-full  items-start justify-start">
    <Tabs tabs={tabs} mode="contained" />
  </div>
);

Tabs with motion

With Motion

import { Tabs } from "pol-ui";
 
const tabs = [
  {
    name: "Product",
    content: (
      <div className="bg-secondary-200 p-6 rounded-2xl">
        <h2 className="text-3xl text-secondary-900 font-bold">Product Tab</h2>
        <p>
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur
        </p>
      </div>
    ),
  },
  {
    name: "Features",
    content: (
      <div className="bg-secondary-200 p-6 rounded-2xl">
        <h2 className="text-3xl text-secondary-900 font-bold">Features Tab</h2>
        <p>
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem
        </p>
      </div>
    ),
  },
  {
    name: "Reviews",
    content: (
      <div className="bg-secondary-200 p-6 rounded-2xl">
        <h2 className="text-3xl text-secondary-900 font-bold">Reviews Tab</h2>
        <p>
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur
        </p>
      </div>
    ),
  },
  {
    name: "Customers",
    content: (
      <div className="bg-secondary-200 p-6 rounded-2xl">
        <h2 className="text-3xl text-secondary-900 font-bold">Customers Tab</h2>
        <p>
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
        </p>
      </div>
    ),
  },
];
 
export const TabsExample = (): JSX.Element => (
  <div className=" relative flex flex-col mx-auto w-full  items-start justify-start">
    <Tabs tabs={tabs} hasMotion={true} />
  </div>
);

Tabs without nav motion

Without Nav Motion

import { Tabs } from "pol-ui";
 
const tabs = [
  {
    name: "Product",
    content: (
      <div className="bg-secondary-200 p-6 rounded-2xl">
        <h2 className="text-3xl text-secondary-900 font-bold">Product Tab</h2>
        <p>
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur
        </p>
      </div>
    ),
  },
  {
    name: "Features",
    content: (
      <div className="bg-secondary-200 p-6 rounded-2xl">
        <h2 className="text-3xl text-secondary-900 font-bold">Features Tab</h2>
        <p>
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem
        </p>
      </div>
    ),
  },
  {
    name: "Reviews",
    content: (
      <div className="bg-secondary-200 p-6 rounded-2xl">
        <h2 className="text-3xl text-secondary-900 font-bold">Reviews Tab</h2>
        <p>
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur
        </p>
      </div>
    ),
  },
  {
    name: "Customers",
    content: (
      <div className="bg-secondary-200 p-6 rounded-2xl">
        <h2 className="text-3xl text-secondary-900 font-bold">Customers Tab</h2>
        <p>
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
        </p>
      </div>
    ),
  },
];
 
export const TabsExample = (): JSX.Element => (
  <div className=" relative flex flex-col mx-auto w-full  items-start justify-start">
    <Tabs tabs={tabs} hasNavMotion={false} />
  </div>
);

Disabled tab

Without Nav Motion

import { Tabs } from "pol-ui";
 
const tabs = [
  {
    name: "Enabled",
    content: (
      <div className="bg-secondary-200 p-6 rounded-2xl">
        <h2 className="text-3xl text-secondary-900 font-bold">Enabled Tab</h2>
        <p>
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur
        </p>
      </div>
    ),
  },
  {
    name: "Disabled",
    disabled: true,
    content: (
      <div className="bg-secondary-200 p-6 rounded-2xl">
        <h2 className="text-3xl text-secondary-900 font-bold">Disabled Tab</h2>
        <p>
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur adipisicing elit. Ipsam, quas.
          Lorem ipsum dolor sit amet consecte tur
        </p>
      </div>
    ),
  },
];
 
export const TabsExample = (): JSX.Element => (
  <div className=" relative flex flex-col mx-auto w-full  items-start justify-start">
    <Tabs tabs={tabs} />
  </div>
);

Theme

To learn more about how to customize the appearance of components, please see the Theme docs.

interface TabsTheme {
  root: {
    base: string;
    shadow: string;
    wrapper: string;
  };
  head: {
    base: string;
    cell: {
      base: string;
    };
  };
  row: {
    base: string;
    hovered: string;
    striped: string;
  };
  body: {
    base: string;
    cell: {
      base: string;
    };;
  };
}

Since March 1, 2024

Proudly Open Source
  • Npm

  • Github

  • Creator

  • Made with love and Pol-ui by Pol Gubau Amores