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.
Installation
pnpm dlx shadcn@latest add @sui/tab-barInstall 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.
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.
Search
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.
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.
Custom content
render replaces the field with your own content. It receives close, which plays the closing animation.
Sizes
size is "sm", "default" or "lg"; the search button follows it.
Labels only and disabled
Icons are optional. A disabled item cannot be selected, held or focused with the arrow keys.
RTL
Horizontal bars follow the document direction: arrow keys, the press-and-slide lens and the search reveal all mirror.
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
| Prop | Type | Default / behavior |
|---|---|---|
items | readonly TabBarItem[] | Destinations: value, label, optional icon and disabled. |
value | string | Controlled current destination. |
onValueChange | (value: string) => void | Called when selecting an enabled destination. |
onItemActivate | (value: string) => void | Called on every activation, including the current item. |
search | TabBarSearch | Optional trailing search button; see below. |
glass, frosted | boolean | GlassConfig, boolean | false; material for the bar and search button. |
size | "sm" | "default" | "lg" | "default". |
feedback | FeedbackOption | Follows FeedbackProvider; haptics on selection and long press. |
| Other props | Native nav props | Includes aria-label, dir, className, style and ref. |
TabBarSearch
| Field | Type | Default / behavior |
|---|---|---|
mode | "expand" | "button" | "expand". |
label | string | "Search"; accessible name and placeholder fallback. |
icon | ReactNode | A search icon. |
onActivate | () => void | Called when the button is pressed or the field opens. |
open, defaultOpen, onOpenChange | boolean, boolean, (open: boolean) => void | Whether the field is shown. |
value, defaultValue, onValueChange | string, string, (value: string) => void | The query. |
onSubmit | (value: string) => void | Called on Enter. |
placeholder | string | Defaults to label. |
closeLabel | string | "Close search"; the close button's accessible name. |
render | ({ open, close }) => ReactNode | Replaces the field. |