Svetuka kune chikuru content Svetuka kuenda kudocs navigation
Check
in English

Mabheji

Zvinyorwa uye mienzaniso yemabheji, kuverenga kwedu kudiki uye chikamu chekunyora.

Mienzaniso

Mabheji anoyera kuti aenderane nehukuru hweiyo mubereki chikamu nekushandisa hukama font saizi uye mayunitsi em. Nezvev5, mabheji haachave nekutarisa kana hover masitaera ezvekubatanidza.

Misoro

Muenzaniso musoroNew

Muenzaniso musoroNew

Muenzaniso musoroNew

Muenzaniso musoroNew

Muenzaniso musoroNew
Muenzaniso musoroNew
html
<h1>Example heading <span class="badge bg-secondary">New</span></h1>
<h2>Example heading <span class="badge bg-secondary">New</span></h2>
<h3>Example heading <span class="badge bg-secondary">New</span></h3>
<h4>Example heading <span class="badge bg-secondary">New</span></h4>
<h5>Example heading <span class="badge bg-secondary">New</span></h5>
<h6>Example heading <span class="badge bg-secondary">New</span></h6>

Mabhatani

Mabheji anogona kushandiswa sechikamu chezvinongedzo kana mabhatani ekupa counter.

html
<button type="button" class="btn btn-primary">
  Notifications <span class="badge text-bg-secondary">4</span>
</button>

Ziva kuti zvichienderana nemashandisirwo aanoitwa, mabheji anogona kunge achivhiringa kune vashandisi vezvidzitiro zvekuverenga uye akafanana anobatsira matekinoroji. Nepo manyorerwo emabheji achipa ratidziro yekuona nezvechinangwa chavo, vashandisi ava vanongoratidzwa nezviri mukati mebheji. Zvichienderana nemamiriro ezvinhu chaiwo, mabheji aya anogona kuita semashoko asina kurongeka kana manhamba pakupera kwemutsara, chinongedzo, kana bhatani.

Kunze kwekunge mamiriro acho ezvinhu akajeka (sezvakaita "Zviziviso" semuenzaniso, pazvinonzwisiswa kuti "4" inhamba yezviziviso), funga kusanganisira yekuwedzera mamiriro nechidimbu chakavanzwa chekuwedzera.

Positioned

Shandisa zvinoshandiswa kugadzirisa a .badgeuye kuimisa mukona yekubatanidza kana bhatani.

html
<button type="button" class="btn btn-primary position-relative">
  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>
</button>

Iwe unogona zvakare kutsiva .badgekirasi nemamwe mashoma ekushandisa pasina kuverenga kune imwe generic chiratidzo.

html
<button type="button" class="btn btn-primary position-relative">
  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>
</button>

Background mavara

Yakawedzerwa mu v5.2.0

Seta kumberi background-colorkwakasiyana colornevabatsiri vedu .text-bg-{color}. Pakutanga zvaidiwa kuti ubatanidze nemaoko sarudzo yako .text-{color}uye .bg-{color}zvishandiso zvesitayera, izvo zvauchiri kushandisa kana uchida.

Primary Secondary Success Danger Yambiro Info Chiedza Rima
html
<span class="badge text-bg-primary">Primary</span>
<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>
<span class="badge text-bg-dark">Dark</span>
Kuendesa zvinoreva kunobatsira matekinoroji

Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies – such as screen readers. Ensure that information denoted by the color is either obvious from the content itself (e.g. the visible text), or is included through alternative means, such as additional text hidden with the .visually-hidden class.

Pill badges

Use the .rounded-pill utility class to make badges more rounded with a larger border-radius.

Primary Secondary Success Danger Warning Info Light Dark
html
<span class="badge rounded-pill text-bg-primary">Primary</span>
<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>
<span class="badge rounded-pill text-bg-dark">Dark</span>

CSS

Variables

Added in v5.2.0

As part of Bootstrap’s evolving CSS variables approach, badges now use local CSS variables on .badge for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.

  --#{$prefix}badge-padding-x: #{$badge-padding-x};
  --#{$prefix}badge-padding-y: #{$badge-padding-y};
  @include rfs($badge-font-size, --#{$prefix}badge-font-size);
  --#{$prefix}badge-font-weight: #{$badge-font-weight};
  --#{$prefix}badge-color: #{$badge-color};
  --#{$prefix}badge-border-radius: #{$badge-border-radius};
  

Sass variables

$badge-font-size:                   .75em;
$badge-font-weight:                 $font-weight-bold;
$badge-color:                       $white;
$badge-padding-y:                   .35em;
$badge-padding-x:                   .65em;
$badge-border-radius:               $border-radius;