The close button is a small, accessible "x" for dismissing alerts, toasts, modals, offcanvas panels, chips and list items. Always set an aria-label, use data-ui-dismiss to close Bootstrap components, and place it on dark surfaces with data-ui-theme="dark".
1Basic close button
A plain .btn-close; always give it an aria-label.
<button type="button" class="btn-close" aria-label="Close"></button>2Disabled
The disabled attribute fades the button and blocks clicks.
<div class="flex gap-4 items-center">
<button type="button" class="btn-close" aria-label="Close"></button>
<button type="button" class="btn-close" disabled aria-label="Close"></button>
</div>3On dark backgrounds
Inside data-ui-theme="dark" the icon turns white automatically.
<div data-ui-theme="dark" class="bg-dark p-4 rounded-md flex gap-4">
<button type="button" class="btn-close" aria-label="Close"></button>
<button type="button" class="btn-close" disabled aria-label="Close"></button>
</div>4In an alert
data-ui-dismiss="alert" removes the alert when the close button is clicked.
<div class="alert alert-info alert-dismissible fade show mb-0" role="alert">
<i class="bi bi-info-circle" aria-hidden="true"></i> Thousands of donors already trust us, and we work hard to keep it that way.
<button type="button" class="btn-close" data-ui-dismiss="alert" aria-label="Close"></button>
</div>5In a toast
The close button in a toast header uses data-ui-dismiss="toast"; the button below shows it again.
<div id="toast-901" class="toast show" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
<img src="../assets/img/avatar-1.svg" class="rounded-md me-2" width="20" height="20" alt="Ruby Whitaker"><strong class="me-auto">Ruby Whitaker</strong><small class="text-muted">yesterday</small>
<button type="button" class="btn-close" data-ui-dismiss="toast" aria-label="Close"></button>
</div>
<div class="toast-body">
Volunteers give their time in schools, shelters and food banks every week.
</div>
</div>
<button type="button" class="btn btn-outline-secondary btn-sm mt-2" data-demo-toast="#toast-901">Show toast again</button>6In a modal header
A static modal preview: the close button sits at the end of the header.
<div class="modal static block" tabindex="-1" aria-labelledby="modal-title-902">
<div class="modal-dialog m-0">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="modal-title-902">Rename file</h5>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
<div class="modal-body">
<p class="mb-0">Every detail is handled by people who care about getting it right.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light border">Cancel</button>
<button type="button" class="btn btn-primary">Rename</button>
</div>
</div>
</div>
</div>7Card corner
Positioned in the top-right corner of a card to dismiss a tip.
Quick tip
A school kit costs less than a cinema ticket and lasts a whole year.
<div class="card relative" style="max-width: 22rem;">
<div class="card-body pe-12">
<h6 class="card-title"><i class="bi bi-lightbulb" aria-hidden="true"></i> Quick tip</h6>
<p class="card-text small mb-0">A school kit costs less than a cinema ticket and lasts a whole year.</p>
</div>
<button type="button" class="btn-close absolute top-0 end-0 m-2" aria-label="Dismiss tip"></button>
</div>8Chips with close
Small close buttons inside chips remove a selected value.
<div class="flex flex-wrap gap-2">
<span class="ca-chip">Omar Brennan
<button type="button" class="btn-close" aria-label="Remove Omar Brennan"></button>
</span><span class="ca-chip">Theo Ibrahim
<button type="button" class="btn-close" aria-label="Remove Theo Ibrahim"></button>
</span><span class="ca-chip">Freya Morgan
<button type="button" class="btn-close" aria-label="Remove Freya Morgan"></button>
</span>
</div>9Sizes
Scale the button with font-size; it is built from an em-sized background icon.
<div class="flex gap-6 items-center">
<button type="button" class="btn-close ca-close-sm" aria-label="Close small"></button>
<button type="button" class="btn-close" aria-label="Close"></button>
<button type="button" class="btn-close ca-close-lg" aria-label="Close large"></button>
</div>10In an offcanvas
The close button in an offcanvas header uses data-ui-dismiss="offcanvas".
Filters
Clear prices, honest advice and no surprises along the way.
<button class="btn btn-primary" type="button" data-ui-toggle="offcanvas" data-ui-target="#offcanvas-903" aria-controls="offcanvas-903"><i class="bi bi-funnel" aria-hidden="true"></i> Open filters</button>
<div class="offcanvas offcanvas-end" tabindex="-1" id="offcanvas-903" aria-labelledby="offcanvas-label-904">
<div class="offcanvas-header border-b">
<h5 class="offcanvas-title" id="offcanvas-label-904">Filters</h5>
<button type="button" class="btn-close" data-ui-dismiss="offcanvas" aria-label="Close"></button>
</div>
<div class="offcanvas-body">
<p>Clear prices, honest advice and no surprises along the way.</p>
</div>
</div>11Remove uploaded images
Small round close buttons on thumbnails in an upload preview.
<div class="flex flex-wrap gap-4">
<div class="relative">
<img src="https://images.unsplash.com/photo-1758599668360-48ba8ba71b47?auto=format&fit=crop&w=800&h=800&q=70" alt="Upload 1" class="rounded-md border" width="96" height="96">
<button type="button" class="btn-close bg-white rounded-full p-1 absolute top-0 end-0 m-1 shadow-sm" style="font-size: .6rem;" aria-label="Remove image 1"></button>
</div>
<div class="relative">
<img src="https://images.unsplash.com/photo-1706806594967-44e2b31f01d0?auto=format&fit=crop&w=800&h=800&q=70" alt="Upload 2" class="rounded-md border" width="96" height="96">
<button type="button" class="btn-close bg-white rounded-full p-1 absolute top-0 end-0 m-1 shadow-sm" style="font-size: .6rem;" aria-label="Remove image 2"></button>
</div>
<div class="relative">
<img src="https://images.unsplash.com/photo-1758599668178-d9716bbda9d5?auto=format&fit=crop&w=800&h=800&q=70" alt="Upload 3" class="rounded-md border" width="96" height="96">
<button type="button" class="btn-close bg-white rounded-full p-1 absolute top-0 end-0 m-1 shadow-sm" style="font-size: .6rem;" aria-label="Remove image 3"></button>
</div>
</div>12Remove list items
A close button at the end of each list item, e.g. email attachments.
- our-yearly-impact-report-explained.pdf
- how-your-donations-built-three-new-classrooms.png
- inside-the-shelter-from-rescue-to-new-home.pdf
<ul class="list-group" style="max-width: 380px;">
<li class="list-group-item flex justify-between items-center"><span><i class="bi bi-paperclip" aria-hidden="true"></i> our-yearly-impact-report-explained.pdf</span><button type="button" class="btn-close" aria-label="Remove attachment"></button></li>
<li class="list-group-item flex justify-between items-center"><span><i class="bi bi-paperclip" aria-hidden="true"></i> how-your-donations-built-three-new-classrooms.png</span><button type="button" class="btn-close" aria-label="Remove attachment"></button></li>
<li class="list-group-item flex justify-between items-center"><span><i class="bi bi-paperclip" aria-hidden="true"></i> inside-the-shelter-from-rescue-to-new-home.pdf</span><button type="button" class="btn-close" aria-label="Remove attachment"></button></li>
</ul>13Clear a search field
A close button inside an input group clears the search.
<div class="input-group" style="max-width: 360px;">
<span class="input-group-text bg-transparent"><i class="bi bi-search" aria-hidden="true"></i></span><input type="search" class="form-control border-s-0 border-e-0" id="clear-search-905" value="update" aria-label="Search"><span class="input-group-text bg-transparent">
<button type="button" class="btn-close" aria-label="Clear search"></button>
</span>
</div>14Notification panel header
A panel title with a mark-all link and a close button.
<div class="border rounded-md shadow-sm" style="max-width: 360px;">
<div class="flex items-center gap-2 p-4 border-b">
<strong class="me-auto">Notifications</strong><a href="#" class="small">Mark all read</a>
<button type="button" class="btn-close" aria-label="Close notifications"></button>
</div>
<div class="p-4 small text-muted">
Our annual report is independently audited and published in full.
</div>
</div>15Cart item remove
A close button removes a product row from the mini cart.
<div class="flex items-center gap-4 border rounded-md p-2" style="max-width: 420px;">
<img src="../assets/img/product-3.svg" alt="Meal pack" class="rounded-md" width="56" height="56">
<div class="grow">
<div class="font-semibold small">
Meal pack
</div>
<div class="small text-muted">
Qty 1 · $16.00
</div>
</div>
<button type="button" class="btn-close" aria-label="Remove Meal pack from cart"></button>
</div>16On coloured surfaces
On primary, success or danger backgrounds use a dark theme wrapper so the icon stays visible.
<div class="flex flex-col gap-2">
<div class="text-bg-primary rounded-md p-4 flex justify-between" data-ui-theme="dark">
<span>Start in minutes and get help from a real person whenever you need it.</span>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
<div class="text-bg-success rounded-md p-4 flex justify-between" data-ui-theme="dark">
<span>Payment received.</span>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
</div>17Close with a label
When space allows, pair the icon with a visible word for clarity.
<button type="button" class="btn btn-light border inline-flex items-center gap-2"><span class="btn-close" style="font-size: .65rem;" aria-hidden="true"></span> Close</button>18Filter chips row
A row of active filters, each removable, with a clear-all link.
<div class="flex flex-wrap items-center gap-2">
<span class="small text-muted me-1">Active filters:</span><span class="badge rounded-full bg-primary-subtle text-primary-emphasis inline-flex items-center gap-2 py-2 px-4 font-normal">Education
<button type="button" class="btn-close" style="font-size: .5rem;" aria-label="Remove Education filter"></button>
</span><span class="badge rounded-full bg-primary-subtle text-primary-emphasis inline-flex items-center gap-2 py-2 px-4 font-normal">Rating 4+
<button type="button" class="btn-close" style="font-size: .5rem;" aria-label="Remove Rating 4+ filter"></button>
</span><span class="badge rounded-full bg-primary-subtle text-primary-emphasis inline-flex items-center gap-2 py-2 px-4 font-normal">Free shipping
<button type="button" class="btn-close" style="font-size: .5rem;" aria-label="Remove Free shipping filter"></button>
</span><span class="badge rounded-full bg-primary-subtle text-primary-emphasis inline-flex items-center gap-2 py-2 px-4 font-normal">Valencia
<button type="button" class="btn-close" style="font-size: .5rem;" aria-label="Remove Valencia filter"></button>
</span><a href="#" class="small ms-1">Clear all</a>
</div>19Promo banner
A full-width dismissible banner at the top of a page.
<div class="alert alert-dismissible fade show rounded-none border-0 text-center mb-0 ca-promo" role="alert" data-ui-theme="dark">
<i class="bi bi-stars" aria-hidden="true"></i> <strong>17% off</strong> all yearly plans this week. <a href="#" class="alert-link">Claim offer</a>
<button type="button" class="btn-close" data-ui-dismiss="alert" aria-label="Close"></button>
</div>20Modal with close buttons
A real modal: the header close button and the footer button both use data-ui-dismiss="modal".
<button type="button" class="btn btn-primary" data-ui-toggle="modal" data-ui-target="#modal-906">Open dialog</button>
<div class="modal fade" id="modal-906" tabindex="-1" aria-labelledby="modal-title-907" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="modal-title-907">A day in the life of a volunteer</h5>
<button type="button" class="btn-close" data-ui-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p class="mb-0">Companies can match employee donations and double their impact. We keep things simple, so you can focus on what matters to you.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-ui-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Got it</button>
</div>
</div>
</div>
</div>