2025-04-15 02:26:20 +08:00
<!DOCTYPE html> < html lang = "en" data-bs-theme = "auto" > < head > < meta charset = "UTF-8" > < meta name = "viewport" content = "width=device-width, initial-scale=1" > < meta name = "description" content = "Documentation and examples for badges, our small count and labeling component." > < meta name = "author" content = "Mark Otto, Jacob Thornton, and Bootstrap contributors" > < meta name = "generator" content = "Astro v5.6.1" > < meta name = "docsearch:language" content = "en" > < meta name = "docsearch:version" content = "5.3" > < link rel = "canonical" href = "https://getbootstrap.com/docs/5.3/components/badge/" > < link rel = "preconnect" href = "https://AK7KMZKZHQ-dsn.algolia.net" crossorigin > < title > Badges · Bootstrap v5.3< / title > < script src = "/docs/5.3/assets/js/color-modes.js" > < / script > < link rel = "stylesheet" href = "https://cdn.jsdelivr.net/npm/@docsearch/css@3" > < link href = "/docs/5.3/dist/css/bootstrap.min.css" rel = "stylesheet" integrity = "sha384-SgOJa3DmI69IUzQ2PVdRZhwQ+dy64/BUtbMJw1MZ8t5HZApcHrRKUc4W0kG879m7" > < link rel = "apple-touch-icon" href = "/docs/5.3/assets/img/favicons/apple-touch-icon.png" sizes = "180x180" > < link rel = "icon" href = "/docs/5.3/assets/img/favicons/favicon-32x32.png" sizes = "32x32" type = "image/png" > < link rel = "icon" href = "/docs/5.3/assets/img/favicons/favicon-16x16.png" sizes = "16x16" type = "image/png" > < link rel = "manifest" href = "/docs/5.3/assets/img/favicons/manifest.json" > < link rel = "mask-icon" href = "/docs/5.3/assets/img/favicons/safari-pinned-tab.svg" color = "#712cf9" > < link rel = "icon" href = "/docs/5.3/assets/img/favicons/favicon.ico" > < meta name = "theme-color" content = "#712cf9" > < meta name = "twitter:card" content = "summary_large_image" > < meta name = "twitter:site" content = "@getbootstrap" > < meta name = "twitter:creator" content = "@getbootstrap" > < meta name = "twitter:title" content = "Badges" > < meta name = "twitter:description" content = "Documentation and examples for badges, our small count and labeling component." > < meta name = "twitter:image" content = "https://getbootstrap.com/docs/5.3/assets/brand/bootstrap-social.png" > < meta property = "og:url" content = "https://getbootstrap.com/docs/5.3/components/badge/" > < meta property = "og:title" content = "Badges" > < meta property = "og:description" content = "Documentation and examples for badges, our small count and labeling component." > < meta property = "og:type" content = "article" > < meta property = "og:image" content = "https://getbootstrap.com/docs/5.3/assets/brand/bootstrap-social.png" > < meta property = "og:image:type" content = "image/png" > < meta property = "og:image:width" content = "2000" > < meta property = "og:image:height" content = "1000" > < script defer src = "https://cdn.usefathom.com/script.js" data-site = "ITUSEYJG" > < / script > < link rel = "stylesheet" href = "/docs/5.3/assets/_slug_.C9dNs6d9.css" > < / head > < body data-bs-spy = "scroll" data-bs-target = "#TableOfContents" > < div class = "skippy visually-hidden-focusable overflow-hidden" > < div class = "container-xl" > < a class = "d-inline-flex p-2 m-1" href = "#content" > Skip to main content< / a > < a class = "d-none d-md-inline-flex p-2 m-1" href = "#bd-docs-nav" >
Skip to docs navigation
< / a > < / div > < / div > < svg xmlns = "http://www.w3.org/2000/svg" class = "d-none" > < symbol id = "arrow-right" viewBox = "0 0 16 16" > < path fill-rule = "evenodd" d = "M1 8a.5.5 0 0 1 .5-.5h11.793l-3.147-3.146a.5.5 0 0 1 .708-.708l4 4a.5.5 0 0 1 0 .708l-4 4a.5.5 0 0 1-.708-.708L13.293 8.5H1.5A.5.5 0 0 1 1 8z" > < / path > < / symbol > < symbol id = "arrow-right-short" viewBox = "0 0 16 16" > < path fill-rule = "evenodd" d = "M4 8a.5.5 0 0 1 .5-.5h5.793L8.146 5.354a.5.5 0 1 1 .708-.708l3 3a.5.5 0 0 1 0 .708l-3 3a.5.5 0 0 1-.708-.708L10.293 8.5H4.5A.5.5 0 0 1 4 8" > < / path > < / symbol > < symbol id = "book-half" viewBox = "0 0 16 16" > < path d = "M8.5 2.687c.654-.689 1.782-.886 3.112-.752 1.234.124 2.503.523 3.388.893v9.923c-.918-.35-2.107-.692-3.287-.81-1.094-.111-2.278-.039-3.213.492V2.687zM8 1.783C7.015.936 5.587.81 4.287.94c-1.514.153-3.042.672-3.994 1.105A.5.5 0 0 0 0 2.5v11a.5.5 0 0 0 .707.455c.882-.4 2.303-.881 3.68-1.02 1.409-.142 2.59.087 3.223.877a.5.5 0 0 0 .78 0c.633-.79 1.814-1.019 3.222-.877 1.378.139 2.8.62 3.681 1.02A.5.5 0 0 0 16 13.5v-11a.5.5 0 0 0-.293-.455c-.952-.433-2.48-.952-3.994-1.105C10.413.809 8.985.936 8 1.783z" > < / path > < / symbol > < symbol id = "box-seam" viewBox = "0 0 16 16" > < path d = "M8.186 1.113a.5.5 0 0 0-.372 0L1.846 3.5l2.404.961L10.404 2l-2.218-.887zm3.564 1.426L5.596 5 8 5.961 14.154 3.5l-2.404-.961zm3.25 1.7-6.5 2.6v7.922l6.5-2.6V4.24zM7.5 14.762V6.838L1 4.239v7.923l6.5 2.6zM7.443.184a1.5 1.5 0 0 1 1.114 0l7.129 2.852A.5.5 0 0 1 16 3.5v8.662a1 1 0 0 1-.629.928l-7.185 2.874a.5.5 0 0 1-.372 0L.63 13.09a1 1 0 0 1-.63-.928V3.5a.5.5 0 0 1 .314-.464L7.443.184z" > < / path > < / symbol > < symbol id = "braces" viewBox = "0 0 16 16" > < path d = "M2.114 8.063V7.9c1.005-.102 1.497-.615 1.497-1.6V4.503c0-1.094.39-1.538 1.354-1.538h.273V2h-.376C3.25 2 2.49 2.759 2.49 4.352v1.524c0 1.094-.376 1.456-1.49 1.456v1.299c1.114 0 1.49.362 1.49 1.456v1.524c0 1.593.759 2.352 2.372 2.352h.376v-.964h-.273c-.964 0-1.354-.444-1.354-1.538V9.663c0-.984-.492-1.497-1.497-1.6zM13.886 7.9v.163c-1.005.103-1.497.616-1.497 1.6v1.798c0 1.094-.39 1.538-1.354 1.538h-.273v.964h.376c1.613 0 2.372-.759 2.372-2.352v-1.524c0-1.094.376-1.456 1.49-1.456V7.332c-1.114 0-1.49-.362-1.49-1.456V4.352C13.51 2.759 12.75 2 11.138 2h-.376v.964h.273c.964 0 1.354.444 1.354 1.538V6.3c0 .984.492 1.497 1.497 1.6z" > < / path > < / symbol > < symbol id = "braces-asterisk" viewBox = "0 0 16 16" > < path fill-rule = "evenodd" d = "M1.114 8.063V7.9c1.005-.102 1.497-.615 1.497-1.6V4.503c0-1.094.39-1.538 1.354-1.538h.273V2h-.376C2.25 2 1.49 2.759 1.49 4.352v1.524c0 1.094-.376 1.456-1.49 1.456v1.299c1.114 0 1.49.362 1.49 1.456v1.524c0 1.593.759 2.352 2.372 2.352h.376v-.964h-.273c-.964 0-1.354-.444-1.354-1.538V9.663c0-.984-.492-1.497-1.497-1.6ZM14.886 7.9v.164c-1.005.103-1.497.616-1.497 1.6v1.798c0 1.094-.39 1.538-1.354 1.538h-.273v.964h.376c1.613 0 2.372-.759 2.372-2.352v-1.524c0-1.094.376-1.456 1.49-1.456v-1.3c-1.114 0-1.49-.362-1.49-1.456V4.352C14.51 2.759 13.75 2 12.138 2h-.376v.964h.273c.964 0 1.354.444 1.354 1.538V6.3c0 .984.492 1.497 1.497 1.6ZM7.5 11.5V9.207l-1.621 1.621-.707-.707L6.792 8.5H4.5v-1h2.293L5.172 5.879l.707-.707L7.5 6.792V4.5h1v2.293l1.621-1.621.707.707L9.208 7.5H11.5v1H9.207l1.621 1.621-.707.707L8.5 9.208V11.5h-1Z" > < / path > < / symbol > < symbol id = "check2" viewBox = "0 0 16 16" > < path d = "M13.854 3.646a.5.5 0 0 1 0 .708l-7 7a.5.5 0 0 1-.708 0l-3.5-3.5a.5.5 0 1 1 .708-.708L6.5 10.293l6.646-6.647a.5.5 0 0 1 .708 0z" > < / path > < / symbol > < symbol id = "chevron-expand" viewBox = "0 0 16 16" > < path fill-rule = "evenodd" d = "M3.646 9.146a.5.5 0 0 1 .708 0L8 12.793l3.646-3.647a.5.5 0 0 1 .708.708l-4 4a.5.5 0 0 1-.708 0l-4-4a.5.5 0 0 1 0-.708zm0-2.292a.5.5 0 0 0 .708 0L8 3.207l3.646 3.647a.5.5 0 0 0 .708-.708l-4-4a.5.5 0 0 0-.708 0l-4 4a.5.5 0 0 0 0 .708z" > < / path > < / symbol > < symbol id = "circle-half" viewBox = "0 0 16 16" > < path d = "M8 15A7 7 0 1 0 8 1v14zm0 1A8 8 0 1 1 8 0a8 8 0 0 1 0 16z" > < / path > < / symbol > < symbol id = "clipboard" viewBox = "0 0 16 16" > < path d = "M4 1.5H3a2 2 0 0 0-2 2V14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V3.5a2 2 0 0 0-2-2h-1v1h1a1 1 0 0 1 1 1V14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3.5a1 1 0 0 1 1-1h1v-1z" > < / path > < path d = "M9.5 1a . 5 . 5 0 0 1 . 5 . 5
Docs
< / a > < / li > < li class = "nav-item col-6 col-lg-auto" > < a class = "nav-link py-2 px-0 px-lg-2" href = "/docs/5.3/examples/" > Examples < / a > < / li > < li class = "nav-item col-6 col-lg-auto" > < a class = "nav-link py-2 px-0 px-lg-2" href = "https://icons.getbootstrap.com/" target = "_blank" rel = "noopener" > Icons < / a > < / li > < li class = "nav-item col-6 col-lg-auto" > < a class = "nav-link py-2 px-0 px-lg-2" href = "https://themes.getbootstrap.com/" target = "_blank" rel = "noopener" > Themes < / a > < / li > < li class = "nav-item col-6 col-lg-auto" > < a class = "nav-link py-2 px-0 px-lg-2" href = "https://blog.getbootstrap.com/" target = "_blank" rel = "noopener" > Blog < / a > < / li > < / ul > < hr class = "d-lg-none text-white-50" > < ul class = "navbar-nav flex-row flex-wrap ms-md-auto" > < li class = "nav-item col-6 col-lg-auto" > < a class = "nav-link py-2 px-0 px-lg-2 nav-link py-2 px-0 px-lg-2" href = "https://github.com/twbs" target = "_blank" rel = "noopener" > < svg xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 512 499.36" role = "img" class = "navbar-nav-svg" height = "16" width = "16" > < title > GitHub< / title > < path fill = "currentColor" fill-rule = "evenodd" d = "M256 0C114.64 0 0 114.61 0 256c0 113.09 73.34 209 175.08 242.9 12.8 2.35 17.47-5.56 17.47-12.34 0-6.08-.22-22.18-.35-43.54-71.2 15.49-86.2-34.34-86.2-34.34-11.64-29.57-28.42-37.45-28.42-37.45-23.27-15.84 1.73-15.55 1.73-15.55 25.69 1.81 39.21 26.38 39.21 26.38 22.84 39.12 59.92 27.82 74.5 21.27 2.33-16.54 8.94-27.82 16.25-34.22-56.84-6.43-116.6-28.43-116.6-126.49 0-27.95 10-50.8 26.35-68.69-2.63-6.48-11.42-32.5 2.51-67.75 0 0 21.49-6.88 70.4 26.24a242.65 242.65 0 0 1 128.18 0c48.87-33.13 70.33-26.24 70.33-26.24 14 35.25 5.18 61.27 2.55 67.75 16.41 17.9 26.31 40.75 26.31 68.69 0 98.35-59.85 120-116.88 126.32 9.19 7.9 17.38 23.53 17.38 47.41 0 34.22-.31 61.83-.31 70.23 0 6.85 4.61 14.81 17.6 12.31C438.72 464.97 512 369.08 512 256.02 512 114.62 397.37 0 256 0z" > < / path > < / svg > < small class = "d-lg-none ms-2" > GitHub< / small > < / a > < / li > < li class = "nav-item col-6 col-lg-auto" > < a class = "nav-link py-2 px-0 px-lg-2 nav-link py-2 px-0 px-lg-2" href = "https://x.com/getbootstrap" target = "_blank" rel = "noopener" > < svg xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 1200 1227" role = "img" class = "navbar-nav-svg" height = "16" width = "16" > < title > X< / title > < path fill = "currentColor" d = "M714.163 519.284 1160.89 0h-105.86L667.137 450.887 357.328 0H0l468.492 681.821L0 1226.37h105.866l409.625-476.152 327.181 476.152H1200L714.137 519.284h.026ZM569.165 687.828l-47.468-67.894-377.686-540.24h162.604l304.797 435.991 47.468 67.894 396.2 566.721H892.476L569.165 687.854v-.026Z" > < / path > < / svg > < small class = "d-lg-none ms-2" > X< / small > < / a > < / li > < li class = "nav-item col-6 col-lg-auto" > < a class = "nav-link py-2 px-0 px-lg-2 nav-link py-2 px-0 px-lg-2" href = "https://opencollective.com/bootstrap" target = "_blank" rel = "noopener" > < svg xmlns = "http://www.w3.org/2000/svg" fill = "currentColor" fill-rule = "evenodd" viewBox = "0 0 40 41" role = "img" class = "navbar-nav-svg" height = "16" width = "16" > < title > Open Collective< / title > < path fill-opacity = ".4" d = "M32.8 21c0 2.4-.8 4.9-2 6.9l5.1 5.1c2.5-3.4 4.1-7.6 4.1-12 0-4.6-1.6-8.8-4-12.2L30.7 14c1.2 2 2 4.3 2 7z" > < / path > < path d = "M20 33.7a12.8 12.8 0 0 1 0-25.6c2.6 0 5 .7 7 2.1L32 5a20 20 0 1 0 .1 31.9l-5-5.2a13 13 0 0 1-7 2z" > < / path > < / svg > < small class = "d-lg-none ms-2" > Open Collective< / small > < / a > < / li > < li class = "nav-item py-2 py-lg-1 col-12 col-lg-auto" > < div class = "vr d-none d-lg-flex h-100 mx-lg-2 text-white" > < / div > < hr class = "d-lg-none my-2 text-white-50" > < / li > < li class = "nav-item dropdown" > < button type = "button" class = "btn btn-link nav-link py-2 px-0 px-lg-2 dropdown-toggle" data-bs-toggle = "dropdown" aria-expanded = "false" data-bs-display = "static" > < span class = "d-lg-none" aria-hidden = "true" > Bootstrap< / span > < span class = "visually-hidden" > Bootstrap < / span > v5.3 < span class = "visually-hidden" > (switch to other versions)< / span > < / button > < ul class = "dropdown-menu dropdown-menu-end" > < li > < h6 class = "dropdown-header" > v5 releases< / h6 > < / li > < li > < a class = "dropdown-item d-flex align-items-center justify-content-between active" aria-current = "true" href = "/do
Latest (5.3.x)
< svg class = "bi" aria-hidden = "true" > < use xlink:href = "#check2" > < / use > < / svg > < / a > < / li > < li > < a class = "dropdown-item" href = "https://getbootstrap.com/docs/5.2/components/badge/" >
v5.2.3
< / a > < / li > < li > < a class = "dropdown-item" href = "https://getbootstrap.com/docs/5.1/components/badge/" >
v5.1.3
< / a > < / li > < li > < a class = "dropdown-item" href = "https://getbootstrap.com/docs/5.0/components/badge/" >
v5.0.2
< / a > < / li > < li > < hr class = "dropdown-divider" > < / li > < li > < h6 class = "dropdown-header" > Previous releases< / h6 > < / li > < li > < a class = "dropdown-item" href = "https://getbootstrap.com/docs/4.6/" > v4.6.x< / a > < / li > < li > < a class = "dropdown-item" href = "https://getbootstrap.com/docs/3.4/" > v3.4.1< / a > < / li > < li > < a class = "dropdown-item" href = "https://getbootstrap.com/2.3.2/" > v2.3.2< / a > < / li > < li > < hr class = "dropdown-divider" > < / li > < li > < a class = "dropdown-item" href = "/docs/versions/" > All versions< / a > < / li > < / ul > < / li > < li class = "nav-item py-2 py-lg-1 col-12 col-lg-auto" > < div class = "vr d-none d-lg-flex h-100 mx-lg-2 text-white" > < / div > < hr class = "d-lg-none my-2 text-white-50" > < / li > < li class = "nav-item dropdown" > < button class = "btn btn-link nav-link px-0 px-lg-2 py-2 dropdown-toggle d-flex align-items-center" id = "bd-theme" type = "button" aria-expanded = "false" data-bs-toggle = "dropdown" data-bs-display = "static" aria-label = "Toggle theme (auto)" > < svg class = "bi my-1 theme-icon-active" aria-hidden = "true" > < use href = "#circle-half" > < / use > < / svg > < span class = "d-lg-none ms-2" id = "bd-theme-text" > Toggle theme< / span > < / button > < ul class = "dropdown-menu dropdown-menu-end" aria-labelledby = "bd-theme-text" > < li > < button type = "button" class = "dropdown-item d-flex align-items-center" data-bs-theme-value = "light" aria-pressed = "false" > < svg class = "bi me-2 opacity-50" aria-hidden = "true" > < use href = "#sun-fill" > < / use > < / svg >
Light
< svg class = "bi ms-auto d-none" aria-hidden = "true" > < use href = "#check2" > < / use > < / svg > < / button > < / li > < li > < button type = "button" class = "dropdown-item d-flex align-items-center" data-bs-theme-value = "dark" aria-pressed = "false" > < svg class = "bi me-2 opacity-50" aria-hidden = "true" > < use href = "#moon-stars-fill" > < / use > < / svg >
Dark
< svg class = "bi ms-auto d-none" aria-hidden = "true" > < use href = "#check2" > < / use > < / svg > < / button > < / li > < li > < button type = "button" class = "dropdown-item d-flex align-items-center active" data-bs-theme-value = "auto" aria-pressed = "true" > < svg class = "bi me-2 opacity-50" aria-hidden = "true" > < use href = "#circle-half" > < / use > < / svg >
Auto
< svg class = "bi ms-auto d-none" aria-hidden = "true" > < use href = "#check2" > < / use > < / svg > < / button > < / li > < / ul > < / li > < / ul > < / div > < / div > < / nav > < / header > < div class = "container-xxl bd-gutter mt-3 my-md-4 bd-layout" > < aside class = "bd-sidebar" > < div class = "offcanvas-lg offcanvas-start" tabindex = "-1" id = "bdSidebar" aria-labelledby = "bdSidebarOffcanvasLabel" > < div class = "offcanvas-header border-bottom" > < h5 class = "offcanvas-title" id = "bdSidebarOffcanvasLabel" > Browse docs< / h5 > < button type = "button" class = "btn-close" data-bs-dismiss = "offcanvas" aria-label = "Close" data-bs-target = "#bdSidebar" > < / button > < / div > < div class = "offcanvas-body" > < nav class = "bd-links w-100" id = "bd-docs-nav" aria-label = "Docs navigation" > < ul class = "bd-links-nav list-unstyled mb-0 pb-3 pb-md-2 pe-lg-2" > < li class = "bd-links-group py-2" > < strong class = "bd-links-heading d-flex w-100 align-items-center fw-semibold" > < svg class = "bi me-2" style = "color: var(--bs-indigo);" aria-hidden = "true" > < use xlink:href = "#book-half" > < / use > < / svg > Getting started < / strong > < ul class = "list-unstyled fw-normal pb-2 small" > < li > < a href = "/docs/5.3/getting-started/introduction" class = "bd-links-link d-inline-block rounded" > Introduction < / a > < / li > < li > < a href = "/docs/5.3/getting-started/download" class = "bd-links-link d-inline-block rounded" > Download < / a > < / li > < li > < a href = "/docs/5.3/getting-started/contents" class = "bd-links-link d-inline-block rounded" > Contents < / a > < / li > < li > < a href = "/docs/5.3/getting-started/browsers-devices" class = "bd-links-link d-inline-block rounded" > Browsers & devices < / a > < / li > < li > < a href = "/docs/5.3/getting-started/javascript" class = "bd-links-link d-inline-block rounded" > JavaScript < / a > < / li > < li > < a href = "/docs/5.3/getting-started/webpack" class = "bd-links-link d-inline-block rounded" > Webpack < / a > < / li > < li > < a href = "/docs/5.3/getting-started/parcel" class = "bd-links-link d-inline-block rounded" > Parcel < / a > < / li > < li > < a href = "/docs/5.3/getting-started/vite" class = "bd-links-link d-inline-block rounded" > Vite < / a > < / li > < li > < a href = "/docs/5.3/getting-started/accessibility" class = "bd-links-link d-inline-block rounded" > Accessibility < / a > < / li > < li > < a href = "/docs/5.3/getting-started/rfs" class = "bd-links-link d-inline-block rounded" > RFS < / a > < / li > < li > < a href = "/docs/5.3/getting-started/rtl" class = "bd-links-link d-inline-block rounded" > RTL < / a > < / li > < li > < a href = "/docs/5.3/getting-started/contribute" class = "bd-links-link d-inline-block rounded" > Contribute < / a > < / li > < / ul > < / li > < li class = "bd-links-group py-2" > < strong class = "bd-links-heading d-flex w-100 align-items-center fw-semibold" > < svg class = "bi me-2" style = "color: var(--bs-pink);" aria-hidden = "true" > < use xlink:href = "#palette2" > < / use > < / svg > Customize < / strong > < ul class = "list-unstyled fw-normal pb-2 small" > < li > < a href = "/docs/5.3/customize/overview" class = "bd-links-link d-inline-block rounded" > Overview < / a > < / li > < li > < a href = "/docs/5.3/customize/sass" class = "bd-links-link d-inline-block rounded" > Sass < / a > < / li > < li > < a href = "/docs/5.3/customize/options" class = "bd-links-link d-inline-block rounded" > Options < / a > < / li > < li > < a href = "/docs/5.3/customize/color" class = "bd-links-link d-inline-block rounded" > Color < / a > < / li > < li > < a href = "/docs/5.3/customize/color-modes" class = "bd-links-link d-inline-block rounded" > Color modes < / a > < / li > < li > < a href = "/docs/5.3/customize/components" class = "bd-links-link d-inline-block rounded" > Components < / a > < / li > < li > < a href = "/docs/5.3/customize/css-variables" class = "bd-links-link d-inline-block rounded" > CSS variables < / a > < / li > < li > < a href = "/docs/5.3/customize/optimize" class = "bd-links-link d-inline-block rounded" > Optimize < / a > < / li > < / ul > < / li > < li class = "bd-links-group py-2" > < strong class = "bd-links-heading d-flex w-100 align-items-center fw-semibold" > < svg class = "bi me-2" style = "color: var(--bs-teal);" aria-hidden = "true" > < use xlink:href = "#grid-fill" > < / use > < / svg > Layout < / strong > < ul class = "list-unstyled fw-normal pb-2 small" > < li > < a href = "/docs/5.3/layout/breakpoints" class = "bd-links-link d-inline-block rounded" > Breakpoints < / a > < / li > < li > < a href = "/docs/5.3/layou
View on GitHub
< / a > < / div > < h1 class = "bd-title mb-0" id = "content" > Badges< / h1 > < / div > < div class = "bd-subtitle" > < p > Documentation and examples for badges, our small count and labeling component.< / p >
< / div > < script async src = "https://cdn.carbonads.com/carbon.js?serve=CKYIKKJL&placement=getbootstrapcom" id = "_carbonads_js" > < / script > < / div > < div class = "bd-toc mt-3 mb-5 my-lg-0 mb-lg-5 px-sm-1 text-body-secondary" > < button class = "btn btn-link p-md-0 mb-2 mb-md-0 text-decoration-none bd-toc-toggle d-md-none" type = "button" data-bs-toggle = "collapse" data-bs-target = "#tocContents" aria-expanded = "false" aria-controls = "tocContents" >
On this page
< svg class = "bi d-md-none ms-2" aria-hidden = "true" > < use xlink:href = "#chevron-expand" > < / use > < / svg > < / button > < strong class = "d-none d-md-block h6 my-2 ms-3" > On this page< / strong > < hr class = "d-none d-md-block my-2 ms-3" > < div class = "collapse bd-toc-collapse" id = "tocContents" > < nav id = "TableOfContents" > < ul > < li > < a href = "#examples" > Examples< / a > < ul > < li > < a href = "#headings" > Headings< / a > < / li > < li > < a href = "#buttons" > Buttons< / a > < / li > < li > < a href = "#positioned" > Positioned< / a > < / li > < / ul > < / li > < li > < a href = "#background-colors" > Background colors< / a > < / li > < li > < a href = "#pill-badges" > Pill badges< / a > < / li > < li > < a href = "#css" > CSS< / a > < ul > < li > < a href = "#variables" > Variables< / a > < / li > < li > < a href = "#sass-variables" > Sass variables< / a > < / li > < / ul > < / li > < / ul > < / nav > < / div > < / div > < div class = "bd-content ps-lg-2" > < h2 id = "examples" > Examples< a class = "anchor-link" href = "#examples" > < / a > < / h2 >
2022-12-25 00:43:04 +08:00
< p > Badges scale to match the size of the immediate parent element by using relative font sizing and < code > em< / code > units. As of v5, badges no longer have focus or hover styles for links.< / p >
2025-04-15 02:26:20 +08:00
< h3 id = "headings" > Headings< a class = "anchor-link" href = "#headings" > < / a > < / h3 >
< div class = "bd-example-snippet bd-code-snippet" > < div class = "bd-example m-0 border-0" > < h1 > Example heading < span class = "badge text-bg-secondary" > New< / span > < / h1 >
2024-02-20 23:22:07 +08:00
< h2 > Example heading < span class = "badge text-bg-secondary" > New< / span > < / h2 >
< h3 > Example heading < span class = "badge text-bg-secondary" > New< / span > < / h3 >
< h4 > Example heading < span class = "badge text-bg-secondary" > New< / span > < / h4 >
< h5 > Example heading < span class = "badge text-bg-secondary" > New< / span > < / h5 >
2025-04-15 02:26:20 +08:00
< h6 > Example heading < span class = "badge text-bg-secondary" > New< / span > < / h6 > < / div > < div class = "d-flex align-items-center highlight-toolbar ps-3 pe-2 py-1 border-0 border-top border-bottom" > < small class = "font-monospace text-body-secondary text-uppercase" > html< / small > < div class = "d-flex ms-auto" > < button type = "button" class = "btn-edit text-nowrap" title = "Try it on StackBlitz" > < svg class = "bi" aria-hidden = "true" > < use xlink:href = "#lightning-charge-fill" > < / use > < / svg > < / button > < button type = "button" class = "btn-clipboard mt-0 me-0" title = "Copy to clipboard" > < svg class = "bi" aria-hidden = "true" > < use xlink:href = "#clipboard" > < / use > < / svg > < / button > < / div > < / div > < div class = "highlight" > < pre class = "language-html" > < code class = "language-html" > < span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > h1< / span > < span class = "token punctuation" > >< / span > < / span > Example heading < span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > span< / span > < span class = "token attr-name" > class< / span > < span class = "token attr-value" > < span class = "token punctuation attr-equals" > =< / span > < span class = "token punctuation" > "< / span > badge text-bg-secondary< span class = "token punctuation" > "< / span > < / span > < span class = "token punctuation" > >< / span > < / span > New< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < /< / span > span< / span > < span class = "token punctuation" > >< / span > < / span > < span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < /< / span > h1< / span > < span class = "token punctuation" > >< / span > < / span >
< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > h2< / span > < span class = "token punctuation" > >< / span > < / span > Example heading < span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > span< / span > < span class = "token attr-name" > class< / span > < span class = "token attr-value" > < span class = "token punctuation attr-equals" > =< / span > < span class = "token punctuation" > "< / span > badge text-bg-secondary< span class = "token punctuation" > "< / span > < / span > < span class = "token punctuation" > >< / span > < / span > New< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < /< / span > span< / span > < span class = "token punctuation" > >< / span > < / span > < span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < /< / span > h2< / span > < span class = "token punctuation" > >< / span > < / span >
< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > h3< / span > < span class = "token punctuation" > >< / span > < / span > Example heading < span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > span< / span > < span class = "token attr-name" > class< / span > < span class = "token attr-value" > < span class = "token punctuation attr-equals" > =< / span > < span class = "token punctuation" > "< / span > badge text-bg-secondary< span class = "token punctuation" > "< / span > < / span > < span class = "token punctuation" > >< / span > < / span > New< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < /< / span > span< / span > < span class = "token punctuation" > >< / span > < / span > < span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < /< / span > h3< / span > < span class = "token punctuation" > >< / span > < / span >
< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > h4< / span > < span class = "token punctuation" > >< / span > < / span > Example heading < span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > span< / span > < span class = "token attr-name" > class< / span > < span class = "token attr-value" > < span class = "token punctuation attr-equals" > =< / span > < span class = "token punctuation" > "< / span > badge text-bg-secondary< span class = "token punctuation" > "< / span > < / span > < span class = "token punctuation" > >< / span > < / span > New< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < /< / span > span< / span > < span class = "token punctuation" > >< / span > < / span > < span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < /< / span > h4< / span > < span class = "token punctuation" > >< / span > < / span >
< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > h5< / span > < span class = "token punctuation" > >< / span > < / span > Example heading < span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > span< / span > < span class = "token attr-name" > class< / span > < span class = "token attr-value" > < span class = "token punctuation attr-equals" > =< / span > < span class = "token punctuation" > "< / span > badge text-bg-secondary< span class = "token punctuation" > "< / span > < / span > < span class = "token punctuation" > >< / span > < / span > New< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < /< / span > span< / span > < span class = "token punctuation" > >< / span > < / span > < span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < /< / span > h5< / span > < span class = "token punctuation" > >< / span > < / span >
< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > h6< / span > < span class = "token punctuation" > >< / span > < / span > Example heading < span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > span< / span > < span class = "token attr-name" > class< / span > < span class = "token attr-value" > < span class = "token punctuation attr-equals" > =< / span > < span class = "token punctuation" > "< / span > badge text-bg-secondary< span class = "token punctuation" > "< / span > < / span > < span class = "token punctuation" > >< / span > < / span > New< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < /< / span > span< / span > < span class = "token punctuation" > >< / span > < / span > < span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < /< / span > h6< / span > < span class = "token punctuation" > >< / span > < / span > < / code > < / pre > < / div > < / div >
< h3 id = "buttons" > Buttons< a class = "anchor-link" href = "#buttons" > < / a > < / h3 >
2022-12-25 00:43:04 +08:00
< p > Badges can be used as part of links or buttons to provide a counter.< / p >
2025-04-15 02:26:20 +08:00
< div class = "bd-example-snippet bd-code-snippet" > < div class = "bd-example m-0 border-0" > < button type = "button" class = "btn btn-primary" >
2022-12-25 00:43:04 +08:00
Notifications < span class = "badge text-bg-secondary" > 4< / span >
2025-04-15 02:26:20 +08:00
< / button > < / div > < div class = "d-flex align-items-center highlight-toolbar ps-3 pe-2 py-1 border-0 border-top border-bottom" > < small class = "font-monospace text-body-secondary text-uppercase" > html< / small > < div class = "d-flex ms-auto" > < button type = "button" class = "btn-edit text-nowrap" title = "Try it on StackBlitz" > < svg class = "bi" aria-hidden = "true" > < use xlink:href = "#lightning-charge-fill" > < / use > < / svg > < / button > < button type = "button" class = "btn-clipboard mt-0 me-0" title = "Copy to clipboard" > < svg class = "bi" aria-hidden = "true" > < use xlink:href = "#clipboard" > < / use > < / svg > < / button > < / div > < / div > < div class = "highlight" > < pre class = "language-html" > < code class = "language-html" > < span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > button< / span > < span class = "token attr-name" > type< / span > < span class = "token attr-value" > < span class = "token punctuation attr-equals" > =< / span > < span class = "token punctuation" > "< / span > button< span class = "token punctuation" > "< / span > < / span > < span class = "token attr-name" > class< / span > < span class = "token attr-value" > < span class = "token punctuation attr-equals" > =< / span > < span class = "token punctuation" > "< / span > btn btn-primary< span class = "token punctuation" > "< / span > < / span > < span class = "token punctuation" > >< / span > < / span >
Notifications < span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > span< / span > < span class = "token attr-name" > class< / span > < span class = "token attr-value" > < span class = "token punctuation attr-equals" > =< / span > < span class = "token punctuation" > "< / span > badge text-bg-secondary< span class = "token punctuation" > "< / span > < / span > < span class = "token punctuation" > >< / span > < / span > 4< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < /< / span > span< / span > < span class = "token punctuation" > >< / span > < / span >
< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < /< / span > button< / span > < span class = "token punctuation" > >< / span > < / span > < / code > < / pre > < / div > < / div >
2022-12-25 00:43:04 +08:00
< p > Note that depending on how they are used, badges may be confusing for users of screen readers and similar assistive technologies. While the styling of badges provides a visual cue as to their purpose, these users will simply be presented with the content of the badge. Depending on the specific situation, these badges may seem like random additional words or numbers at the end of a sentence, link, or button.< / p >
2025-04-15 02:26:20 +08:00
< p > Unless the context is clear (as with the “Notifications” example, where it is understood that the “4” is the number of notifications), consider including additional context with a visually hidden piece of additional text.< / p >
< h3 id = "positioned" > Positioned< a class = "anchor-link" href = "#positioned" > < / a > < / h3 >
2022-12-25 00:43:04 +08:00
< p > Use utilities to modify a < code > .badge< / code > and position it in the corner of a link or button.< / p >
2025-04-15 02:26:20 +08:00
< div class = "bd-example-snippet bd-code-snippet" > < div class = "bd-example m-0 border-0" > < button type = "button" class = "btn btn-primary position-relative" >
2022-12-25 00:43:04 +08:00
Inbox
< span class = "position-absolute top-0 start-100 translate-middle badge rounded-pill bg-danger" >
99+
< span class = "visually-hidden" > unread messages< / span >
< / span >
2025-04-15 02:26:20 +08:00
< / button > < / div > < div class = "d-flex align-items-center highlight-toolbar ps-3 pe-2 py-1 border-0 border-top border-bottom" > < small class = "font-monospace text-body-secondary text-uppercase" > html< / small > < div class = "d-flex ms-auto" > < button type = "button" class = "btn-edit text-nowrap" title = "Try it on StackBlitz" > < svg class = "bi" aria-hidden = "true" > < use xlink:href = "#lightning-charge-fill" > < / use > < / svg > < / button > < button type = "button" class = "btn-clipboard mt-0 me-0" title = "Copy to clipboard" > < svg class = "bi" aria-hidden = "true" > < use xlink:href = "#clipboard" > < / use > < / svg > < / button > < / div > < / div > < div class = "highlight" > < pre class = "language-html" > < code class = "language-html" > < span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > button< / span > < span class = "token attr-name" > type< / span > < span class = "token attr-value" > < span class = "token punctuation attr-equals" > =< / span > < span class = "token punctuation" > "< / span > button< span class = "token punctuation" > "< / span > < / span > < span class = "token attr-name" > class< / span > < span class = "token attr-value" > < span class = "token punctuation attr-equals" > =< / span > < span class = "token punctuation" > "< / span > btn btn-primary position-relative< span class = "token punctuation" > "< / span > < / span > < span class = "token punctuation" > >< / span > < / span >
Inbox
< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > span< / span > < span class = "token attr-name" > class< / span > < span class = "token attr-value" > < span class = "token punctuation attr-equals" > =< / span > < span class = "token punctuation" > "< / span > position-absolute top-0 start-100 translate-middle badge rounded-pill bg-danger< span class = "token punctuation" > "< / span > < / span > < span class = "token punctuation" > >< / span > < / span >
99+
< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > span< / span > < span class = "token attr-name" > class< / span > < span class = "token attr-value" > < span class = "token punctuation attr-equals" > =< / span > < span class = "token punctuation" > "< / span > visually-hidden< span class = "token punctuation" > "< / span > < / span > < span class = "token punctuation" > >< / span > < / span > unread messages< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < /< / span > span< / span > < span class = "token punctuation" > >< / span > < / span >
< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < /< / span > span< / span > < span class = "token punctuation" > >< / span > < / span >
< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < /< / span > button< / span > < span class = "token punctuation" > >< / span > < / span > < / code > < / pre > < / div > < / div >
2022-12-25 00:43:04 +08:00
< p > You can also replace the < code > .badge< / code > class with a few more utilities without a count for a more generic indicator.< / p >
2025-04-15 02:26:20 +08:00
< div class = "bd-example-snippet bd-code-snippet" > < div class = "bd-example m-0 border-0" > < button type = "button" class = "btn btn-primary position-relative" >
2022-12-25 00:43:04 +08:00
Profile
< span class = "position-absolute top-0 start-100 translate-middle p-2 bg-danger border border-light rounded-circle" >
< span class = "visually-hidden" > New alerts< / span >
< / span >
2025-04-15 02:26:20 +08:00
< / button > < / div > < div class = "d-flex align-items-center highlight-toolbar ps-3 pe-2 py-1 border-0 border-top border-bottom" > < small class = "font-monospace text-body-secondary text-uppercase" > html< / small > < div class = "d-flex ms-auto" > < button type = "button" class = "btn-edit text-nowrap" title = "Try it on StackBlitz" > < svg class = "bi" aria-hidden = "true" > < use xlink:href = "#lightning-charge-fill" > < / use > < / svg > < / button > < button type = "button" class = "btn-clipboard mt-0 me-0" title = "Copy to clipboard" > < svg class = "bi" aria-hidden = "true" > < use xlink:href = "#clipboard" > < / use > < / svg > < / button > < / div > < / div > < div class = "highlight" > < pre class = "language-html" > < code class = "language-html" > < span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > button< / span > < span class = "token attr-name" > type< / span > < span class = "token attr-value" > < span class = "token punctuation attr-equals" > =< / span > < span class = "token punctuation" > "< / span > button< span class = "token punctuation" > "< / span > < / span > < span class = "token attr-name" > class< / span > < span class = "token attr-value" > < span class = "token punctuation attr-equals" > =< / span > < span class = "token punctuation" > "< / span > btn btn-primary position-relative< span class = "token punctuation" > "< / span > < / span > < span class = "token punctuation" > >< / span > < / span >
Profile
< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > span< / span > < span class = "token attr-name" > class< / span > < span class = "token attr-value" > < span class = "token punctuation attr-equals" > =< / span > < span class = "token punctuation" > "< / span > position-absolute top-0 start-100 translate-middle p-2 bg-danger border border-light rounded-circle< span class = "token punctuation" > "< / span > < / span > < span class = "token punctuation" > >< / span > < / span >
< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > span< / span > < span class = "token attr-name" > class< / span > < span class = "token attr-value" > < span class = "token punctuation attr-equals" > =< / span > < span class = "token punctuation" > "< / span > visually-hidden< span class = "token punctuation" > "< / span > < / span > < span class = "token punctuation" > >< / span > < / span > New alerts< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < /< / span > span< / span > < span class = "token punctuation" > >< / span > < / span >
< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < /< / span > span< / span > < span class = "token punctuation" > >< / span > < / span >
< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < /< / span > button< / span > < span class = "token punctuation" > >< / span > < / span > < / code > < / pre > < / div > < / div >
< h2 id = "background-colors" > Background colors< a class = "anchor-link" href = "#background-colors" > < / a > < / h2 >
2022-12-25 00:43:04 +08:00
< small class = "d-inline-flex mb-3 px-2 py-1 fw-semibold text-success-emphasis bg-success-subtle border border-success-subtle rounded-2" > Added in v5.2.0< / small >
2025-04-15 02:26:20 +08:00
< p > Set a < code > background-color< / code > with contrasting foreground < code > color< / code > with < a href = "/docs/5.3/helpers/color-background" > our < code > .text-bg-{color}< / code > helpers< / a > . Previously it was required to manually pair your choice of < a href = "/docs/5.3/utilities/colors" > < code > .text-{color}< / code > < / a > and < a href = "/docs/5.3/utilities/background" > < code > .bg-{color}< / code > < / a > utilities for styling, which you still may use if you prefer.< / p >
< div class = "bd-example-snippet bd-code-snippet" > < div class = "bd-example m-0 border-0" > < span class = "badge text-bg-primary" > Primary< / span >
2022-12-25 00:43:04 +08:00
< span class = "badge text-bg-secondary" > Secondary< / span >
< span class = "badge text-bg-success" > Success< / span >
< span class = "badge text-bg-danger" > Danger< / span >
< span class = "badge text-bg-warning" > Warning< / span >
< span class = "badge text-bg-info" > Info< / span >
< span class = "badge text-bg-light" > Light< / span >
2025-04-15 02:26:20 +08:00
< span class = "badge text-bg-dark" > Dark< / span > < / div > < div class = "d-flex align-items-center highlight-toolbar ps-3 pe-2 py-1 border-0 border-top border-bottom" > < small class = "font-monospace text-body-secondary text-uppercase" > html< / small > < div class = "d-flex ms-auto" > < button type = "button" class = "btn-edit text-nowrap" title = "Try it on StackBlitz" > < svg class = "bi" aria-hidden = "true" > < use xlink:href = "#lightning-charge-fill" > < / use > < / svg > < / button > < button type = "button" class = "btn-clipboard mt-0 me-0" title = "Copy to clipboard" > < svg class = "bi" aria-hidden = "true" > < use xlink:href = "#clipboard" > < / use > < / svg > < / button > < / div > < / div > < div class = "highlight" > < pre class = "language-html" > < code class = "language-html" > < span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > span< / span > < span class = "token attr-name" > class< / span > < span class = "token attr-value" > < span class = "token punctuation attr-equals" > =< / span > < span class = "token punctuation" > "< / span > badge text-bg-primary< span class = "token punctuation" > "< / span > < / span > < span class = "token punctuation" > >< / span > < / span > Primary< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < /< / span > span< / span > < span class = "token punctuation" > >< / span > < / span >
< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > span< / span > < span class = "token attr-name" > class< / span > < span class = "token attr-value" > < span class = "token punctuation attr-equals" > =< / span > < span class = "token punctuation" > "< / span > badge text-bg-secondary< span class = "token punctuation" > "< / span > < / span > < span class = "token punctuation" > >< / span > < / span > Secondary< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < /< / span > span< / span > < span class = "token punctuation" > >< / span > < / span >
< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > span< / span > < span class = "token attr-name" > class< / span > < span class = "token attr-value" > < span class = "token punctuation attr-equals" > =< / span > < span class = "token punctuation" > "< / span > badge text-bg-success< span class = "token punctuation" > "< / span > < / span > < span class = "token punctuation" > >< / span > < / span > Success< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < /< / span > span< / span > < span class = "token punctuation" > >< / span > < / span >
< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > span< / span > < span class = "token attr-name" > class< / span > < span class = "token attr-value" > < span class = "token punctuation attr-equals" > =< / span > < span class = "token punctuation" > "< / span > badge text-bg-danger< span class = "token punctuation" > "< / span > < / span > < span class = "token punctuation" > >< / span > < / span > Danger< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < /< / span > span< / span > < span class = "token punctuation" > >< / span > < / span >
< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > span< / span > < span class = "token attr-name" > class< / span > < span class = "token attr-value" > < span class = "token punctuation attr-equals" > =< / span > < span class = "token punctuation" > "< / span > badge text-bg-warning< span class = "token punctuation" > "< / span > < / span > < span class = "token punctuation" > >< / span > < / span > Warning< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < /< / span > span< / span > < span class = "token punctuation" > >< / span > < / span >
< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > span< / span > < span class = "token attr-name" > class< / span > < span class = "token attr-value" > < span class = "token punctuation attr-equals" > =< / span > < span class = "token punctuation" > "< / span > badge text-bg-info< span class = "token punctuation" > "< / span > < / span > < span class = "token punctuation" > >< / span > < / span > Info< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < /< / span > span< / span > < span class = "token punctuation" > >< / span > < / span >
< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > span< / span > < span class = "token attr-name" > class< / span > < span class = "token attr-value" > < span class = "token punctuation attr-equals" > =< / span > < span class = "token punctuation" > "< / span > badge text-bg-light< span class = "token punctuation" > "< / span > < / span > < span class = "token punctuation" > >< / span > < / span > Light< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < /< / span > span< / span > < span class = "token punctuation" > >< / span > < / span >
< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > span< / span > < span class = "token attr-name" > class< / span > < span class = "token attr-value" > < span class = "token punctuation attr-equals" > =< / span > < span class = "token punctuation" > "< / span > badge text-bg-dark< span class = "token punctuation" > "< / span > < / span > < span class = "token punctuation" > >< / span > < / span > Dark< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < /< / span > span< / span > < span class = "token punctuation" > >< / span > < / span > < / code > < / pre > < / div > < / div >
< div class = "bd-callout bd-callout-info" > < p > < strong > Accessibility tip:< / strong > Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies like screen readers. Please ensure the meaning is obvious from the content itself (e.g., the visible text with a < a href = "/docs/5.3/getting-started/accessibility/#color-contrast" > < em > sufficient< / em > color contrast< / a > ) or is included through alternative means, such as additional text hidden with the < code > .visually-hidden< / code > class.< / p > < / div >
< h2 id = "pill-badges" > Pill badges< a class = "anchor-link" href = "#pill-badges" > < / a > < / h2 >
2022-12-25 00:43:04 +08:00
< p > Use the < code > .rounded-pill< / code > utility class to make badges more rounded with a larger < code > border-radius< / code > .< / p >
2025-04-15 02:26:20 +08:00
< div class = "bd-example-snippet bd-code-snippet" > < div class = "bd-example m-0 border-0" > < span class = "badge rounded-pill text-bg-primary" > Primary< / span >
2022-12-25 00:43:04 +08:00
< span class = "badge rounded-pill text-bg-secondary" > Secondary< / span >
< span class = "badge rounded-pill text-bg-success" > Success< / span >
< span class = "badge rounded-pill text-bg-danger" > Danger< / span >
< span class = "badge rounded-pill text-bg-warning" > Warning< / span >
< span class = "badge rounded-pill text-bg-info" > Info< / span >
< span class = "badge rounded-pill text-bg-light" > Light< / span >
2025-04-15 02:26:20 +08:00
< span class = "badge rounded-pill text-bg-dark" > Dark< / span > < / div > < div class = "d-flex align-items-center highlight-toolbar ps-3 pe-2 py-1 border-0 border-top border-bottom" > < small class = "font-monospace text-body-secondary text-uppercase" > html< / small > < div class = "d-flex ms-auto" > < button type = "button" class = "btn-edit text-nowrap" title = "Try it on StackBlitz" > < svg class = "bi" aria-hidden = "true" > < use xlink:href = "#lightning-charge-fill" > < / use > < / svg > < / button > < button type = "button" class = "btn-clipboard mt-0 me-0" title = "Copy to clipboard" > < svg class = "bi" aria-hidden = "true" > < use xlink:href = "#clipboard" > < / use > < / svg > < / button > < / div > < / div > < div class = "highlight" > < pre class = "language-html" > < code class = "language-html" > < span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > span< / span > < span class = "token attr-name" > class< / span > < span class = "token attr-value" > < span class = "token punctuation attr-equals" > =< / span > < span class = "token punctuation" > "< / span > badge rounded-pill text-bg-primary< span class = "token punctuation" > "< / span > < / span > < span class = "token punctuation" > >< / span > < / span > Primary< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < /< / span > span< / span > < span class = "token punctuation" > >< / span > < / span >
< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > span< / span > < span class = "token attr-name" > class< / span > < span class = "token attr-value" > < span class = "token punctuation attr-equals" > =< / span > < span class = "token punctuation" > "< / span > badge rounded-pill text-bg-secondary< span class = "token punctuation" > "< / span > < / span > < span class = "token punctuation" > >< / span > < / span > Secondary< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < /< / span > span< / span > < span class = "token punctuation" > >< / span > < / span >
< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > span< / span > < span class = "token attr-name" > class< / span > < span class = "token attr-value" > < span class = "token punctuation attr-equals" > =< / span > < span class = "token punctuation" > "< / span > badge rounded-pill text-bg-success< span class = "token punctuation" > "< / span > < / span > < span class = "token punctuation" > >< / span > < / span > Success< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < /< / span > span< / span > < span class = "token punctuation" > >< / span > < / span >
< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > span< / span > < span class = "token attr-name" > class< / span > < span class = "token attr-value" > < span class = "token punctuation attr-equals" > =< / span > < span class = "token punctuation" > "< / span > badge rounded-pill text-bg-danger< span class = "token punctuation" > "< / span > < / span > < span class = "token punctuation" > >< / span > < / span > Danger< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < /< / span > span< / span > < span class = "token punctuation" > >< / span > < / span >
< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > span< / span > < span class = "token attr-name" > class< / span > < span class = "token attr-value" > < span class = "token punctuation attr-equals" > =< / span > < span class = "token punctuation" > "< / span > badge rounded-pill text-bg-warning< span class = "token punctuation" > "< / span > < / span > < span class = "token punctuation" > >< / span > < / span > Warning< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < /< / span > span< / span > < span class = "token punctuation" > >< / span > < / span >
< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > span< / span > < span class = "token attr-name" > class< / span > < span class = "token attr-value" > < span class = "token punctuation attr-equals" > =< / span > < span class = "token punctuation" > "< / span > badge rounded-pill text-bg-info< span class = "token punctuation" > "< / span > < / span > < span class = "token punctuation" > >< / span > < / span > Info< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < /< / span > span< / span > < span class = "token punctuation" > >< / span > < / span >
< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > span< / span > < span class = "token attr-name" > class< / span > < span class = "token attr-value" > < span class = "token punctuation attr-equals" > =< / span > < span class = "token punctuation" > "< / span > badge rounded-pill text-bg-light< span class = "token punctuation" > "< / span > < / span > < span class = "token punctuation" > >< / span > < / span > Light< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < /< / span > span< / span > < span class = "token punctuation" > >< / span > < / span >
< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > span< / span > < span class = "token attr-name" > class< / span > < span class = "token attr-value" > < span class = "token punctuation attr-equals" > =< / span > < span class = "token punctuation" > "< / span > badge rounded-pill text-bg-dark< span class = "token punctuation" > "< / span > < / span > < span class = "token punctuation" > >< / span > < / span > Dark< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < /< / span > span< / span > < span class = "token punctuation" > >< / span > < / span > < / code > < / pre > < / div > < / div >
< h2 id = "css" > CSS< a class = "anchor-link" href = "#css" > < / a > < / h2 >
< h3 id = "variables" > Variables< a class = "anchor-link" href = "#variables" > < / a > < / h3 >
2022-12-25 00:43:04 +08:00
< small class = "d-inline-flex mb-3 px-2 py-1 fw-semibold text-success-emphasis bg-success-subtle border border-success-subtle rounded-2" > Added in v5.2.0< / small >
2025-04-15 02:26:20 +08:00
< p > As part of Bootstrap’ s evolving CSS variables approach, badges now use local CSS variables on < code > .badge< / code > for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.< / p >
< script type = "module" src = "/docs/5.3/assets/Code.astro_astro_type_script_index_0_lang.5BTJN8ix.js" > < / script > < div class = "bd-code-snippet bd-example-snippet bd-file-ref" > < div class = "d-flex align-items-center highlight-toolbar ps-3 pe-2 py-1 border-bottom" > < a class = "font-monospace link-secondary link-underline-secondary link-underline-opacity-0 link-underline-opacity-100-hover small" href = "https://github.com/twbs/bootstrap/blob/v5.3.5/scss/_badge.scss" > scss/_badge.scss < / a > < div class = "d-flex ms-auto" > < button type = "button" class = "btn-clipboard mt-0 me-0" title = "Copy to clipboard" > < svg class = "bi" aria-hidden = "true" > < use xlink:href = "#clipboard" > < / use > < / svg > < / button > < / div > < / div > < div class = "highlight" > < pre class = "language-scss" > < code class = "language-scss" > < span class = "token property" > --< span class = "token variable" > #{$prefix}< / span > badge-padding-x< / span > < span class = "token punctuation" > :< / span > < span class = "token variable" > #{$badge-padding-x}< / span > < span class = "token punctuation" > ;< / span >
< span class = "token property" > --< span class = "token variable" > #{$prefix}< / span > badge-padding-y< / span > < span class = "token punctuation" > :< / span > < span class = "token variable" > #{$badge-padding-y}< / span > < span class = "token punctuation" > ;< / span >
< span class = "token keyword" > @include< / span > < span class = "token function" > rfs< / span > < span class = "token punctuation" > (< / span > < span class = "token variable" > $badge-font-size< / span > < span class = "token punctuation" > ,< / span > --< span class = "token variable" > #{$prefix}< / span > badge-font-size< span class = "token punctuation" > )< / span > < span class = "token punctuation" > ;< / span >
< span class = "token property" > --< span class = "token variable" > #{$prefix}< / span > badge-font-weight< / span > < span class = "token punctuation" > :< / span > < span class = "token variable" > #{$badge-font-weight}< / span > < span class = "token punctuation" > ;< / span >
< span class = "token property" > --< span class = "token variable" > #{$prefix}< / span > badge-color< / span > < span class = "token punctuation" > :< / span > < span class = "token variable" > #{$badge-color}< / span > < span class = "token punctuation" > ;< / span >
< span class = "token property" > --< span class = "token variable" > #{$prefix}< / span > badge-border-radius< / span > < span class = "token punctuation" > :< / span > < span class = "token variable" > #{$badge-border-radius}< / span > < span class = "token punctuation" > ;< / span >
< / code > < / pre > < / div > < / div >
< h3 id = "sass-variables" > Sass variables< a class = "anchor-link" href = "#sass-variables" > < / a > < / h3 >
< div class = "bd-code-snippet bd-example-snippet bd-file-ref" > < div class = "d-flex align-items-center highlight-toolbar ps-3 pe-2 py-1 border-bottom" > < a class = "font-monospace link-secondary link-underline-secondary link-underline-opacity-0 link-underline-opacity-100-hover small" href = "https://github.com/twbs/bootstrap/blob/v5.3.5/scss/_variables.scss" > scss/_variables.scss < / a > < div class = "d-flex ms-auto" > < button type = "button" class = "btn-clipboard mt-0 me-0" title = "Copy to clipboard" > < svg class = "bi" aria-hidden = "true" > < use xlink:href = "#clipboard" > < / use > < / svg > < / button > < / div > < / div > < div class = "highlight" > < pre class = "language-scss" > < code class = "language-scss" > < span class = "token property" > < span class = "token variable" > $badge-font-size< / span > < / span > < span class = "token punctuation" > :< / span > .75em< span class = "token punctuation" > ;< / span >
< span class = "token property" > < span class = "token variable" > $badge-font-weight< / span > < / span > < span class = "token punctuation" > :< / span > < span class = "token variable" > $font-weight-bold< / span > < span class = "token punctuation" > ;< / span >
< span class = "token property" > < span class = "token variable" > $badge-color< / span > < / span > < span class = "token punctuation" > :< / span > < span class = "token variable" > $white< / span > < span class = "token punctuation" > ;< / span >
< span class = "token property" > < span class = "token variable" > $badge-padding-y< / span > < / span > < span class = "token punctuation" > :< / span > .35em< span class = "token punctuation" > ;< / span >
< span class = "token property" > < span class = "token variable" > $badge-padding-x< / span > < / span > < span class = "token punctuation" > :< / span > .65em< span class = "token punctuation" > ;< / span >
< span class = "token property" > < span class = "token variable" > $badge-border-radius< / span > < / span > < span class = "token punctuation" > :< / span > < span class = "token function" > var< / span > < span class = "token punctuation" > (< / span > --< span class = "token variable" > #{$prefix}< / span > border-radius< span class = "token punctuation" > )< / span > < span class = "token punctuation" > ;< / span >
< / code > < / pre > < / div > < / div > < / div > < / main > < / div > < footer class = "bd-footer py-4 py-md-5 mt-5 bg-body-tertiary" > < div class = "container py-4 py-md-5 px-4 px-md-3 text-body-secondary" > < div class = "row" > < div class = "col-lg-3 mb-3" > < a class = "d-inline-flex align-items-center mb-2 text-body-emphasis text-decoration-none" href = "/" aria-label = "Bootstrap" > < svg xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 118 94" role = "img" class = "d-block me-2" height = "32" width = "40" > < title > Bootstrap< / title > < path fill-rule = "evenodd" clip-rule = "evenodd" d = "M24.509 0c-6.733 0-11.715 5.893-11.492 12.284.214 6.14-.064 14.092-2.066 20.577C8.943 39.365 5.547 43.485 0 44.014v5.972c5.547.529 8.943 4.649 10.951 11.153 2.002 6.485 2.28 14.437 2.066 20.577C12.794 88.106 17.776 94 24.51 94H93.5c6.733 0 11.714-5.893 11.491-12.284-.214-6.14.064-14.092 2.066-20.577 2.009-6.504 5.396-10.624 10.943-11.153v-5.972c-5.547-.529-8.934-4.649-10.943-11.153-2.002-6.484-2.28-14.437-2.066-20.577C105.214 5.894 100.233 0 93.5 0H24.508zM80 57.863C80 66.663 73.436 72 62.543 72H44a2 2 0 01-2-2V24a2 2 0 012-2h18.437c9.083 0 15.044 4.92 15.044 12.474 0 5.302-4.01 10.049-9.119 10.88v.277C75.317 46.394 80 51.21 80 57.863zM60.521 28.34H49.948v14.934h8.905c6.884 0 10.68-2.772 10.68-7.727 0-4.643-3.264-7.207-9.012-7.207zM49.948 49.2v16.458H60.91c7.167 0 10.964-2.876 10.964-8.281 0-5.406-3.903-8.178-11.425-8.178H49.948z" fill = "currentColor" > < / path > < / svg > < span class = "fs-5" > Bootstrap< / span > < / a > < ul class = "list-unstyled small" > < li class = "mb-2" >
Designed and built with all the love in the world by the < a href = "/docs/5.3/about/team" > Bootstrap team< / a > with the help of < a href = "https://github.com/twbs/bootstrap/graphs/contributors" > our contributors< / a > .
< / li > < li class = "mb-2" >
Code licensed < a href = "https://github.com/twbs/bootstrap/blob/main/LICENSE" target = "_blank" rel = "license noopener" > MIT< / a > , docs < a href = "https://creativecommons.org/licenses/by/3.0/" target = "_blank" rel = "license noopener" > CC BY 3.0< / a > .
< / li > < li class = "mb-2" > Currently v5.3.5.< / li > < / ul > < / div > < div class = "col-6 col-lg-2 offset-lg-1 mb-3" > < h5 > Links< / h5 > < ul class = "list-unstyled" > < li class = "mb-2" > < a href = "/" > Home< / a > < / li > < li class = "mb-2" > < a href = "/docs/5.3/" > Docs< / a > < / li > < li class = "mb-2" > < a href = "/docs/5.3/examples" > Examples< / a > < / li > < li class = "mb-2" > < a href = "https://icons.getbootstrap.com/" > Icons< / a > < / li > < li class = "mb-2" > < a href = "https://themes.getbootstrap.com/" > Themes< / a > < / li > < li class = "mb-2" > < a href = "https://blog.getbootstrap.com/" > Blog< / a > < / li > < li class = "mb-2" > < a href = "https://cottonbureau.com/people/bootstrap" target = "_blank" rel = "noopener" > Swag Store< / a > < / li > < / ul > < / div > < div class = "col-6 col-lg-2 mb-3" > < h5 > Guides< / h5 > < ul class = "list-unstyled" > < li class = "mb-2" > < a href = "/docs/5.3/getting-started" > Getting started< / a > < / li > < li class = "mb-2" > < a href = "/docs/5.3/examples/starter-template" > Starter template< / a > < / li > < li class = "mb-2" > < a href = "/docs/5.3/getting-started/webpack" > Webpack< / a > < / li > < li class = "mb-2" > < a href = "/docs/5.3/getting-started/parcel" > Parcel< / a > < / li > < li class = "mb-2" > < a href = "/docs/5.3/getting-started/vite" > Vite< / a > < / li > < / ul > < / div > < div class = "col-6 col-lg-2 mb-3" > < h5 > Projects< / h5 > < ul class = "list-unstyled" > < li class = "mb-2" > < a href = "https://github.com/twbs/bootstrap" target = "_blank" rel = "noopener" > Bootstrap 5< / a > < / li > < li class = "mb-2" > < a href = "https://github.com/twbs/bootstrap/tree/v4-dev" target = "_blank" rel = "noopener" > Bootstrap 4< / a > < / li > < li class = "mb-2" > < a href = "https://github.com/twbs/icons" target = "_blank" rel = "noopener" > Icons< / a > < / li > < li class = "mb-2" > < a href = "https://github.com/twbs/rfs" target = "_blank" rel = "noopener" > RFS< / a > < / li > < li class = "mb-2" > < a href = "https://github.com/twbs/examples" target = "_blank" rel = "noopener" > Examples repo< / a > < / li > < / ul > < / div > < div class = "col-6 col-lg-2 mb-3" > < h5 > Community< / h5 > < ul class = "list-unstyled" > < li class = "mb-2" > < a href = "https://github.com/twbs/bootstrap/issues" target = "_blank" rel = "noopener" > Issues< / a > < / li > < li class = "mb-2" > < a href = "https://github.com/twbs/bootstrap/discussions" target = "_blank" rel = "noopener" > Discussions< / a > < / li > < li class = "mb-2" > < a href = "https://github.com/sponsors/twbs" target = "_blank" rel = "noopener" > Corporate sponsors< / a > < / li > < li class = "mb-2" > < a href = "https://opencollective.com/bootstrap" target = "_blank" rel = "noopener" > Open Collective< / a > < / li > < li class = "mb-2" > < a href = "https://stackoverflow.com/questions/tagged/bootstrap-5" target = "_blank" rel = "noopener" > Stack Overflow< / a > < / li > < / ul > < / div > < / div > < / div > < / footer > < script src = "/docs/5.3/dist/js/bootstrap.bundle.min.js" integrity = "sha384-k6d4wzSIapyDyv1kpU366/PK5hCdSbCRGRCMv+eplOQJWyd1fbcAu9OCUj5zNLiq" > < / script > < script type = "module" src = "/docs/5.3/assets/Scripts.astro_astro_type_script_index_0_lang.BeKqXKw6.js" > < / script > < script type = "module" src = "/docs/5.3/assets/Scripts.astro_astro_type_script_index_1_lang.CAqD2hc_.js" > < / script > < script type = "module" > c o n s t p = ( ) = > { c o n s t t = d o c u m e n t . q u e r y S e l e c t o r ( " . b d - s i d e b a r " ) , a = d o c u m e n t . q u e r y S e l e c t o r ( " . b d - l i n k s - n a v . a c t i v e " ) ; i f ( ! t | | ! a ) r e t u r n ; c o n s t c = t . c l i e n t H e i g h t , i = a . o f f s e t T o p , r = a . c l i e n t H e i g h t , n = i , s = n - c + r ; ( t . s c r o l l T o p > n | | t . s c r o l l T o p < s ) & & ( t . s c r o l l T o p = n - c / 2 + r / 2 ) } , v = ( ) = > { d o c u m e n t . q u e r y S e l e c t o r A l l ( ' [ d a t a - b s - t o g g l e = " t o o l t i p " ] ' ) . f o r E a c h ( e = > { n e w b o o t s t r a p . T o o l t i p ( e ) } ) , d o c u m e n t . q u e r y S e l e c t o r A l l ( ' [ d a t a - b s - t o g g l e = " p o p o v e r " ] ' ) . f o r E a c h ( e = > { n e w b o o t s t r a p . P o p o v e r ( e ) } ) ; c o n s t t = d o c u m e n t . g e t E l e m e n t B y I d ( " t o a s t P l a c e m e n t " ) ; t & & d o c u m e n t . g e t E l e m e n t B y I d ( " s e l e c t T o a s t P l a c e m e n t " ) . a d d E v e n t L i s t e n e r ( " c h a n g e " , f u n c t i o n ( ) { t . d a t a s e t . o r i g i n a l C l a s s | | ( t . d a t a s e t . o r i g i n a l C l a s s = t . c l a s s N a m e ) , t . c l a s s N a m e = ` $ { t . d a t a s e t . o r i g i n a l C l a s s } $ { t h i s . v a l u e } ` } ) , d o c u m e n t . q u e r y S e l e c t o r A l l ( " . b d - e x a m p l e . t o a s t " ) . f o r E a c h ( e = > { n e w b o o t s t r a p . T o a s t ( e , { a u t o h i d e : ! 1 } ) . s h o w ( ) } ) ; c o n s t a = d o c u m e n t . g e t E l e m e n t B y I d ( " l i v e T o a s t B t n " ) , c = d o c u m e n t . g e t E l e m e n t B y I d ( " l i v e T o a s t " ) ; i f ( a ) { c o n s t e = b o o t s t r a p . T o a s t . g e t O r C r e a t e I n s t a n c e ( c ) ; a . a d d E v e n t L i s t e n e r ( " c l i c k " , ( ) = > { e . s h o w ( ) } ) } c o n s t i = d o c u m e n t . g e t E l e m e n t B y I d ( " l i v e A l e r t P l a c e h o l d e r " ) , r = ( e , o ) = > { c o n s t l = d o c u m e n t . c r e a t e E l e m e n t ( " d i v " ) ; l . i n n e r H T M L = [ ` < d i v c l a s s = " a l e r t a l e r t - $ { o } a l e r t - d i s m i s s i b l e " r o l