Skip to content

Tab

The Tab component offers an effective way to organize and display content in a layered interface. It allows users to switch between different sections of information by selecting corresponding tabs, making it ideal for displaying diverse content without overwhelming the user.

Add the Tab component and its sub-components to your project using the OrbitUI CLI:

Terminal window
npx orbitkit@latest add tab

Import the Tab, TabList, TabTrigger, and TabContent components.

Start with the main Tab component, which can optionally set a defaultValue for the initially active tab. Inside, place a TabList to group your TabTrigger elements. Each TabTrigger needs a unique value that corresponds to the value of its associated TabContent. Finally, add your TabContent panels, ensuring each has a value that matches a TabTrigger.

The Tab system consists of several components, each with its own set of props:

The Tab component serves as the main wrapper for the entire tabbed interface. It manages the active tab state and provides context to its children.

PropTypeDefault
defaultValuestringundefined

This component accepts all the standard HTML attributes that a <div> element would.

The TabList component acts as the container for all TabTrigger elements. It semantically groups the tab controls. This component accepts all the standard HTML attributes that a <div> element would.

The TabTrigger component represents an individual clickable tab that controls the visibility of its corresponding TabContent.

PropTypeDefault
valuestringundefined
  • value: A unique identifier that links this trigger to its corresponding TabContent panel.

This component accepts all the standard HTML attributes that a <button> element would.

The TabContent component contains the actual content associated with a specific tab. Its visibility is controlled by the active TabTrigger.

PropTypeDefault
valuestringundefined
  • value: A unique identifier that links this content panel to its corresponding TabTrigger.

This component accepts all the standard HTML attributes that a <div> element would.