Tab bar
The iOS 26 tab bar: a 62 pt Liquid Glass platter inset 21 pt with 54 pt items, the current one on a tinted lens, and a separate search circle; minimises on scroll.
Four tabs and search
Minimize on scroll
"use client"
import {
Home01Icon,
Mail01Icon,
Search01Icon,
UserIcon,
} from "@hugeicons/core-free-icons"
import { useState } from "react"
import { Switch } from "@applecn/ui/components/switch"
import {
TabBar,
TabBarItem,
TabBarSearch,
} from "@applecn/ui/components/tab-bar"
import { Text } from "@applecn/ui/components/text"
export default function TabBarBasic() {
const [value, setValue] = useState("home")
const [minimized, setMinimized] = useState(false)
return (
<div className="relative h-72 overflow-hidden rounded-4xl bg-[linear-gradient(160deg,var(--system-mint),var(--system-indigo))] p-4">
<div className="flex items-center gap-2 text-white">
<Switch
aria-label="Minimized"
checked={minimized}
onCheckedChange={setMinimized}
color="tint"
/>
<Text color="inherit">Minimize on scroll</Text>
</div>
<TabBar
aria-label="Main"
value={value}
onValueChange={setValue}
minimized={minimized}
className="absolute"
>
<TabBarItem value="home" icon={Home01Icon} label="Home" />
<TabBarItem value="inbox" icon={Mail01Icon} label="Inbox" badge={3} />
<TabBarItem value="you" icon={UserIcon} label="You" />
<TabBarSearch icon={Search01Icon} />
</TabBar>
</div>
)
}Install
From the registry this site publishes, with dependencies resolved by the CLI.
npx shadcn@latest add https://applecn.vercel.app/r/tab-bar.jsonSource
packages/ui/src/components/tab-bar.tsx
"use client"
import type { IconSvgElement } from "@hugeicons/react"
import { cn } from "cn"
import {
createContext,
useContext,
useMemo,
type ComponentProps,
type ReactNode,
} from "react"
import { Badge } from "./badge"
import { Icon } from "./icon"
/**
* The iOS 26 tab bar (HIG › Tab bars): a 62 pt Liquid Glass platter floating 21 pt from the
* edges, with 54 pt items inset 4 — a 24 pt symbol over a 10 pt label — the current item on a
* tinted lens, a separate 62 pt circular search button at the trailing end, and a `minimized`
* state that keeps only the current tab. All from the platform tokens.
*/
interface TabBarContextValue {
value?: string
onValueChange?: (value: string) => void
minimized: boolean
}
const TabBarContext = createContext<TabBarContextValue>({ minimized: false })
type TabBarProps = Omit<ComponentProps<"nav">, "onChange"> & {
value?: string
onValueChange?: (value: string) => void
minimized?: boolean
}
function TabBar({
className,
value,
onValueChange,
minimized = false,
children,
...props
}: TabBarProps) {
const items: ReactNode[] = []
const extras: ReactNode[] = []
for (const child of Array.isArray(children) ? children : [children]) {
if (
child &&
typeof child === "object" &&
"type" in child &&
child.type === TabBarSearch
)
extras.push(child)
else if (child) items.push(child)
}
const context = useMemo(
() => ({ value, onValueChange, minimized }),
[value, onValueChange, minimized]
)
return (
<TabBarContext.Provider value={context}>
<nav
data-slot="tab-bar"
data-minimized={minimized || undefined}
className={cn(
"fixed inset-x-(--tab-bar-inset) bottom-[max(var(--tab-bar-inset),env(safe-area-inset-bottom))] z-40 flex items-center justify-center gap-2",
minimized && "justify-end",
className
)}
{...props}
>
<div
data-slot="tab-bar-capsule"
className={cn(
"flex h-(--tab-bar-height) items-stretch rounded-full glass p-(--tab-bar-item-inset) transition-[width,padding] duration-(--duration-nav) ease-(--ease-nav)",
minimized ? "flex-none" : "flex-1 justify-around"
)}
>
{items}
</div>
{extras}
</nav>
</TabBarContext.Provider>
)
}
type TabBarItemProps = Omit<ComponentProps<"button">, "value"> & {
value: string
icon: IconSvgElement
label: string
href?: string
badge?: ReactNode
}
function TabBarItem({
className,
value,
icon,
label,
href,
badge,
onClick,
...props
}: TabBarItemProps) {
const context = useContext(TabBarContext)
const current = context.value === value
const hidden = context.minimized && !current
const itemClassName = cn(
"relative flex h-(--tab-bar-item) min-w-11 flex-1 flex-col items-center justify-center gap-0.5 rounded-full px-3 text-[length:var(--tab-bar-label)] leading-none font-medium text-label-2 transition-[background-color,color] duration-(--duration-press) outline-none select-none focus-visible:ring-4 focus-visible:ring-ring/60 aria-[current=page]:bg-fill-3 aria-[current=page]:text-primary aria-[current=true]:bg-fill-3 aria-[current=true]:text-primary [&_svg]:size-6",
className
)
const content = (
<>
<span
data-slot="tab-bar-item-icon"
className="relative flex items-center justify-center"
>
<Icon icon={icon} weight={current ? "semibold" : "regular"} />
{badge !== undefined && badge !== null ? (
<Badge className="absolute -end-2.5 -top-1.5">{badge}</Badge>
) : null}
</span>
<span data-slot="tab-bar-item-label">{label}</span>
</>
)
if (href) {
return (
<a
href={href}
data-slot="tab-bar-item"
aria-current={current ? "page" : undefined}
hidden={hidden}
className={itemClassName}
>
{content}
</a>
)
}
return (
<button
type="button"
data-slot="tab-bar-item"
aria-current={current ? "true" : undefined}
hidden={hidden}
className={itemClassName}
onClick={(event) => {
context.onValueChange?.(value)
onClick?.(event)
}}
{...props}
>
{content}
</button>
)
}
type TabBarSearchProps = Omit<ComponentProps<"button">, "children"> & {
icon: IconSvgElement
href?: string
label?: string
}
function TabBarSearch({
className,
icon,
href,
label = "Search",
...props
}: TabBarSearchProps) {
const searchClassName = cn(
"flex size-(--tab-bar-height) shrink-0 pressable items-center justify-center rounded-full glass text-label outline-none focus-visible:ring-4 focus-visible:ring-ring/60 [&_svg]:size-6",
className
)
if (href) {
return (
<a
href={href}
aria-label={label}
data-slot="tab-bar-search"
className={searchClassName}
>
<Icon icon={icon} weight="semibold" />
</a>
)
}
return (
<button
type="button"
aria-label={label}
data-slot="tab-bar-search"
className={searchClassName}
{...props}
>
<Icon icon={icon} weight="semibold" />
</button>
)
}
export { TabBar, TabBarItem, TabBarSearch }
export type { TabBarItemProps, TabBarProps, TabBarSearchProps }