Motion UIComponentsComponent

Smooth tabs

Tabs whose active pill slides between labels while panels crossfade with a directional blur.

npx shadcn@latest add @motion/smooth-tabs

API reference

Components

<SmoothTabs />

Tabs root with a sliding indicator and directional panel crossfade.

defaultValue?

string = ""

The uncontrolled initial selected tab value.

value?

string

The selected tab value (controlled).

onValueChange?

(value: string) => void

Called when the selection changes.

contentOffsetX?

number = 50

Horizontal distance (px) the panel slides during the crossfade. Default 50.

className?

string

Merged onto the root wrapper.

children?

ReactNode

SmoothTabsList and SmoothTabsPanels.

<SmoothTabsList />

The tablist rail with roving-tabindex keyboard navigation.

ariaLabel?

string

Accessible name for the role="tablist".

className?

string

Merged onto the tablist shell.

children?

ReactNode

The SmoothTabsTab children.

<SmoothTabsTab />

One tab with a shared sliding pill when selected.

value

string

This tab's value. Must match a SmoothTabsPanel.

children?

ReactNode

The tab's label.

className?

string

Merged onto the tab <button>.

<SmoothTabsPanels />

Crossfade viewport for the active panel.

children?

ReactNode

The SmoothTabsPanel children.

className?

string

Merged onto the crossfade viewport.

<SmoothTabsPanel />

Declarative panel config read by SmoothTabsPanels. Renders nothing itself.

value

string

This panel's value. Must match a SmoothTabsTab.

children?

ReactNode

The panel's content.

className?

string

Merged onto the animated role="tabpanel" wrapper.

Hooks

useSmoothTabsContext

Read the active tab value and a selector from outside the parts.

useSmoothTabsContext(): {
  /** The currently selected tab's value. */
  value: string
  /** Select a tab by value. */
  select: (value: string) => void
}

Related examples