Skip to main content

File Tabs

Paper-style folder tabs over a package of static documents kept together, like tabbed dividers in a binder: a grant application, a plot lease, a year of meeting minutes. Each tab is a standalone document; they share one panel, with optional controls and a busy status at the header's end.

For code files, use Code Block or Demo: they render their headers with File Tabs.

import {
  FileTabs,
  FileTabsControl,
  FileTabsList,
  FileTabsPanel,
} from '@fairgarden/design/navigation/file-tabs'

FileTabs holds the selection and the header's settings (frame, controls, status, mono). FileTabsList renders the header from them: 56 px with its rule, the tabs across its whole width under 12 px of room and standing on the rule, and the status and controls at its end. FileTabsPanel is the one tabpanel, labelled by the selected tab. The tabs are paper: the selected tab takes the panel's own face and opens into it, with no rule between them, and its label turns bold; the others sit recessed behind it on a slightly darker step of the same scale, each standing on the header's rule. The state reads by weight and by the joined edge, not by color alone. The selected tab's radii grow while it's pressed; each label reserves its bold width, so selecting a tab never moves the row. Hover underlines the other labels. Labels take the UI face at the caption size and are never caps; mono sets them in mono for file names, as Code Block and Demo do. It needs no docs engine, so it works anywhere.

The header is one fixed row that never wraps, so nothing that joins it later can move the page. The header opens a host: a bordered box with no padding, a --primary1 face and no clip, such as a code block's frame, or the FileTabs root given a frame class, as in these demos. The host keeps the page's panel radius, --radius-2-25; the tabs alone take the paper-tab radius, --radius-2-75, and their curves leave the host's side line below its corner. The tab strip runs out over the host's side edges by their width, so there's no gap between an end tab and the edge, and the edges are drawn again over the header, so scrolled tabs and the ends of the strip's scrollbar pass under them. frame says which host it is: "top" (the default) for the top of a box with rounded corners, "joined" for a part below another, and "none" for no box at all.

In print the header hugs its labels: plain labels in a wrapping row, the selected one in bold, without the controls or status.

Tabs or File Tabs?

Tabs switch between views or sections of one thing on a page: settings panes, the sections of an article, filtered views of one list. File Tabs hold a package of separate documents kept together, where each tab is a standalone document, drawn as paper tabs. For code files, use Code Block or Demo, which use File Tabs for their headers.

Documents

Documents

With two or more documents the header shows tabs; with one it shows the document's title as a label, and the panel is a plain region. Arrow keys move between tabs and Enter or Space selects, so moving focus never swaps the document.

Plot lease, 2026 season

Plot 14 at Riverbend Community Garden is leased to its gardener from March 1 to November 30. The lease renews each winter while the plot is kept planted and tidy.

Signed at the February open day.

Welcome letter

Welcome to Riverbend! Your key to the tool shed is on the hook inside the gate box, and the next work day is the first Saturday of April.

'use client'

import * as React from 'react'
import { FileTabs, FileTabsList, FileTabsPanel } from '@fairgarden/design/navigation/file-tabs'
import styles from './basic.module.css'

/** A plot lease packet: three documents kept together. */
const documents = [
  {
    id: 'Lease',
    content: (
      <>
        <h3 className={styles.title}>Plot lease, 2026 season</h3>
        <p>
          Plot 14 at Riverbend Community Garden is leased to its gardener from March 1 to November
          30. The lease renews each winter while the plot is kept planted and tidy.
        </p>
        <p className={styles.muted}>Signed at the February open day.</p>
      </>
    ),
  },
  {
    id: 'Plot map',
    content: (
      <>
        <h3 className={styles.title}>Where plot 14 is</h3>
        <p>
          Third row from the gate, between the rain barrels and the pollinator bed. The water tap is
          two plots east; the tool shed is by the north fence.
        </p>
      </>
    ),
  },
  {
    id: 'Garden rules',
    content: (
      <>
        <h3 className={styles.title}>Garden rules</h3>
        <ul className={styles.list}>
          <li>Water in the early morning or the evening.</li>
          <li>Return shared tools to the shed the same day.</li>
          <li>No synthetic pesticides anywhere in the garden.</li>
        </ul>
      </>
    ),
  },
]

/**
 * Three documents of a lease packet switching one panel, and a packet of
 * one, which shows its title instead of tabs. Each sits at the top of a
 * bordered box, the header's host.
 */
export function FileTabsBasic() {
  const [selected, setSelected] = React.useState(documents[0].id)
  const current = documents.find((document) => document.id === selected) ?? documents[0]

  return (
    <div className={styles.stack}>
      <FileTabs
        tabs={documents.map((document) => ({ id: document.id, name: document.id }))}
        value={selected}
        onValueChange={setSelected}
        className={styles.frame}
      >
        <FileTabsList aria-label="Lease packet" />
        <FileTabsPanel>
          <div className={styles.doc}>{current.content}</div>
        </FileTabsPanel>
      </FileTabs>
      <FileTabs tabs={[{ id: 'Welcome letter', name: 'Welcome letter' }]} className={styles.frame}>
        <FileTabsList />
        <FileTabsPanel>
          <div className={styles.doc}>
            <p>
              Welcome to Riverbend! Your key to the tool shed is on the hook inside the gate box, and
              the next work day is the first Saturday of April.
            </p>
          </div>
        </FileTabsPanel>
      </FileTabs>
    </div>
  )
}

A tab with a slug is a link to #slug. A plain click selects the document without writing the hash or jumping the page; a modifier click (Ctrl, Cmd, Alt or Shift, from the keyboard too) opens the link elsewhere and leaves the selection alone. The scroll targets and the hash latch belong to the consumer, as this demo renders them.

'use client'

import * as React from 'react'
import { FileTabs, FileTabsList, FileTabsPanel } from '@fairgarden/design/navigation/file-tabs'
import {
  Table,
  TableBody,
  TableCell,
  TableHead,
  TableHeaderCell,
  TableRow,
} from '@fairgarden/design/data/table'
import styles from './links.module.css'

/** A grant application packet: each document has a deep-link slug. */
const documents = [
  {
    id: 'Cover letter',
    slug: 'grant-packet:cover-letter',
    content: (
      <>
        <h3 className={styles.title}>Cover letter</h3>
        <p>
          Riverbend Community Garden asks the county’s neighbourhood fund for help building a
          rain-fed watering system for its forty plots.
        </p>
      </>
    ),
  },
  {
    id: 'Budget',
    slug: 'grant-packet:budget',
    content: (
      <Table strategy="fit" density="compact">
        <TableHead>
          <TableRow>
            <TableHeaderCell>Item</TableHeaderCell>
            <TableHeaderCell numeric>Cost ($)</TableHeaderCell>
          </TableRow>
        </TableHead>
        <TableBody>
          <TableRow>
            <TableHeaderCell>Rain barrels (6)</TableHeaderCell>
            <TableCell numeric>540</TableCell>
          </TableRow>
          <TableRow>
            <TableHeaderCell>Drip line and fittings</TableHeaderCell>
            <TableCell numeric>310</TableCell>
          </TableRow>
          <TableRow>
            <TableHeaderCell>Volunteer lunches</TableHeaderCell>
            <TableCell numeric>150</TableCell>
          </TableRow>
        </TableBody>
      </Table>
    ),
  },
  {
    id: 'Site plan',
    slug: 'grant-packet:site-plan',
    content: (
      <>
        <h3 className={styles.title}>Site plan</h3>
        <p>Barrels along the shed’s north gutter feed a drip line down each row of plots.</p>
      </>
    ),
  },
  {
    id: 'Letters of support',
    slug: 'grant-packet:letters-of-support',
    content: (
      <>
        <h3 className={styles.title}>Letters of support</h3>
        <ul className={styles.list}>
          <li>Riverbend Elementary’s garden club</li>
          <li>The Hillside Tool Library</li>
        </ul>
      </>
    ),
  },
]

/** The document whose slug is the URL hash, if any. */
function documentFromHash() {
  const hash = decodeURIComponent(window.location.hash.slice(1))
  return documents.find((document) => document.slug === hash)?.id
}

/**
 * Each tab is a deep link to `#slug`. A plain click selects the document; a
 * modifier click (Ctrl, Cmd, Alt or Shift) opens the link elsewhere and
 * leaves the selection. The scroll targets and the hash latch are the
 * consumer's: this demo renders one hidden target per document and selects
 * the document named by the hash on load and on hash changes.
 */
export function FileTabsLinks() {
  const [selected, setSelected] = React.useState(documents[0].id)
  const current = documents.find((document) => document.id === selected) ?? documents[0]

  React.useEffect(() => {
    const latch = () => {
      const id = documentFromHash()
      if (id) setSelected(id)
    }
    latch()
    window.addEventListener('hashchange', latch)
    return () => window.removeEventListener('hashchange', latch)
  }, [])

  return (
    <div className={styles.stack}>
      <div>
        {documents.map((document) => (
          <span key={document.slug} id={document.slug} className={styles.target} />
        ))}
        <FileTabs
          tabs={documents.map((document) => ({ id: document.id, name: document.id, slug: document.slug }))}
          value={selected}
          onValueChange={setSelected}
          className={styles.frame}
        >
          <FileTabsList aria-label="Grant application" />
          <FileTabsPanel>
            <div className={styles.doc}>{current.content}</div>
          </FileTabsPanel>
        </FileTabs>
      </div>
      <p className={styles.copy}>
        Link to the <a href={`#${documents[1].slug}`}>budget</a> or the{' '}
        <a href={`#${documents[3].slug}`}>letters of support</a>.
      </p>
    </div>
  )
}

Agenda with attachments

Agenda with attachments

A cover document and its attachments in one frame: the meeting's agenda, or its minutes, above, and the documents it refers to below in frame="joined" tabs. A link in the cover selects that document's tab through the controlled value and moves focus to the tab, as the tabs pattern does, scrolling it into view; a modifier click still opens the link, and the hash selects the document on load.

Garden committee, March meeting

Tuesday 10 March, 7 pm, in the Riverbend tool shed

  1. Welcome and apologies
  2. Treasurer's report
  3. Plot waitlist: two plots to offer
  4. Tool shed quote
  5. Spring planting plan
  6. Any other business

Treasurer's report

The garden holds $1,240 after the seed sale. Water and insurance are paid through June.

'use client'

import * as React from 'react'
import { Toggle } from '@fairgarden/design/actions/toggle'
import { ToggleGroup } from '@fairgarden/design/actions/toggle-group'
import { FileTabs, FileTabsList, FileTabsPanel } from '@fairgarden/design/navigation/file-tabs'
import styles from './agenda.module.css'

/** The attachments: each has a deep-link slug the cover document links to. */
const attachments = [
  {
    id: "Treasurer's report",
    slug: 'committee-meeting:treasurers-report',
    text: 'The garden holds $1,240 after the seed sale. Water and insurance are paid through June.',
  },
  {
    id: 'Plot waitlist',
    slug: 'committee-meeting:plot-waitlist',
    text: 'Four households wait for a plot; two plots by the gate come free in April.',
  },
  {
    id: 'Tool shed quote',
    slug: 'committee-meeting:tool-shed-quote',
    text: 'A cedar lean-to on the shed, built by the volunteer carpentry crew: $380 in materials.',
  },
  {
    id: 'Spring planting plan',
    slug: 'committee-meeting:spring-planting-plan',
    text: 'Peas and greens in March, the shared pumpkin patch in May, a new pollinator border along the fence.',
  },
]

const slugOf = (id: string) => attachments.find((attachment) => attachment.id === id)?.slug ?? ''

/** The attachment whose slug is the URL hash, if any. */
function attachmentFromHash() {
  const hash = decodeURIComponent(window.location.hash.slice(1))
  return attachments.find((attachment) => attachment.slug === hash)?.id
}

/**
 * A cover document with its attachments: the meeting's agenda (or, switched,
 * its minutes) above, and the documents it refers to in `frame="joined"`
 * file tabs below. A link in the cover selects that attachment's tab and
 * moves focus to it, as the tabs pattern does, scrolling it into view; a
 * modifier click opens the link as usual. The hash selects it on load too.
 * It all runs on FileTabs' controlled `value`, with no extra API.
 */
export function FileTabsAgenda() {
  const [cover, setCover] = React.useState<'agenda' | 'minutes'>('agenda')
  const [selected, setSelected] = React.useState(attachments[0].id)
  const frameRef = React.useRef<HTMLDivElement | null>(null)
  const current = attachments.find((attachment) => attachment.id === selected) ?? attachments[0]

  React.useEffect(() => {
    const latch = () => {
      const id = attachmentFromHash()
      if (id) setSelected(id)
    }
    latch()
    window.addEventListener('hashchange', latch)
    return () => window.removeEventListener('hashchange', latch)
  }, [])

  /** A cover link: a plain activation selects the tab and focuses it; a modifier one keeps the browser's own handling. */
  const open = (id: string) => (event: React.MouseEvent<HTMLAnchorElement>) => {
    if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return
    event.preventDefault()
    setSelected(id)
    const tab = frameRef.current?.querySelector<HTMLElement>(`[role="tab"][href="#${slugOf(id)}"]`)
    tab?.focus({ preventScroll: true })
    tab?.scrollIntoView({ block: 'nearest', inline: 'nearest' })
  }

  const link = (id: string, words?: string) => (
    <a href={`#${slugOf(id)}`} onClick={open(id)}>
      {words ?? id}
    </a>
  )

  return (
    <div className={styles.stack}>
      {attachments.map((attachment) => (
        <span key={attachment.slug} id={attachment.slug} className={styles.target} />
      ))}
      <div ref={frameRef} className={styles.frame}>
        <div className={styles.cover}>
          <ToggleGroup
            variant="segmented"
            aria-label="Cover document"
            value={[cover]}
            onValueChange={(value) => {
              const next = value[value.length - 1]
              if (next === 'agenda' || next === 'minutes') setCover(next)
            }}
          >
            <Toggle value="agenda" size="sm">
              Agenda
            </Toggle>
            <Toggle value="minutes" size="sm">
              Minutes
            </Toggle>
          </ToggleGroup>
          {cover === 'agenda' ? (
            <>
              <h3 className={styles.title}>Garden committee, March meeting</h3>
              <p className={styles.muted}>Tuesday 10 March, 7 pm, in the Riverbend tool shed</p>
              <ol className={styles.list}>
                <li>Welcome and apologies</li>
                <li>{link("Treasurer's report")}</li>
                <li>{link('Plot waitlist')}: two plots to offer</li>
                <li>{link('Tool shed quote')}</li>
                <li>{link('Spring planting plan')}</li>
                <li>Any other business</li>
              </ol>
            </>
          ) : (
            <>
              <h3 className={styles.title}>Garden committee, March minutes</h3>
              <p>
                Seven members attended. The treasurer presented the {link("Treasurer's report", 'report')}{' '}
                and the committee thanked the seed-sale volunteers. Two households from the{' '}
                {link('Plot waitlist', 'waitlist')} will be offered the gate plots. The{' '}
                {link('Tool shed quote', 'lean-to quote')} was accepted, and the{' '}
                {link('Spring planting plan', 'planting plan')} adopted with the pollinator border.
              </p>
            </>
          )}
        </div>
        <FileTabs
          tabs={attachments.map((attachment) => ({ id: attachment.id, name: attachment.id, slug: attachment.slug }))}
          value={selected}
          onValueChange={setSelected}
          frame="joined"
        >
          <FileTabsList aria-label="Attachments" />
          <FileTabsPanel>
            <div className={styles.doc}>
              <h3 className={styles.title}>{current.id}</h3>
              <p>{current.text}</p>
            </div>
          </FileTabsPanel>
        </FileTabs>
      </div>
    </div>
  )
}

Controls

Controls

controls go at the header's end. A FileTabsControl is the one to use for a menu: render it as the Menu's trigger (<Menu.Trigger render={<FileTabsControl />}> from Base UI) with an Icon inside (the ⋮ is more_vert at the tag tier, size="tag") and an aria-label. It always hangs just outside the host's end edge, whatever the number of documents, and takes no room from the tabs: an ear 20 px wide from the frame's line, from its top edge to the foot of the header's rule. Its 44 px hit area reaches out into the gutter, never over the tabs. Pointing at it or focusing it outlines the ear at once, on a soft fill; its tooltip keeps its own delay. At the top of a rounded frame the outline wraps the frame's corner: it runs along the frame's arc and end edge, so ear and corner read as one shape. A document menu holds actions such as print, download and copy link; a copy confirms with a Toast, never in the header. A FileTabsControl can also be a lone action, named by its aria-label and a Tooltip, as a nameless snippet's copy button is in Code Block. With no documents at all there's no header row: the control hangs from the frame's top-end corner. Small icon Buttons, the other kind of control, sit in the header instead, beside a single document's label.

Leave room for it. Nothing measures the space: the host must leave --fgd-size-file-tabs-control (24 px) free past the frame's end, with nothing clipping it sideways, or an overflow-clip-margin that covers it. Where the page ends sooner than the 44 px hit area, clip the page sideways (overflow-x: clip) so the rest of it can't scroll the page. This site's column keeps that gutter at every width, 44 px from the medium breakpoint. Both columns below keep it: the first on the page, the second inside a column that clips, with the gutter inside its clip.

Take up to five seed packets a season; return a packet of saved seed if you can.

Take up to five seed packets a season; return a packet of saved seed if you can.

'use client'

import * as React from 'react'
import { Menu as BaseMenu } from '@base-ui/react/menu'
import { useToastManager } from '@fairgarden/design/feedback/toast'
import { Icon } from '@fairgarden/design/foundations/icon'
import {
  FileTabs,
  FileTabsControl,
  FileTabsList,
  FileTabsPanel,
} from '@fairgarden/design/navigation/file-tabs'
import { Menu, MenuItem, MenuPopup } from '@fairgarden/design/overlays/menu'
import styles from './controls.module.css'

const documents = [
  { id: 'Borrowing rules', text: 'Take up to five seed packets a season; return a packet of saved seed if you can.' },
  { id: 'Catalogue', text: 'Beans, squash, calendula and six heirloom tomatoes, sorted by sowing month.' },
  { id: 'Returns', text: 'Dry saved seed for two weeks, then label it with the plant and the year.' },
]

/** The ⋮ Menu: document actions; copying the link confirms with a toast. */
function MoreActions({ document }: { document: string }) {
  const toasts = useToastManager()
  const copyLink = () => {
    Promise.resolve()
      .then(() => navigator.clipboard.writeText(`${window.location.origin}${window.location.pathname}#controls`))
      .then(
        () => toasts.add({ status: 'success', title: 'Link copied' }),
        () => toasts.add({ status: 'danger', title: "Couldn't copy the link" }),
      )
  }
  return (
    <Menu>
      <BaseMenu.Trigger render={<FileTabsControl />} aria-label="More actions">
        <Icon name="more_vert" size="tag" weight="interactive" />
      </BaseMenu.Trigger>
      <MenuPopup align="end">
        <MenuItem onClick={() => window.print()}>Print {document}</MenuItem>
        <MenuItem icon="download">Download {document} (PDF)</MenuItem>
        <MenuItem icon="link" onClick={copyLink}>
          Copy link
        </MenuItem>
      </MenuPopup>
    </Menu>
  )
}

function SeedLibrary() {
  const [selected, setSelected] = React.useState(documents[0].id)
  const current = documents.find((document) => document.id === selected) ?? documents[0]

  return (
    <FileTabs
      tabs={documents.map((document) => ({ id: document.id, name: document.id }))}
      value={selected}
      onValueChange={setSelected}
      controls={<MoreActions document={selected} />}
      className={styles.frame}
    >
      <FileTabsList aria-label="Seed library" />
      <FileTabsPanel>
        <div className={styles.doc}>
          <p>{current.text}</p>
        </div>
      </FileTabsPanel>
    </FileTabs>
  )
}

/**
 * The same documents and ⋮ Menu in two columns; the trigger always hangs
 * just outside the frame, and the tabs keep the whole header. Each column
 * leaves --fgd-size-file-tabs-control free past the frame: the first on
 * the page, the second, narrow, inside its own sideways clip.
 */
export function FileTabsControls() {
  return (
    <div className={styles.stack}>
      <div className={styles.gutter}>
        <SeedLibrary />
      </div>
      <div className={styles.narrow}>
        <SeedLibrary />
      </div>
    </div>
  )
}

Many documents

Many documents

Any number of documents fits. When the tabs overflow, the row scrolls sideways with the browser's own scrollbar. The header keeps its height whatever the scrollbar takes: a scrollbar that takes room hangs flush under the header's rule, over the panel's top, and one that overlays the page shows over the foot of the tabs. Either way the tabs never lift off the rule. At either end of the scroll the end tab sits flush with the frame's edge.

March meeting minutes

Twelve gardeners attended. The committee reviewed the work-day schedule, the plot waitlist and the treasurer’s report, and set the next meeting for the second Tuesday.

'use client'

import * as React from 'react'
import { Menu as BaseMenu } from '@base-ui/react/menu'
import { Icon } from '@fairgarden/design/foundations/icon'
import {
  FileTabs,
  FileTabsControl,
  FileTabsList,
  FileTabsPanel,
} from '@fairgarden/design/navigation/file-tabs'
import { Menu, MenuItem, MenuPopup } from '@fairgarden/design/overlays/menu'
import styles from './overflow.module.css'

const months = [
  'January',
  'February',
  'March',
  'April',
  'May',
  'June',
  'July',
  'August',
  'September',
  'October',
  'November',
  'December',
]

/**
 * A year of monthly meeting minutes in a narrow frame, with a ⋮ Menu: the
 * row scrolls sideways under the frame's edges with the browser's own
 * scrollbar, flush under the header, and arrow keys bring each tab into
 * view. The trigger hangs outside the frame, so the tabs keep the whole
 * header.
 */
export function FileTabsOverflow() {
  const [selected, setSelected] = React.useState(months[2])

  return (
    <div className={styles.stack}>
      <FileTabs
        tabs={months.map((month) => ({ id: month, name: month }))}
        value={selected}
        onValueChange={setSelected}
        controls={
          <Menu>
            <BaseMenu.Trigger render={<FileTabsControl />} aria-label="More actions">
              <Icon name="more_vert" size="tag" weight="interactive" />
            </BaseMenu.Trigger>
            <MenuPopup align="end">
              <MenuItem icon="download">Download {selected} minutes (PDF)</MenuItem>
              <MenuItem icon="download">Download the whole year (PDF)</MenuItem>
            </MenuPopup>
          </Menu>
        }
        className={`${styles.frame} ${styles.narrow}`}
      >
        <FileTabsList aria-label="Meeting minutes, 2026" />
        <FileTabsPanel>
          <div className={styles.doc}>
            <h3 className={styles.title}>{selected} meeting minutes</h3>
            <p>
              Twelve gardeners attended. The committee reviewed the work-day schedule, the plot
              waitlist and the treasurer’s report, and set the next meeting for the second Tuesday.
            </p>
          </div>
        </FileTabsPanel>
      </FileTabs>
    </div>
  )
}

One document

One document

With one document, the label and the controls share the header: a row of small icon Buttons, each named by a Tooltip. Use text icon-only Buttons: they're quiet at rest, a glyph with no edge, like the ⋮, and pointing at one or focusing it draws its circle at once. They never hang, and the header never wraps: the label truncates with an ellipsis to leave them room. The row is aligned to the end, so a control that joins later goes first in controls and the ones already there stay put. A confirmation, such as a copied link, is a Toast in the page's toast bar, never text in the header or a changed icon.

Volunteer handbook

Sign in at the shed whistle board, wear closed shoes, and ask a crew lead before using the chipper. Work days run 9 to noon; water and gloves are provided.

'use client'

import { Button } from '@fairgarden/design/actions/button'
import { useToastManager } from '@fairgarden/design/feedback/toast'
import type { IconName } from '@fairgarden/design/foundations/icon'
import { FileTabs, FileTabsList, FileTabsPanel } from '@fairgarden/design/navigation/file-tabs'
import {
  Tooltip,
  TooltipPopup,
  TooltipProvider,
  TooltipTrigger,
} from '@fairgarden/design/overlays/tooltip'
import styles from './single.module.css'

const name = 'Volunteer handbook'
const text = `Volunteer handbook

Sign in at the shed whistle board, wear closed shoes, and ask a crew lead before using the chipper. Work days run 9 to noon; water and gloves are provided.`

/** A quiet (`text`) icon-only Button named by its Tooltip; a link when it has an `href`. */
function IconAction(props: {
  icon: IconName
  label: string
  onClick?: () => void
  href?: string
  download?: string
}) {
  const { icon, label, onClick, href, download } = props
  const button = href ? (
    <Button
      variant="text"
      iconOnly
      size="sm"
      icon={icon}
      nativeButton={false}
      render={<a href={href} download={download} />}
    >
      {label}
    </Button>
  ) : (
    <Button variant="text" iconOnly size="sm" icon={icon} onClick={onClick}>
      {label}
    </Button>
  )
  return (
    <Tooltip>
      <TooltipTrigger render={button} />
      <TooltipPopup>{label}</TooltipPopup>
    </Tooltip>
  )
}

/**
 * One document: its title as a label, and a row of quiet icon Buttons
 * beside it, their edge drawn only on hover and focus.
 * Copying the link confirms with a toast in the page's toast bar, not in
 * the header.
 */
export function FileTabsSingle() {
  const toasts = useToastManager()
  const copyLink = () => {
    Promise.resolve()
      .then(() => navigator.clipboard.writeText(`${window.location.origin}${window.location.pathname}#single`))
      .then(
        () => toasts.add({ status: 'success', title: 'Link copied' }),
        () =>
          toasts.add({
            status: 'danger',
            title: "Couldn't copy the link",
            description: "The browser didn't allow access to the clipboard.",
          }),
      )
  }

  return (
    <div className={styles.stack}>
      <FileTabs
        tabs={[{ id: name, name }]}
        controls={
          <TooltipProvider>
            <IconAction icon="link" label="Copy link" onClick={copyLink} />
            <IconAction
              icon="download"
              label={`Download ${name}`}
              href={`data:text/plain,${encodeURIComponent(text)}`}
              download="volunteer-handbook.txt"
            />
          </TooltipProvider>
        }
        className={styles.frame}
      >
        <FileTabsList />
        <FileTabsPanel>
          <div className={styles.doc}>
            <p>
              Sign in at the shed whistle board, wear closed shoes, and ask a crew lead before using
              the chipper. Work days run 9 to noon; water and gloves are provided.
            </p>
          </div>
        </FileTabsPanel>
      </FileTabs>
    </div>
  )
}

Status

Status

status is the busy "-ing…" label while something the header started is under way, such as "Saving…". It's laid over the header's end beside the controls, covering the end of the tabs on the frame's face rather than pushing them, so they never move. It's a live region, mounted whenever status is set: pass '' while idle rather than leaving it out, so the change is announced. Confirmations don't go here: a copied link, say, shows a toast.

Saturday crew

Nine volunteers mulched the orchard path and turned two compost bays.

'use client'

import * as React from 'react'
import { Menu as BaseMenu } from '@base-ui/react/menu'
import { Icon } from '@fairgarden/design/foundations/icon'
import {
  FileTabs,
  FileTabsControl,
  FileTabsList,
  FileTabsPanel,
} from '@fairgarden/design/navigation/file-tabs'
import { Menu, MenuItem, MenuPopup } from '@fairgarden/design/overlays/menu'
import styles from './status.module.css'

const reports = [
  { id: 'Saturday crew', text: 'Nine volunteers mulched the orchard path and turned two compost bays.' },
  { id: 'Sunday crew', text: 'Six volunteers weeded the herb spiral and staked the tomatoes.' },
  { id: 'Tool check', text: 'Two spades need new handles; the wheelbarrow tyre is patched.' },
  { id: 'Water log', text: 'The barrels held through the dry week; the east tap drips.' },
]

/**
 * The busy status beside the ⋮ Menu: "Saving…" while the (pretend) PDF is
 * made. It's laid over the header's end, so the tabs never move, and it's
 * a live region, so its words are announced.
 */
export function FileTabsStatus() {
  const [selected, setSelected] = React.useState(reports[0].id)
  const [status, setStatus] = React.useState('')
  const current = reports.find((report) => report.id === selected) ?? reports[0]

  React.useEffect(() => {
    if (status === '') return undefined
    const timer = window.setTimeout(() => setStatus(''), 1500)
    return () => window.clearTimeout(timer)
  }, [status])

  return (
    <div className={styles.stack}>
      <FileTabs
        tabs={reports.map((report) => ({ id: report.id, name: report.id }))}
        value={selected}
        onValueChange={setSelected}
        status={status}
        controls={
          <Menu>
            <BaseMenu.Trigger render={<FileTabsControl />} aria-label="More actions">
              <Icon name="more_vert" size="tag" weight="interactive" />
            </BaseMenu.Trigger>
            <MenuPopup align="end">
              <MenuItem icon="download" onClick={() => setStatus('Saving…')}>
                Save {selected} as PDF
              </MenuItem>
            </MenuPopup>
          </Menu>
        }
        className={styles.frame}
      >
        <FileTabsList aria-label="Work-day reports" />
        <FileTabsPanel>
          <div className={styles.doc}>
            <h3 className={styles.title}>{current.id}</h3>
            <p>{current.text}</p>
          </div>
        </FileTabsPanel>
      </FileTabs>
    </div>
  )
}

Frames

Frames

frame="joined" puts the header in a part of the host below another, as the Agenda demo's attachments sit under its agenda, and a demo's code under its preview: the header draws the rule that joins them, and the side edges run from it. frame="none" is for tabs with no box around them: the strip stays inside the header, the end tabs show their own edges, and a FileTabsControl hangs past the header's own end.

2026 harvest: 68 kg from fourteen plots, 52 kg to the food bank.

Tomatoes 38 kg, squash 21 kg, beans 9 kg, from fourteen plots.

Tomatoes 38 kg, squash 21 kg, beans 9 kg, from fourteen plots.

'use client'

import * as React from 'react'
import { Menu as BaseMenu } from '@base-ui/react/menu'
import { Icon } from '@fairgarden/design/foundations/icon'
import {
  FileTabs,
  FileTabsControl,
  FileTabsList,
  FileTabsPanel,
  type FileTabsFrame,
} from '@fairgarden/design/navigation/file-tabs'
import { Menu, MenuItem, MenuPopup } from '@fairgarden/design/overlays/menu'
import styles from './frames.module.css'

const sheets = [
  { id: 'Tally sheet', text: 'Tomatoes 38 kg, squash 21 kg, beans 9 kg, from fourteen plots.' },
  { id: 'Food bank receipt', text: 'Received 52 kg of fresh produce for the Thursday pantry.' },
  { id: 'Notes', text: 'Next year, weigh the herbs too, and start the tally a week earlier.' },
]

function HarvestSheets({ frame }: { frame: FileTabsFrame }) {
  const [selected, setSelected] = React.useState(sheets[0].id)
  const current = sheets.find((sheet) => sheet.id === selected) ?? sheets[0]

  return (
    <FileTabs
      tabs={sheets.map((sheet) => ({ id: sheet.id, name: sheet.id }))}
      value={selected}
      onValueChange={setSelected}
      frame={frame}
      controls={
        <Menu>
          <BaseMenu.Trigger render={<FileTabsControl />} aria-label="More actions">
            <Icon name="more_vert" size="tag" weight="interactive" />
          </BaseMenu.Trigger>
          <MenuPopup align="end">
            <MenuItem icon="download">Download {selected} (PDF)</MenuItem>
          </MenuPopup>
        </Menu>
      }
    >
      <FileTabsList aria-label="Harvest records" />
      <FileTabsPanel>
        <div className={styles.doc}>
          <p>{current.text}</p>
        </div>
      </FileTabsPanel>
    </FileTabs>
  )
}

/**
 * The header on its other hosts. `frame="joined"`: in a box below another
 * part (here, the season's summary), joined to it by the header's rule;
 * the Agenda demo below builds on it. `frame="none"`: no box, the tabs over
 * their panel on the page; the ⋮ trigger hangs past the header's own end.
 */
export function FileTabsFrames() {
  return (
    <div className={styles.stack}>
      <div className={styles.frame}>
        <p className={styles.output}>2026 harvest: 68 kg from fourteen plots, 52 kg to the food bank.</p>
        <HarvestSheets frame="joined" />
      </div>
      <HarvestSheets frame="none" />
    </div>
  )
}

Disabled

Disabled

disabled holds every tab while the documents load: muted labels with a dotted underline, never dimmed. The selected tab keeps its face, shape and weight, so its muted label still reads. A disabled FileTabsControl stands in for the menu until it loads, in the same place and size.

Loading…

import { Icon } from '@fairgarden/design/foundations/icon'
import {
  FileTabs,
  FileTabsControl,
  FileTabsList,
  FileTabsPanel,
} from '@fairgarden/design/navigation/file-tabs'
import styles from './disabled.module.css'

const names = ['Planting calendar', 'Seed order', 'Tool inventory']

/**
 * While the documents load, every tab is disabled, and so is the ⋮ trigger
 * that stands in for the menu. The selected tab keeps its shape and weight.
 */
export function FileTabsDisabled() {
  return (
    <div className={styles.stack}>
      <FileTabs
        tabs={names.map((name) => ({ id: name, name }))}
        defaultValue={names[1]}
        disabled
        controls={
          <FileTabsControl aria-label="More actions" disabled>
            <Icon name="more_vert" size="tag" weight="interactive" />
          </FileTabsControl>
        }
        className={styles.frame}
      >
        <FileTabsList aria-label="Spring packet" />
        <FileTabsPanel>
          <div className={styles.doc}>
            <p className={styles.status}>Loading…</p>
          </div>
        </FileTabsPanel>
      </FileTabs>
    </div>
  )
}

Mono labels

mono sets the labels, and a single document's label, in mono (type-data) for file names, e.g. code. Code Block and Demo set it; the geometry is the same in either face.

API Reference

FileTabs

The root of a set of file tabs: it holds the selection and the header’s frame, controls, status and mono, and wraps both the header (FileTabsList) and FileTabsPanel. Tabs with a slug are deep links: a plain click selects the document, a modifier click opens the link and leaves the selection.

PropTypeDescription
defaultValue
string | undefined

Uncontrolled initial id. Default: the first tab.

value
string | undefined

Controlled: the selected tab’s id. undefined, or an id not in tabs, selects the first tab.

onValueChange
((id: string) => void) | undefined

Called on user selection only. Not called for a modifier activation, which eventDetails.cancel()s. The modifiers are read from eventDetails.event (Base UI 1.8), so this covers the keyboard as well as the pointer.

controls
React.ReactNode | undefined

Controls at the header’s end: a FileTabsControl (a Menu’s ⋮ trigger) or a few small icon Buttons.

  • A FileTabsControl always hangs just outside the host’s inline-end edge (past the header’s own end with frame="none") with zero layout width, whatever the tab count, so the tabs keep the whole header. Its hit area, --fgd-size-hit, extends outward into the gutter, never over the tabs. The host must leave --fgd-size-file-tabs-control (24 px) free past its edge, unclipped (or inside an overflow-clip-margin); where the page ends sooner, clip it sideways (overflow-x: clip) so the rest of the hit area can’t scroll it. With no document (tabs empty) there is no header row at all: the ⋮ hangs from the host’s top-end corner.
  • Small icon Buttons (variant="text" icon-only sm Buttons) sit in the header, quiet at rest: their edge is drawn only while pointed at or focused. They sit beside the one document’s label, which truncates to leave them room (the header never wraps); with several documents, in a --fgd-size-hit cell at the header’s end with a --role-rule start edge, where the tabs end. The row is end-aligned: a control that joins after the first paint goes before the others (earlier in controls), so the ones already painted don’t move. Hidden in print.
frame
FileTabsFrame | undefined

Where the header sits. Its host is the bordered box it opens: a --border-size-1 edge, no padding, a --primary1 face and no clip, such as Code Block’s frame, or the Root itself given a frame class. 'top': at the top of the host, whose top corners take --radius-2-25 (a host with another radius sets --file-tabs-host-radius on the Root). The tab strip runs out over the host’s side edges by their width, so an end tab’s edge is the host’s edge, its paper-tab corner leaving that line below the host’s corner; the side edges are drawn again over the header from below the host’s corner radius, so scrolled tabs and the ends of the strip’s native scrollbar pass under them; a FileTabsControl hangs outside. 'joined': the same, in a part of the host below another (Demo’s code); the header draws the --role-rule that joins the part above, and the side edges run from it. 'none': no host frame (tabs over their panel on the page); the strip stays inside the header, the end tabs show their own edges, and a FileTabsControl hangs past the header’s own end. Default 'top'.

mono
boolean | undefined

Labels in mono (type-data, §3.11) instead of the UI face: for file names, e.g. code. Mono labels are left to right (dir="ltr") on any page, since file names are, while the tabs and header still mirror in RTL. Code Block and Demo set it. Default false.

primary
| 'ruby'
| 'olive'
| 'sage'
| 'slate'
| 'sand'
| 'gray'
| 'mauve'
| 'brown'
| 'bronze'
| 'gold'
| 'red'
| 'crimson'
| 'tomato'
| 'pink'
| 'plum'
| 'indigo'
| 'iris'
| 'violet'
| 'purple'
| undefined

Primary scale: labels, rules, the tabs’ faces (the recessed --primary3, the front --primary1), focus ring. Never defaulted [D133].

secondary
| 'ruby'
| 'olive'
| 'sage'
| 'slate'
| 'sand'
| 'gray'
| 'mauve'
| 'brown'
| 'bronze'
| 'gold'
| 'red'
| 'crimson'
| 'tomato'
| 'pink'
| 'plum'
| 'indigo'
| 'iris'
| 'violet'
| 'purple'
| 'amber'
| 'blue'
| 'cyan'
| 'grass'
| 'green'
| 'jade'
| 'lime'
| 'mint'
| 'orange'
| 'sky'
| 'teal'
| 'yellow'
| undefined

Secondary scale: the hover underline (--role-accent). Never defaulted.

status
React.ReactNode | undefined

The busy “-ing…” label while something the header started is under way (“Switching to JS…", “Formatting…") [D84], laid over the header’s end beside the controls: mono, --role-muted, on the --primary1 face with a --role-rule start edge, so it never moves or narrows the tabs. Its element is a role="status" live region, rendered whenever status isn’t undefined: pass '' while idle, so it stays mounted and its changes are announced. Not for confirmations such as a copy: those are toasts (§10.17). Hidden in print.

tabs
FileTab[] | undefined
disabled
boolean | undefined

Disables every tab: --role-muted label plus a line-dotted-fine underline, no opacity. Default false.

FileTabsList

The header: one fixed 56 px row with its --role-rule, the folder tabs across its full width under 12 px of room, standing on the rule, and the Root’s status and controls at its end. The labels take the UI face (mono with mono); the selected tab takes its panel’s face and opens into it, the others recessed behind it with its neighbours tucked under it. When they overflow, their row scrolls sideways with its native scrollbar, which hangs just below the header (or overlays the strip’s foot, where scrollbars overlay), so the tabs never lift off the rule. With one tab it shows that name as a label (no tablist), truncated with an ellipsis where the controls need its room; with none, the controls and status (a FileTabsControl alone hangs, with no header row), or nothing. Its own props (aria-label, className …) go to the tablist, or to the one document’s label.

PropTypeDescription
aria-label
string | undefined

The tablist’s accessible name. Default "Documents" (Code Block passes "Files").

FileTabsControl

One header control for the Root’s controls: a <button> holding an icon (an Icon with weight="interactive" takes its hover weight here; the ⋮ is more_vert at the tag tier, size="tag", 20 px). It always hangs outside the host’s inline-end edge: an ear --size-px-4 wide from the host’s edge line, from the host’s top edge to the header rule’s foot, with its --fgd-size-hit hit area past that edge and none over the tabs; the host leaves --fgd-size-file-tabs-control free there. Hovered or focused, the ear shows at once, drawn in --primary12 on the --role-soft-hover fill (at the top of a rounded host, wrapping the host’s top-end corner, so the outline runs unbroken round both); while its popup is open (aria-expanded="true"; a tooltip’s data-popup-open changes nothing), on the --primary1 face. As a Menu’s trigger: <Menu.Trigger render={<FileTabsControl />} aria-label="More actions">. Or as a lone action, where it is the only one (Code Block’s nameless snippet hangs its copy, content_copy at the tag tier): name it with aria-label, pair it with a Tooltip, and give it an onClick.

PropTypeDescription
className
string | undefined

FileTabsPanel

The panel for the selected tab: role="tabpanel", labelled by the selected tab, which aria-controls it. Its element stays the same across selections, so the content inside is never remounted; empty hidden panels stand in for the other tabs, so every tab’s aria-controls resolves. With fewer than two tabs it renders a plain div (there is no tablist to pair with).

Additional types

FileTab

One tab: a document in the package.

type FileTab = {
  /** The tab's value, unique within `tabs`. A code block passes the file name. */
  id: string;
  /** The label: the document's short title (a file name in a code block). UI face at the caption size, not caps; mono with `mono`. */
  name: string;
  /**
   * Deep-link slug. The tab renders as `<a href="#slug">` (`nativeButton={false}`).
   * A plain click selects the tab and `preventDefault()`s the anchor, so the page
   * doesn't jump and the hash isn't written. A modifier click (Ctrl, Cmd, Alt or
   * Shift) opens the link and leaves the selection alone.
   */
  slug?: string;
}
fileTabs
FileTabsControlProps

Props for FileTabsControl: button props plus render. Name it with aria-label.

type FileTabsControlProps = { className?: string }
FileTabsFrame

Where the header sits on its host: see FileTabsProps['frame'].

type FileTabsFrame = 'top' | 'joined' | 'none'
FileTabsListProps

Props for FileTabsList: Base UI Tabs List props; the tabs, controls and status come from the Root.

type FileTabsListProps = {
  /** The tablist's accessible name. Default `"Documents"` (Code Block passes `"Files"`). */
  'aria-label'?: string;
}
FileTabsPanelProps

Props for FileTabsPanel: Base UI Tabs Panel props; its value is the selected tab’s.

type FileTabsPanelProps = Omit<TabsPanel.TabsPanelProps, 'value'>
FileTabsProps

Props for FileTabs: Base UI Tabs Root props (without its value props and orientation) plus the documents, the header’s frame, controls, status and label face, and the color axes.

type FileTabsProps = {
  tabs: FileTab[];
  /** Controlled: the selected tab's `id`. `undefined`, or an id not in `tabs`, selects the first tab. */
  value?: string;
  /** Uncontrolled initial `id`. Default: the first tab. */
  defaultValue?: string;
  /**
   * Called on user selection only. Not called for a modifier activation, which
   * `eventDetails.cancel()`s. The modifiers are read from `eventDetails.event`
   * (Base UI 1.8), so this covers the keyboard as well as the pointer.
   */
  onValueChange?: (id: string) => void;
  /** Disables every tab: `--role-muted` label plus a `line-dotted-fine` underline, no opacity. Default `false`. */
  disabled?: boolean;
  /**
   * Labels in mono (`type-data`, §3.11) instead of the UI face: for file
   * names, e.g. code. Mono labels are left to right (`dir="ltr"`) on any
   * page, since file names are, while the tabs and header still mirror in
   * RTL. Code Block and Demo set it. Default `false`.
   */
  mono?: boolean;
  /**
   * Where the header sits. Its host is the bordered box it opens: a
   * `--border-size-1` edge, no padding, a `--primary1` face and no clip,
   * such as Code Block's frame, or the Root itself given a frame class.
   * `'top'`: at the top of the host, whose top corners take
   * `--radius-2-25` (a host with another radius sets `--file-tabs-host-radius`
   * on the Root). The tab strip runs out over the host's side edges by
   * their width, so an end tab's edge is the host's edge, its paper-tab
   * corner leaving that line below the host's corner; the side edges are
   * drawn again over the header from below the host's corner radius, so
   * scrolled tabs and the ends of the strip's native scrollbar pass under
   * them; a `FileTabsControl` hangs outside.
   * `'joined'`: the same, in a part of the host below another (Demo's
   * code); the header draws the `--role-rule` that joins the part above,
   * and the side edges run from it. `'none'`: no host frame (tabs over
   * their panel on the page); the strip stays inside the header, the end
   * tabs show their own edges, and a `FileTabsControl` hangs past the
   * header's own end. Default `'top'`.
   */
  frame?: FileTabsFrame;
  /**
   * Controls at the header's end: a `FileTabsControl` (a Menu's ⋮ trigger)
   * or a few small icon Buttons.
   * - A `FileTabsControl` always hangs just outside the host's inline-end
   *   edge (past the header's own end with `frame="none"`) with zero layout
   *   width, whatever the tab count, so the tabs keep the whole header. Its
   *   hit area, `--fgd-size-hit`, extends outward into the gutter, never
   *   over the tabs. **The host must leave `--fgd-size-file-tabs-control`
   *   (24 px) free past its edge, unclipped** (or inside an
   *   `overflow-clip-margin`); where the page ends sooner, clip it sideways
   *   (`overflow-x: clip`) so the rest of the hit area can't scroll it.
   *   With no document (`tabs` empty) there is no header row at all: the ⋮
   *   hangs from the host's top-end corner.
   * - Small icon Buttons (`variant="text"` icon-only `sm` Buttons) sit in
   *   the header, quiet at rest: their edge is drawn only while pointed at
   *   or focused. They sit beside the one document's label, which truncates
   *   to leave them room (the header never wraps); with several documents,
   *   in a `--fgd-size-hit` cell at the header's end with a `--role-rule`
   *   start edge, where the tabs end. The row is end-aligned: a control
   *   that joins after the first paint goes before the others (earlier in
   *   `controls`), so the ones already painted don't move.
   * Hidden in print.
   */
  controls?: React.ReactNode;
  /**
   * The busy "-ing…" label while something the header started is under way
   * ("Switching to JS…", "Formatting…") [D84], laid over the header's end
   * beside the controls: mono, `--role-muted`, on the `--primary1` face with
   * a `--role-rule` start edge, so it never moves or narrows the tabs. Its
   * element is a `role="status"` live region, rendered whenever `status`
   * isn't `undefined`: pass `''` while idle, so it stays mounted and its
   * changes are announced. Not for confirmations such as a copy: those are
   * toasts (§10.17). Hidden in print.
   */
  status?: React.ReactNode;
  /** Primary scale: labels, rules, the tabs' faces (the recessed --primary3, the front --primary1), focus ring. Never defaulted [D133]. */
  primary?:
    | 'ruby'
    | 'olive'
    | 'sage'
    | 'slate'
    | 'sand'
    | 'gray'
    | 'mauve'
    | 'brown'
    | 'bronze'
    | 'gold'
    | 'red'
    | 'crimson'
    | 'tomato'
    | 'pink'
    | 'plum'
    | 'indigo'
    | 'iris'
    | 'violet'
    | 'purple';
  /** Secondary scale: the hover underline (`--role-accent`). Never defaulted. */
  secondary?:
    | 'ruby'
    | 'olive'
    | 'sage'
    | 'slate'
    | 'sand'
    | 'gray'
    | 'mauve'
    | 'brown'
    | 'bronze'
    | 'gold'
    | 'red'
    | 'crimson'
    | 'tomato'
    | 'pink'
    | 'plum'
    | 'indigo'
    | 'iris'
    | 'violet'
    | 'purple'
    | 'amber'
    | 'blue'
    | 'cyan'
    | 'grass'
    | 'green'
    | 'jade'
    | 'lime'
    | 'mint'
    | 'orange'
    | 'sky'
    | 'teal'
    | 'yellow';
}

Specification: DESIGN-SYSTEM.md §9.13 (file tabs), §9.5 (tabs) and §3.11 (mono for file names).