Components
Icon
A lucide icon wrapper with size presets and accessible labels.
Installation
$ npx veil-ui@latest add iconUsage
import { ArrowRight } from "lucide-react";
import { Icon } from "@/components/ui/icon";
<Icon icon={ArrowRight} />;Examples
Basic
Continue
Labeled
Sizes
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| icon | LucideIcon | — | The lucide icon component to render. |
| size | "xs" | "sm" | "md" | "lg" | "xl" | "md" | Square size preset from 12px to 32px. |
| strokeWidth | number | 2 | SVG stroke width. |
| label | string | — | When set, the icon becomes an image with this accessible name. |
Accessibility
- Decorative icons are hidden from assistive technology by default.
- Give standalone, meaningful icons a
label; otherwise the surrounding text already provides the name.
Vue and plain HTML
This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add icon --framework vue or switch the framework in components.json.
<script setup lang="ts">
import { computed, type Component } from "vue";
import { cn } from "@/lib/utils";
const sizes = {
xs: "size-3",
sm: "size-4",
md: "size-5",
lg: "size-6",
xl: "size-8",
} as const;
const props = withDefaults(
defineProps<{
icon: Component;
size?: keyof typeof sizes;
strokeWidth?: number;
label?: string;
class?: string;
}>(),
{ size: "md", strokeWidth: 2 },
);
const classes = computed(() => cn(sizes[props.size], props.class));
</script>
<template>
<component
:is="props.icon"
data-slot="icon"
:aria-hidden="props.label ? undefined : true"
:aria-label="props.label"
:role="props.label ? 'img' : undefined"
:stroke-width="props.strokeWidth"
:class="classes"
/>
</template>