Usage

import { Tabs, Tab } from '@loomhq/lens'
<Tabs
  tabs={[
    { tabContent: 'First' },
    { tabContent: 'Second', isActive: true },
    { tabContent: 'Third' },
  ]}
/>

Active tab

Scroll offset

Use scrollOffset to allow the Tabs to scroll from edge to edge in narrow screen sizes. Pass the same value used for page side paddings to scrollOffset.

Full tabs

Bottom border

This style is commonly used in full-page layouts, where scrolling may be required. The underline acts as a divider, clearly separating the navigation from the main content and guiding users across the tab options.

With icons

HTML tag

Tabs can be rendered as button or a tags.

Examples

With useState

Pilled Tabs

Use isPilledDesign to use the pilled design for tabs.

  • isPilledDesign will always default in hasFullTabs = true.

Disabled Tabs

Use disabled styling to show tabs that are not currently available. Only the first tab is enabled in this example.

Tabs with tooltips

You can add tooltips to individual tabs by providing tooltipProps to any tab item. This is useful for providing additional context or explanations for tab functionality.

With React Router

Use React Router Link components as tabContent. Additionally add tabIndex=-1 and onClick as shown below to ensure keyboard support.

import { Link, useHistory } from "react-router-dom"
const history = useHistory();

<Tabs
  tabs={[
    {
      tabContent: <Link tabIndex={-1} to="/">Home</Link>,
      isActive: true,
      onClick: () => history.push("/"),
      tabIndex={-1}
    },
    {
      tabContent: <Link to="/about">About</Link>,
      htmlTag: "span",
      onClick: () => history.push("/about"),
      tabIndex={-1}
    },
  ]}
/>

Deprecated - Legacy Tab Structure

This legacy approach to defining tabs is deprecated and should not be used in new code. The structure shown below does not meet accessibility standards and lacks proper keyboard navigation and screen reader support.

Previously, we exposed both <Tabs> and <Tab> components and allowed developers to manually structure the tab layout. This approach has been deprecated in favor of the current tabs prop pattern, which ensures proper accessibility and consistent behavior across all implementations.

Props

Tabs

name
type
default
scrollOffset
number | string
hasFullTabs
boolean
children
React.ReactNode
tabs
TabItem[]
isPilledDesign
boolean
hasBottomBorder
boolean

Deprecated - Tab

name
type
default
htmlTag
'a' | 'button' | 'span'
'button'
isDisabled
boolean
false
isActive
boolean
icon
React.ReactNode
children
React.ReactNode
isPilledDesign
boolean