Components
Mobile Toolbar
A horizontally scrollable row of labeled toolbar actions.
Installation
$ npx veil-ui@latest add mobile-toolbarUsage
import { MobileToolbar } from "@/components/ui/mobile-toolbar";
<MobileToolbar
items={[
{ label: "Filter", active: true, onClick: openFilters },
{ label: "Sort", onClick: openSort },
]}
/>;Examples
Basic
View switch
Showing grid view
API reference
The package exports mobile-toolbar along with its composable parts. It forwards standard attributes to its root element; see the examples above for the component-specific props.
Accessibility
- Touch targets are large enough to tap comfortably and keep visible focus rings for keyboard and switch users.
- Gesture interactions (swipe, pull to refresh) have visible button alternatives so they are not the only way to act.
- Sheets, drawers and dialogs follow the underlying accessible primitives for focus trapping and escape handling.
Vue and plain HTML
This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add mobile-toolbar --framework vue or switch the framework in components.json.
<script setup lang="ts">
import { computed, useAttrs } from "vue";
import { cn } from "@/lib/utils";
import type { MobileToolbarItem, MobileToolbarProps } from "./types";
defineOptions({ inheritAttrs: false });
const props = defineProps<MobileToolbarProps>();
const attrs = useAttrs();
const label = computed(
() => (attrs["aria-label"] as string | undefined) ?? "Toolbar",
);
function itemClasses(item: MobileToolbarItem) {
return cn(
"relative inline-flex shrink-0 items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring",
item.active
? "bg-primary text-primary-foreground"
: "text-muted-foreground hover:bg-accent hover:text-accent-foreground",
);
}
</script>
<template>
<div
data-slot="mobile-toolbar"
role="toolbar"
:aria-label="label"
v-bind="$attrs"
:class="
cn(
'flex w-full items-center gap-1 overflow-x-auto border-y bg-background px-2 py-1.5 [scrollbar-width:none]',
props.class,
)
"
>
<button
v-for="item in items"
:key="item.label"
type="button"
:aria-pressed="item.active"
:class="itemClasses(item)"
@click="item.onClick?.()"
>
<span v-if="item.icon" class="[&_svg]:size-3.5" aria-hidden="true">
<component :is="item.icon" />
</span>
<span>{{ item.label }}</span>
<span
v-if="item.badge !== undefined"
class="rounded-full bg-muted px-1.5 text-[10px] leading-4 text-muted-foreground"
>
{{ item.badge }}
</span>
</button>
</div>
</template>