Veil UI
Components

Close Button

An icon button with a pre-labelled dismiss affordance.

Installation

$ npx veil-ui@latest add close-button

Usage

import { CloseButton } from "@/components/ui/close-button";

<CloseButton />;

Examples

Basic

Outline

Large

API reference

PropTypeDefaultDescription
labelstring"Close"Accessible name announced to screen readers.
variantButtonVariant"ghost"Visual style inherited from IconButton.
sizeButtonSize"icon"Icon button size preset.

Accessibility

  • Ships with a default aria-label, so the icon-only button always has an accessible name.
  • The icon is decorative and hidden from assistive technology.
  • Override label when the surrounding context needs a more specific name, such as "Close dialog".

Vue and plain HTML

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

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

import { IconButton } from "@/components/ui/icon-button";
import type { IconButtonVariants } from "@/components/ui/icon-button";

defineOptions({ inheritAttrs: false });

const props = withDefaults(
  defineProps<{
    label?: string;
    variant?: IconButtonVariants["variant"];
    size?: IconButtonVariants["size"];
    asChild?: boolean;
    class?: string;
  }>(),
  { label: "Close" },
);
</script>

<template>
  <IconButton
    data-slot="close-button"
    :aria-label="label"
    :variant="variant"
    :size="size"
    :as-child="asChild"
    :class="props.class"
    v-bind="$attrs"
  >
    <X aria-hidden="true" />
  </IconButton>
</template>

On this page