Close Button
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="d-flex gap-3 align-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-3 rounded d-flex gap-3">
<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-fill" aria-hidden="true"></i> New pieces arrive every month, and the best ones sell out fast.
<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 me-2" width="20" height="20" alt="Sofia Kim"><strong class="me-auto">Sofia Kim</strong><small class="text-body-secondary">yesterday</small>
<button type="button" class="btn-close" data-ui-dismiss="toast" aria-label="Close"></button>
</div>
<div class="toast-body">
Start in minutes and get help from a real person whenever you need it.
</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 position-static d-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">Friendly people answer your questions quickly, by phone, chat or email.</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
Free shipping on orders over $50 and easy returns within 30 days.
<div class="card position-relative" style="max-width: 22rem;">
<div class="card-body pe-5">
<h6 class="card-title"><i class="bi bi-lightbulb-fill" aria-hidden="true"></i> Quick tip</h6>
<p class="card-text small mb-0">Free shipping on orders over $50 and easy returns within 30 days.</p>
</div>
<button type="button" class="btn-close position-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="d-flex flex-wrap gap-2">
<span class="ca-chip">Lea Varga
<button type="button" class="btn-close" aria-label="Remove Lea Varga"></button>
</span><span class="ca-chip">Theo Rossi
<button type="button" class="btn-close" aria-label="Remove Theo Rossi"></button>
</span><span class="ca-chip">Noah Silva
<button type="button" class="btn-close" aria-label="Remove Noah Silva"></button>
</span>
</div>9Sizes
Scale the button with font-size; it is built from an em-sized background icon.
<div class="d-flex gap-4 align-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
Each product is checked by hand before it goes into the box.
<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-fill" 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-bottom">
<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>Each product is checked by hand before it goes into the box.</p>
</div>
</div>11Remove uploaded images
Small round close buttons on thumbnails in an upload preview.
<div class="d-flex flex-wrap gap-3">
<div class="position-relative">
<img src="https://images.unsplash.com/photo-1443884590026-2e4d21aee71c?auto=format&fit=crop&w=800&h=800&q=70" alt="Upload 1" class="rounded border" width="96" height="96">
<button type="button" class="btn-close bg-white rounded-circle p-1 position-absolute top-0 end-0 m-1 shadow-sm" style="font-size: .6rem;" aria-label="Remove image 1"></button>
</div>
<div class="position-relative">
<img src="https://images.unsplash.com/photo-1598305762558-328f599df683?auto=format&fit=crop&w=800&h=800&q=70" alt="Upload 2" class="rounded border" width="96" height="96">
<button type="button" class="btn-close bg-white rounded-circle p-1 position-absolute top-0 end-0 m-1 shadow-sm" style="font-size: .6rem;" aria-label="Remove image 2"></button>
</div>
<div class="position-relative">
<img src="https://images.unsplash.com/photo-1601647998829-ee316a565aea?auto=format&fit=crop&w=800&h=800&q=70" alt="Upload 3" class="rounded border" width="96" height="96">
<button type="button" class="btn-close bg-white rounded-circle p-1 position-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.
- how-to-care-for-linen-so-it-lasts-for-years.pdf
- meet-the-makers-behind-our-ceramics.png
- looking-back-at-a-busy-season.pdf
<ul class="list-group" style="max-width: 380px;">
<li class="list-group-item d-flex justify-content-between align-items-center"><span><i class="bi bi-paperclip" aria-hidden="true"></i> how-to-care-for-linen-so-it-lasts-for-years.pdf</span><button type="button" class="btn-close" aria-label="Remove attachment"></button></li>
<li class="list-group-item d-flex justify-content-between align-items-center"><span><i class="bi bi-paperclip" aria-hidden="true"></i> meet-the-makers-behind-our-ceramics.png</span><button type="button" class="btn-close" aria-label="Remove attachment"></button></li>
<li class="list-group-item d-flex justify-content-between align-items-center"><span><i class="bi bi-paperclip" aria-hidden="true"></i> looking-back-at-a-busy-season.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-start-0 border-end-0" id="clear-search-905" value="community" 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 shadow-sm" style="max-width: 360px;">
<div class="d-flex align-items-center gap-2 p-3 border-bottom">
<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-3 small text-body-secondary">
We listen first, then build a plan around what you actually need.
</div>
</div>15Cart item remove
A close button removes a product row from the mini cart.
<div class="d-flex align-items-center gap-3 border rounded p-2" style="max-width: 420px;">
<img src="../assets/img/product-10.svg" alt="Face oil" class="rounded" width="56" height="56">
<div class="flex-grow-1">
<div class="fw-semibold small">
Face oil
</div>
<div class="small text-body-secondary">
Qty 1 · $35.00
</div>
</div>
<button type="button" class="btn-close" aria-label="Remove Face oil 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="d-flex flex-column gap-2">
<div class="text-bg-primary rounded p-3 d-flex justify-content-between" data-ui-theme="dark">
<span>We measure success by how many shoppers come back and tell their friends.</span>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
<div class="text-bg-success rounded p-3 d-flex justify-content-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 d-inline-flex align-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="d-flex flex-wrap align-items-center gap-2">
<span class="small text-body-secondary me-1">Active filters:</span><span class="badge rounded-pill bg-primary-subtle text-primary-emphasis d-inline-flex align-items-center gap-2 py-2 px-3 fw-normal">Accessories
<button type="button" class="btn-close" style="font-size: .5rem;" aria-label="Remove Accessories filter"></button>
</span><span class="badge rounded-pill bg-primary-subtle text-primary-emphasis d-inline-flex align-items-center gap-2 py-2 px-3 fw-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-pill bg-primary-subtle text-primary-emphasis d-inline-flex align-items-center gap-2 py-2 px-3 fw-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-pill bg-primary-subtle text-primary-emphasis d-inline-flex align-items-center gap-2 py-2 px-3 fw-normal">Toronto
<button type="button" class="btn-close" style="font-size: .5rem;" aria-label="Remove Toronto 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-0 border-0 text-center mb-0 ca-promo" role="alert" data-ui-theme="dark">
<i class="bi bi-stars" aria-hidden="true"></i> <strong>37% 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">How we choose sustainable materials</h5>
<button type="button" class="btn-close" data-ui-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p class="mb-0">Our team has done this many times, so you never have to guess. Order before 2 pm and most items leave our warehouse the same day.</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>