Veil UI
Components

Mobile Header

A compact sticky header with back navigation and actions.

Installation

$ npx veil-ui@latest add mobile-header

Usage

import { MobileHeader } from "@/components/ui/mobile-header";

<MobileHeader
  title="Billing"
  subtitle="Acme workspace"
  onBack={() => history.back()}
  actions={<Button size="icon" variant="ghost" aria-label="Share" />}
/>;

Examples

Basic

Project settings

Acme workspace

With back

Billing

API reference

The package exports mobile-header 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-header --framework vue or switch the framework in components.json.

<script setup lang="ts">
import { ChevronLeft } from "lucide-vue-next";

import { cn } from "@/lib/utils";

import type { MobileHeaderProps } from "./types";

defineOptions({ inheritAttrs: false });

const props = withDefaults(defineProps<MobileHeaderProps>(), {
  sticky: true,
});
</script>

<template>
  <header
    data-slot="mobile-header"
    v-bind="$attrs"
    :class="
      cn(
        'z-30 border-b bg-background/95 pt-[env(safe-area-inset-top)] backdrop-blur',
        sticky && 'sticky top-0',
        props.class,
      )
    "
  >
    <div class="flex h-14 items-center gap-2 px-3">
      <button
        v-if="props.onBack"
        type="button"
        aria-label="Go back"
        class="rounded-full p-1.5 text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
        @click="props.onBack()"
      >
        <ChevronLeft class="size-5" aria-hidden="true" />
      </button>
      <div class="min-w-0 flex-1">
        <p class="truncate text-sm font-semibold leading-tight">
          <slot name="title">{{ title }}</slot>
        </p>
        <p
          v-if="subtitle || $slots.subtitle"
          class="truncate text-xs text-muted-foreground"
        >
          <slot name="subtitle">{{ subtitle }}</slot>
        </p>
      </div>
      <div v-if="$slots.actions" class="flex shrink-0 items-center gap-1">
        <slot name="actions" />
      </div>
    </div>
  </header>
</template>

On this page