Skip to main content
Components
Close Button
pnpm add @winkintel/bootstrap-svelte
GitHub

Close Button

Bootstrap's close button component built with Svelte 5. Use it to dismiss components like alerts, modals, and toasts.


Experiment with the CloseButton component by adjusting the props below:

Interactive Playground

Controls

Preview

Code

            
            <CloseButton />
        
            
            <CloseButton />
        

This uses the filter property to invert the background-image without overriding its value.

            
            <div class="bg-dark p-3 w-100" data-bs-theme="dark">
  <CloseButton />
  <CloseButton disabled />
</div>
        

Make close buttons look inactive by adding the disabled prop.

            
            <CloseButton disabled />
        

Close buttons have a default aria-label of "Close" for screen readers. You can customize this with the ariaLabel prop.

            
            <CloseButton aria-label="Dismiss notification" />
        

Props

NameTypeDefaultDescription
ariaLabelstring'Close'Sets the aria-label attribute for screen readers
classstringundefinedAdditional CSS classes to apply to the component.
disabledbooleanfalseMakes the button appear inactive and prevents interactions
elementRefHTMLElement | nullnullReference to the DOM element

CSS Classes

The component applies Bootstrap's close button classes based on the provided props:

  • btn-close - Always applied as the base class