Import
Usage
Props
Accessible label for the button. Defaults to “Close” but can be customized for specific contexts
(e.g., “Dismiss notification”, “Close dialog”, “Remove item”).
The visual style variant of the button (inherited from ActionIcon):
primary- Filled with primary color and shadowsecondary- Filled with secondary colorghost- Transparent background (default)destructive- Filled with destructive/danger color and shadowoutline- Transparent with border outline
The size of the square button:
xs- 28×28px (size-7)sm- 32×32px (size-8)md- 36×36px (size-9)lg- 40×40px (size-10)xl- 44×44px (size-11)
Whether the button is disabled. Disabled buttons have reduced opacity and cannot be clicked.
Whether the button is in a loading state. Replaces the close icon with a spinner and disables interaction.
Callback function triggered when the button is clicked. Ignored when disabled or loading.
Additional CSS classes to apply to the button element.
Forward ref to the underlying button element.
Description
CloseButton is a convenience component that wraps ActionIcon with a pre-configured close (✕) icon. It’s commonly used in:- Modal headers
- Drawer headers
- Toast notifications
- Alert/banner dismissal
- Tag removal
- Any dismissible UI element
- 24×24 viewBox scaled to 16px (size-4)
- 2px stroke width
- Round line caps and joins
- Current color inheritance
Accessibility
- Defaults to
aria-label="Close"which can be overridden for specific contexts - Uses semantic
<button>element withtype="button" - Sets
disabledandaria-disabledattributes when disabled or loading - Includes focus-visible ring for keyboard navigation
- The ✕ icon is purely decorative; the
aria-labelprovides the accessible text
Examples
Modal Header
Toast Notification
Alert Banner
Removable Tag
Drawer Header
Comparison with ActionIcon
Use CloseButton when:- You need a standard close/dismiss button
- You want consistent close icon styling
- You’re building modals, drawers, toasts, or alerts
- You need a custom icon
- You want more control over the icon appearance
- The action is not a close/dismiss action