Tabs

Underline tabs from the opportunity and contact workspaces: 12 px labels with a 14 px icon, and an orange underline that slides to the selected tab. Built on ui-sdk's Tabs: arrow keys move between tabs and select them, Home and End jump to the ends.

BetaReady to use. Its API can still change in a minor release; the changelog says when.

import { UnderlineTabs, Tabs, TabsList, TabsTab, TabsPanels, TabsPanel } from "@leap-crm/design-system";

Playground

Change a prop and the component follows. Its code is under Props.

Props

children
count
icon
disabled

Best practices

When to use it, and the rules that apply in particular places.

GuidancePractice
DoUse UnderlineTabs for workspace sections driven by value, like an opportunity's Overview, Tasks and Notes. Compose Tabs, TabsList, TabsTab and TabsPanel when each tab owns its content.
DoPut the panels in TabsPanels, so switching slides the new panel in and the height eases instead of jumping the content below.
DoName the list with aria-label, like "Opportunity sections".
DoLeave count out while it's unknown. A count that shows 0 while loading tells a lawyer there are no open tasks.
Don'tUse tabs to switch between views of the same data, like a list and a board. Use ViewSwitch, or SegmentedControl for a choice in a form or filter.

Props

Tabs takes ui-sdk's Tabs options: value, defaultValue, onValueChange, orientation, activation (automatic or manual), loop and controller. TabsTab takes value, disabled and render.

UnderlineTabs

PropTypeDefaultDescription
tabs *unknown—The tabs, in order: value, label, and an optional count, icon or link.
value *TValue—The selected tab's value.
onValueChange(value: TValue) => void—Runs with the tab's value when another is selected.
aria-labelstring—Names the tab list for screen readers, like "Opportunity sections".
classNamestring—Classes added to the root element, merged with its own. Tokens only.
tabClassNamestring—Classes for every tab.

TabsList

PropTypeDefaultDescription
childrenReactNode—What it shows inside.
classNamestring—Classes added to the root element, merged with its own. Tokens only.

TabsTab

PropTypeDefaultDescription
childrenReactNode—What it shows inside.
iconReactNode—A 14 px icon before the label. It takes the tab's colour.
countnumber—A small count after the label, like the number of open tasks. Leave it out while it's unknown.
classNamestring—Classes added to the root element, merged with its own. Tokens only.

TabsPanels

PropTypeDefaultDescription
childrenReactNode—The TabsPanels, one per tab.
classNamestring—Classes added to the root element, merged with its own. Tokens only.

TabsPanel

PropTypeDefaultDescription
childrenReactNode—What it shows inside.
classNamestring—Classes added to the root element, merged with its own. Tokens only.

Code

What the playground shows, ready to copy.

import { Tabs, TabsList, TabsTab } from "@leap-crm/design-system";

<Tabs defaultValue="tasks">
  <TabsList aria-label="Sections">
    <TabsTab value="overview">Overview</TabsTab>
    <TabsTab value="tasks" count={3}>Tasks</TabsTab>
    <TabsTab value="notes">Notes</TabsTab>
  </TabsList>
</Tabs>

Workspace tabs

UnderlineTabs takes the CRM's tab list as it is: value, label, icon, count. Click or use the arrow keys; the underline slides along.

With panels

Compose Tabs, TabsList, TabsTab and TabsPanel when each tab owns content, with the panels in TabsPanels so switching turns the page: the new panel slides in toward the tab you picked while the old one crossfades out, and the height eases between panels of different lengths. Reduced motion only crossfades. Tab from the list moves into the selected panel.

Send the costs agreement, due today.Call about the title search, due Wednesday.Book the settlement date, due Friday.

States

Selected (orange underline, #ad6430 label at 450), unselected, hover (darker label) and disabled. Tab to see focus wrap the whole tab, underline included.

What the examples share

The imports and the scaffolding the examples above call. The scaffolding lives in this page, not in the library.

import { Eye, FileText, Link, ListTree, Phone, SquareCheckBig, StickyNote } from "lucide-react";

import { useState } from "react";

import { Tabs, TabsList, TabsPanel, TabsPanels, TabsTab, UnderlineTabs, type TabItem } from "@leap-crm/design-system";

const workspace = [
  { value: "overview", label: "Overview", icon: Eye },
  { value: "tasks", label: "Tasks", icon: SquareCheckBig, count: 3 },
  { value: "notes", label: "Notes", icon: StickyNote },
  { value: "documents", label: "Documents", icon: FileText, count: 12 },
  { value: "relationships", label: "Relationships", icon: Link },
  { value: "interactions", label: "Interactions", icon: Phone },
  { value: "extra-fields", label: "Extra Fields", icon: ListTree },
] as const satisfies readonly TabItem[];

type Section = (typeof workspace)[number]["value"];

function WorkspaceTabs() {
  const [value, setValue] = useState<Section>("overview");
  return (
    <UnderlineTabs
      aria-label="Opportunity sections"
      tabs={workspace}
      value={value}
      onValueChange={setValue}
    />
  );
}

Keyboard

The keys it answers to. Tab moves between components, arrows move within them.

KeysWhat they do
TabMoves focus to the selected tab, then from the tab list into its panel.
ArrowRightArrowLeftMove focus and select the tab.
HomeEndMove to the first and last tabs.
Shift + TabFrom the panel, returns to the selected tab.