Tinyrack

Tabs

Keyboard-navigable views with three densities, two orientations, and manual or automatic activation.

Contract

AxisValuesDefault
uiSizemd, lgmd
orientationhorizontal, verticalhorizontal
disabled tabTRTabs.Tab disabledfalse
activationmanual or activateOnFocusmanual
focuslooping or boundedlooping
statecontrolled value, including null, or uncontrolled defaultValuefirst enabled tab

Install

pnpm add @tinyrack/ui

Scroll inside the code area to read long lines.

Styles

@import '@tinyrack/ui/components/tabs.css';

Scroll inside the code area to read long lines.

Imports

import { TRTabs } from '@tinyrack/ui/components/tabs';

Scroll inside the code area to read long lines.

Playground

Usage

Controlled manual activation permalink

Arrow keys move focus. Enter or Space selects the focused tab and updates the result.

Examples

Overflow with an indicator permalink

The narrow tab strip scrolls horizontally while the optional indicator follows the active tab.

Anatomy

  • Root owns controlled or uncontrolled selection, orientation, and uiSize.
  • List is the labelled tablist and configures activation and focus looping.
  • Tab identifies a view by value; disabled tabs remain focusable but cannot activate.
  • Indicator is optional and follows the active tab, including in an overflow strip.
  • Panel connects accessible content to the tab with the same value.

API

PartKey propsNotes
Rootvalue, defaultValue, onValueChange, orientation, uiSizeUse value={null} for no active tab. Without a value prop, the first enabled tab is selected.
ListactivateOnFocus, loopFocusManual activation and looping focus are the defaults.
Tabvalue, disabled, renderArrow keys move focus; Enter or Space activates in manual mode.
IndicatorrenderBeforeHydration, renderOptional visual marker driven by Base UI geometry variables.
Panelvalue, keepMounted, hiddenUntilFound, renderMatches a tab value and preserves ARIA relationships.

Base UI supplies roles, focus movement, selection, and hydration-safe state. Import tabs.css after your Tinyrack foundation styles. Customize with --tr-tabs-indicator-background, --tr-tabs-indicator-size, --tr-tabs-radius, --tr-tabs-tab-height, and --tr-tabs-panel-padding.