Skip to main content

CloseButton

A button component used to close or dismiss content, such as modals, alerts, or other dismissible elements.

Usage

import { CloseButton } from '@blendx-ui';

// Basic usage
<CloseButton onClick={handleClose} />

// With custom aria-label
<CloseButton
onClick={handleClose}
aria-label="Close modal"
/>

Props

PropTypeRequiredDefaultDescription
onClickfunctionYes-Callback function called when the button is clicked
aria-labelstringNo"Close"Accessibility label for the button
classNamestringNo-Additional CSS classes to apply
disabledbooleanNofalseWhether the button is disabled
variantstringNo-Visual variant of the button

Accessibility

  • The button includes an aria-label by default for screen readers
  • It's keyboard accessible and can be triggered with the Enter or Space key
  • The button has appropriate focus styles for keyboard navigation

Best Practices

  • Always provide an onClick handler
  • Consider providing a custom aria-label if the default "Close" isn't descriptive enough
  • Use this component for dismissible elements like modals, alerts, or popovers
  • Modal
  • Alert
  • Toast
  • Popover

Notes

This component is built on top of React Bootstrap's CloseButton component.