Components
Bottom Navigation
A thumb-friendly tab bar for primary mobile destinations.
Installation
$ npx veil-ui@latest add bottom-navigationUsage
import { Home, User } from "lucide-react";
import { BottomNavigation } from "@/components/ui/bottom-navigation";
<BottomNavigation
items={[
{ label: "Home", icon: Home, href: "/", active: true },
{ label: "Account", icon: User, href: "/account" },
]}
/>;Examples
Basic
Badges
Floating
Interactive
Active: Home
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| items | { label; icon; href?; active?; badge? }[] | — | Destinations, each with a required lucide icon. |
| onSelect | (item) => void | — | Called instead of navigating when an item is clicked. |
| variant | "default" | "floating" | — | Default is a pinned bar with a top border; floating renders a rounded, elevated pill. |
| ...props | React.ComponentProps<"nav"> | — | All native nav attributes. |
Accessibility
- Renders a labelled
<nav>landmark. - The active destination receives
aria-current="page". - Badges are purely visual; keep counts out of the accessible name unless they change meaning.
Vue and plain HTML
This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add bottom-navigation --framework vue or switch the framework in components.json.
<script setup lang="ts">
import { cn } from "@/lib/utils";
import type { BottomNavigationItem, BottomNavigationProps } from "./types";
defineOptions({ inheritAttrs: false });
const props = withDefaults(defineProps<BottomNavigationProps>(), {
variant: "default",
});
function itemClasses(item: BottomNavigationItem) {
return cn(
"relative flex flex-1 flex-col items-center gap-1 rounded-xl py-2 text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
item.active &&
props.variant === "default" &&
"text-foreground after:absolute after:inset-x-4 after:top-0 after:h-0.5 after:rounded-full after:bg-foreground",
item.active && props.variant === "floating" && "bg-muted text-foreground",
);
}
</script>
<template>
<nav
data-slot="bottom-navigation"
:data-variant="variant"
aria-label="Bottom"
:class="
cn(
'flex w-full items-stretch justify-around bg-background',
variant === 'default' &&
'border-t pb-[env(safe-area-inset-bottom)]',
variant === 'floating' &&
'mx-auto w-[calc(100%-2rem)] max-w-md gap-1 rounded-2xl border p-1 shadow-lg backdrop-blur supports-[backdrop-filter]:bg-background/80',
props.class,
)
"
v-bind="$attrs"
>
<template v-for="item in items" :key="item.label">
<a
v-if="item.href"
:href="item.href"
:aria-current="item.active ? 'page' : undefined"
:class="itemClasses(item)"
>
<span class="relative">
<component :is="item.icon" class="size-5" aria-hidden="true" />
<span
v-if="item.badge || $slots.badge"
class="absolute -right-2 -top-1 min-w-4 rounded-full bg-primary px-1 text-center text-[10px] font-medium leading-4 text-primary-foreground"
>
<slot name="badge" :item="item">{{ item.badge }}</slot>
</span>
</span>
<span class="text-[11px] font-medium">{{ item.label }}</span>
</a>
<button
v-else
type="button"
:aria-current="item.active ? 'page' : undefined"
:class="itemClasses(item)"
@click="props.onSelect?.(item)"
>
<span class="relative">
<component :is="item.icon" class="size-5" aria-hidden="true" />
<span
v-if="item.badge || $slots.badge"
class="absolute -right-2 -top-1 min-w-4 rounded-full bg-primary px-1 text-center text-[10px] font-medium leading-4 text-primary-foreground"
>
<slot name="badge" :item="item">{{ item.badge }}</slot>
</span>
</span>
<span class="text-[11px] font-medium">{{ item.label }}</span>
</button>
</template>
</nav>
</template>