Veil UI
Components

Button

Triggers an action or event. Supports variants, sizes, icons and composition.

Installation

$ npx veil-ui@latest add button

Usage

import { Button } from "@/components/ui/button";

<Button variant="outline">Cancel</Button>;

Examples

Basic

Variants

Sizes

With icons

Loading

Disable the button and swap the leading icon for a spinner. The accessible name stays stable, so screen readers announce the action rather than the state change.

Composition

asChild forwards styles and props to a single child element. Use it for links, Next.js <Link> or any custom trigger.

API reference

PropTypeDefaultDescription
variant"default" | "secondary" | "outline" | "ghost" | "destructive" | "link""default"Visual style of the button.
size"sm" | "default" | "lg" | "icon""default"Control height and padding.
asChildbooleanfalseRender the child element instead of a button.
...propsReact.ComponentProps<"button">—All native button attributes, including type, disabled and onClick.

Accessibility

  • Renders a native <button> unless asChild is used.
  • Includes a 3px focus ring with offset, visible in both themes.
  • Disabled buttons use pointer-events: none and opacity: 50%.
  • Icon-only buttons must receive an aria-label.
  • Loading buttons keep the same accessible name; mark the button disabled while the request is in flight.

Vue and plain HTML

This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add button --framework vue or switch the framework in components.json.

<script setup lang="ts">
import { Primitive } from "reka-ui";
import { computed } from "vue";

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

import { buttonVariants, type ButtonVariants } from "./variants";

defineOptions({ inheritAttrs: false });

const props = withDefaults(
  defineProps<{
    variant?: ButtonVariants["variant"];
    size?: ButtonVariants["size"];
    asChild?: boolean;
    type?: "button" | "submit" | "reset";
    disabled?: boolean;
    class?: string;
  }>(),
  { asChild: false, type: "button" },
);

const classes = computed(() =>
  cn(buttonVariants({ variant: props.variant, size: props.size }), props.class),
);
</script>

<template>
  <Primitive
    v-if="asChild"
    as-child
    data-slot="button"
    :data-variant="variant ?? 'default'"
    :data-size="size ?? 'default'"
    :class="classes"
    v-bind="$attrs"
  >
    <slot />
  </Primitive>
  <button
    v-else
    data-slot="button"
    :data-variant="variant ?? 'default'"
    :data-size="size ?? 'default'"
    :type="type"
    :disabled="disabled"
    :class="classes"
    v-bind="$attrs"
  >
    <slot />
  </button>
</template>

On this page