Components
Image
A rounded image with optional aspect ratio presets.
Installation
$ npx veil-ui@latest add imageUsage
import { Image } from "@/components/ui/image";
<Image src="/photo.jpg" alt="A mountain valley" ratio="video" />;Examples
Basic
Video ratio
API reference
The package exports image along with its composable parts. It forwards standard attributes to its root element; see the examples above for the component-specific props.
Accessibility
- Media players use native
<video>and<audio>controls with accessible labels. - Images require meaningful
alttext; clickable thumbnails are buttons namedPlay <title>. - Decorative play overlays, durations and icons are hidden from assistive technology.
Vue and plain HTML
This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add image --framework vue or switch the framework in components.json.
<script setup lang="ts">
import { computed } from "vue";
import { cn } from "@/lib/utils";
const ratioClass = {
auto: "",
square: "aspect-square",
video: "aspect-video",
wide: "aspect-[3/1]",
} as const;
const props = withDefaults(
defineProps<{
src?: string;
alt?: string;
ratio?: keyof typeof ratioClass;
class?: string;
}>(),
{ ratio: "auto" },
);
const classes = computed(() =>
cn("max-w-full rounded-lg object-cover", ratioClass[props.ratio], props.class),
);
</script>
<template>
<img
data-slot="image"
:src="props.src"
:alt="props.alt"
:class="classes"
/>
</template>