Skip to component content

Dismiss alerts, dialogs, and other transient content with Bootstrap's native .btn-close.

Usage

Use .btn-close for dismissing nearby transient content such as alerts, dialogs, toasts, and offcanvas panels. Render the button at the edge of the surface it dismisses, and always provide an accessible name with aria-label because the icon has no visible text.

Pair the close button with the matching Bootstrap dismissal behavior for the owning component, such as data-bs-dismiss="alert" or data-bs-dismiss="modal". Use disabled only when dismissal is temporarily unavailable; Bootstrap suppresses pointer and selection behavior for the disabled state.

For dark surfaces, prefer data-bs-theme="dark" on the button or parent instead of deprecated color inversion classes. After dismissal, make sure focus lands somewhere sensible when the closed surface contained the active control.

Default

Provide an accessible label; the icon itself carries no visible text.

Close Button
<div class="d-inline-flex">
  <button type="button" class="btn-close" aria-label="Close"></button>
</div>

Disabled

Disabled close buttons lower opacity and drop pointer and hover interaction.

Close Button
<div class="d-inline-flex">
  <button type="button" class="btn-close" aria-label="Close" disabled></button>
</div>

In context

Pair with a flex row to dismiss a notice, alert, or toast.

Close Button
Update available
Version 2.1 is ready to install.
<div class="d-flex align-items-start justify-content-between gap-3 p-3 rounded-3 border bg-body" style="width: 20rem;">
  <div>
    <div class="fw-medium">Update available</div>
    <div class="text-body-secondary small">Version 2.1 is ready to install.</div>
  </div>
  <button type="button" class="btn-close" aria-label="Close"></button>
</div>

RTL

Compare Arabic, Hebrew, and English close actions in an RTL layout for operations workflows.

تم تجاهل الحادث
تم مسح تنبيه الحادث.
<div class="d-inline-flex align-items-start justify-content-between gap-3 p-3 rounded-3 border bg-body" dir="rtl">
  <div>
    <div class="fw-medium">تم تجاهل الحادث</div>
    <div class="text-body-secondary small">تم مسح تنبيه الحادث.</div>
  </div>
  <button type="button" class="btn-close" aria-label="إغلاق"></button>
</div>
האירוע נסגר
התראת האירוע נוקתה.
<div class="d-inline-flex align-items-start justify-content-between gap-3 p-3 rounded-3 border bg-body" dir="rtl">
  <div>
    <div class="fw-medium">האירוע נסגר</div>
    <div class="text-body-secondary small">התראת האירוע נוקתה.</div>
  </div>
  <button type="button" class="btn-close" aria-label="סגירה"></button>
</div>
Incident dismissed
The incident alert was cleared.
<div class="d-inline-flex align-items-start justify-content-between gap-3 p-3 rounded-3 border bg-body" dir="ltr">
  <div>
    <div class="fw-medium">Incident dismissed</div>
    <div class="text-body-secondary small">The incident alert was cleared.</div>
  </div>
  <button type="button" class="btn-close" aria-label="Close"></button>
</div>

Component reference

Status
Accepted
Runtime
native HTML/CSS
Markup
Bootstrap/native HTML
Reference

For Bootstrap's source behavior and CSS variables, see the Bootstrap Close button documentation.

Settings

Theme
Choose how Moo UI looks on this device.
Sidebar
Choose how the sidebar sits on the page.
Theme Builder
Tune catalog tokens and chart colors for this browser.
Base color
Theme color
Chart color
Heading font
Body font
Radius
Direction
Choose the reading direction. RTL flips the layout live.
Reset

Restore the default appearance.