Components
Safe Area View
A wrapper that applies device safe-area insets on selected edges.
Installation
$ npx veil-ui@latest add safe-area-viewUsage
import { SafeAreaView } from "@/components/ui/safe-area-view";
<SafeAreaView edges={["top", "bottom"]}>{content}</SafeAreaView>;Examples
Basic
Content respects all device insets.
Bottom only
Sticky footer content
Only the bottom inset is applied.
API reference
The package exports safe-area-view 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 safe-area-view --framework vue or switch the framework in components.json.
<script setup lang="ts">
import { computed } from "vue";
import { cn } from "@/lib/utils";
import type { SafeAreaEdge, SafeAreaViewProps } from "./types";
const edgeClasses: Record<SafeAreaEdge, string> = {
top: "pt-[env(safe-area-inset-top)]",
right: "pr-[env(safe-area-inset-right)]",
bottom: "pb-[env(safe-area-inset-bottom)]",
left: "pl-[env(safe-area-inset-left)]",
};
const props = withDefaults(defineProps<SafeAreaViewProps>(), {
edges: () => ["top", "right", "bottom", "left"],
});
const classes = computed(() =>
cn(
props.edges.map((edge) => edgeClasses[edge]),
props.class,
),
);
</script>
<template>
<div
data-slot="safe-area-view"
:data-edges="props.edges.join(' ')"
:class="classes"
>
<slot />
</div>
</template>