GitHub

Tab Bar

Controlled application navigation with press-and-slide selection, an iOS-style search button and optional glass material.

TabBar presents the primary destinations of an application, as on iOS. It controls nothing but the selection: routing and content stay with the application.

Loading example…

Installation

pnpm dlx shadcn@latest add @sui/tab-bar

Install with the shadcn CLI or use the shared @workspace/ui package. Follow the installation guide to configure the registry, load styles, and choose import aliases.

Usage

import { TabBar } from "@workspace/ui/components/tab-bar";
import { HomeIcon, SettingsIcon } from "lucide-react";
import { useState } from "react";

export function ApplicationNavigation() {
  const [value, setValue] = useState("home");
  return (
    <TabBar
      aria-label="Application navigation"
      value={value}
      onValueChange={setValue}
      items={[
        { value: "home", label: "Home", icon: <HomeIcon /> },
        { value: "settings", label: "Settings", icon: <SettingsIcon /> },
      ]}
      search={{ onSubmit: (query) => console.log(query) }}
    />
  );
}

value names the current destination and onValueChange asks the application to select another, so it can update a router or show its own view. Item values must be unique. TabBar renders a navigation landmark of buttons and marks the current one with aria-current; it does not render panels. Use Tabs to switch panels within a page.

In an app

A phone-sized screen: the bar switches the page content, and the search field filters every entry as you type. Search is controlled here, so the page shows results while it is open.

Loading example…

Material

The default bar uses the theme's muted surface. glass (optionally with settings, glass={{ … }}) or frosted applies Glass to the bar and its search button. Both keep a neutral selection pill, as on iOS, with the icon and label in the contrast-adjusted theme foreground. Keep the surrounding container plain to avoid nesting glass.

Loading example…

search adds a separate round button on the trailing side, as in iOS 26 and later. Pressing it hides the bar and reveals a field, as wide as the bar and button were, growing from the button toward the leading side. The close button or Escape folds the field back into the button before the bar returns; Enter calls onSubmit.

Loading example…

The field is uncontrolled by default (defaultOpen, defaultValue); pass open/onOpenChange or value/onValueChange to control it. placeholder, label, closeLabel and icon customize it. Closing from the field returns focus to the search button, and an open field keeps the bar's width as the viewport changes.

Button only

With mode: "button" the button never expands: handle onActivate yourself, for example to open a search sheet, a route or, as here, any other trailing action.

Loading example…

Custom content

render replaces the field with your own content. It receives close, which plays the closing animation.

Loading example…

Sizes

size is "sm", "default" or "lg"; the search button follows it.

Loading example…

Labels only and disabled

Icons are optional. A disabled item cannot be selected, held or focused with the arrow keys.

Loading example…

RTL

Horizontal bars follow the document direction: arrow keys, the press-and-slide lens and the search reveal all mirror.

Loading example…

Keyboard

Left and Right arrows move among enabled destinations; Home and End focus the first and last. Moving focus does not change the destination; Enter or Space activates the focused one. Only the current destination is in the Tab sequence. The bar scrolls when destinations exceed its space.

Press and slide

Hold an item for 250ms, or drag beyond 6px, to lift the selection into a floating lens that enlarges the icon and label. Slide to move the lens over other items; releasing selects the item under it. Past either end the lens follows with growing resistance and keeps the end item. Releasing well away from the bar, cancelling the pointer or losing window focus restores the original selection. In glass mode the lens is clear, with edge highlights and a floating shadow but no blur or refraction, and the bar's glass stays still underneath.

Motion

GSAP moves the selection pill and lens using the buttons' measured bounds. The search field takes its final width at once and a rounded clip reveals it, so glass measures it a single time rather than following a resize; closing plays the clip in reverse, then fades the bar in. Reduced-motion preferences turn off all of these animations.

API reference

PropTypeDefault / behavior
itemsreadonly TabBarItem[]Destinations: value, label, optional icon and disabled.
valuestringControlled current destination.
onValueChange(value: string) => voidCalled when selecting an enabled destination.
onItemActivate(value: string) => voidCalled on every activation, including the current item.
searchTabBarSearchOptional trailing search button; see below.
glass, frostedboolean | GlassConfig, booleanfalse; material for the bar and search button.
size"sm" | "default" | "lg""default".
feedbackFeedbackOptionFollows FeedbackProvider; haptics on selection and long press.
Other propsNative nav propsIncludes aria-label, dir, className, style and ref.
FieldTypeDefault / behavior
mode"expand" | "button""expand".
labelstring"Search"; accessible name and placeholder fallback.
iconReactNodeA search icon.
onActivate() => voidCalled when the button is pressed or the field opens.
open, defaultOpen, onOpenChangeboolean, boolean, (open: boolean) => voidWhether the field is shown.
value, defaultValue, onValueChangestring, string, (value: string) => voidThe query.
onSubmit(value: string) => voidCalled on Enter.
placeholderstringDefaults to label.
closeLabelstring"Close search"; the close button's accessible name.
render({ open, close }) => ReactNodeReplaces the field.