Main content ah kal rawh Docs navigation ah kal rawh
Check
in English

A rawng hrang hrang

colorColor utility class tlemte hmangin awmzia sawifiah rawh . Hover states nena styling links support a awm bawk.

A rawng hrang hrang

Text chu color utilities hmangin colorize rawh. Links colorize duh chuan .link-*helper classes which have :hoverleh :focusstates te hi i hmang thei ang.

.text-a hmasa ber a ni

.text-secondary tih a ni

.text-hlawhtlinna

.text-hlauhawm tak a ni

.text-vaukhânna

.text-info a ni

.text-eng a ni

.text-thim a ni

.text-taksa a ni

.text-muted a ni

.text-a var a ni

.text-black-50 tih a ni

.text-white-50 tih a ni

html tih a ni
<p class="text-primary">.text-primary</p>
<p class="text-secondary">.text-secondary</p>
<p class="text-success">.text-success</p>
<p class="text-danger">.text-danger</p>
<p class="text-warning bg-dark">.text-warning</p>
<p class="text-info bg-dark">.text-info</p>
<p class="text-light bg-dark">.text-light</p>
<p class="text-dark">.text-dark</p>
<p class="text-body">.text-body</p>
<p class="text-muted">.text-muted</p>
<p class="text-white bg-dark">.text-white</p>
<p class="text-black-50">.text-black-50</p>
<p class="text-white-50 bg-dark">.text-white-50</p>
Deprecation:.text-opacity-* Text utilities atan utilities leh CSS variable te .text-black-50dah belh a .text-white-50nih avangin, v5.1.0 atang khan deprecated a ni. v6.0.0 ah an paih dawn a ni.
Assistive technology-te hnena awmzia thlentu

awmzia belhchhah nan color hman hian hmuh theiha hriattirna chauh a pe a, chu chu assistive technology hmangtute hnenah a thlen dawn lo – screen reader ang chi te. Color hmanga tarlan information chu a thupui a\ang ngeia lang (entir nan, hmuh theih thuziak), a nih loh leh kawng dang hmanga telh a nih theih nan enfiah rawh, chu chu .visually-hiddenclass nena thup belh thuziak ang chi a ni.

Opacity a ni

v5.1.0 ah dah belh a ni

v5.1.0 atang khan Sass hmangin CSS variable hmangin text color utilities siam a ni. Hei hian compilation leh dynamic alpha transparency thlak ngai lovin real-time color thlak theihna a siamsak a ni.

A hnathawh dan

Kan default .text-primaryutility hi han ngaihtuah teh.

.text-primary {
  --bs-text-opacity: 1;
  color: rgba(var(--bs-primary-rgb), var(--bs-text-opacity)) !important;
}

Kan --bs-primary(value 13, 110, 253) CSS variable RGB version kan hmang a, alpha transparency atan CSS variable pahnihna, , kan attached a ( local CSS variable vangin --bs-text-opacitydefault value nen ). 1Chumi awmzia chu .text-primarytuna i hman apiangin i computed colorvalue chu rgba(13, 110, 253, 1). Class tin chhunga local CSS variable hian .text-*inheritance issue a pumpelh avangin utilities te nested instance te hian automatic in modified alpha transparency an nei lo.

Entirna

Chu opacity chu thlak tur chuan --bs-text-opacitycustom style emaw inline style emaw hmangin override la.

Hei hi default primary text a ni
Hei hi 50% opacity primary text a ni
html tih a ni
<div class="text-primary">This is default primary text</div>
<div class="text-primary" style="--bs-text-opacity: .5;">This is 50% opacity primary text</div>

.text-opacityA nih loh leh, utility zingah eng emaw zat thlang rawh :

Hei hi default primary text a ni
Hei hi 75% opacity primary text a ni
Hei hi 50% opacity primary text a ni
Hei hi 25% opacity primary text a ni
html tih a ni
<div class="text-primary">This is default primary text</div>
<div class="text-primary text-opacity-75">This is 75% opacity primary text</div>
<div class="text-primary text-opacity-50">This is 50% opacity primary text</div>
<div class="text-primary text-opacity-25">This is 25% opacity primary text</div>

A bik takin

A châng chuan selector dang specificity vangin contextual class hman theih a ni lo. A then phei chuan workaround tling tak chu i element content chu <div>class duh ang nen semantic element pakhat emaw a aia tam emaw-a wrap hi a ni.

Sass a ni

A hnuaia Sass functionality bakah hian kan included CSS custom properties (aka CSS variables) te chu color leh thil dang tam tak tan chhiar tum ang che.

Variables te pawh a awm

Utility tam zawk colorhi kan theme colors atanga siam a ni a, kan generic color palette variable atanga reassign a ni.

$blue:    #0d6efd;
$indigo:  #6610f2;
$purple:  #6f42c1;
$pink:    #d63384;
$red:     #dc3545;
$orange:  #fd7e14;
$yellow:  #ffc107;
$green:   #198754;
$teal:    #20c997;
$cyan:    #0dcaf0;
$primary:       $blue;
$secondary:     $gray-600;
$success:       $green;
$info:          $cyan;
$warning:       $yellow;
$danger:        $red;
$light:         $gray-100;
$dark:          $gray-900;

Grayscale color pawh a awm a, mahse subset chauh hmangin utility eng pawh siam a ni.

$white:    #fff;
$gray-100: #f8f9fa;
$gray-200: #e9ecef;
$gray-300: #dee2e6;
$gray-400: #ced4da;
$gray-500: #adb5bd;
$gray-600: #6c757d;
$gray-700: #495057;
$gray-800: #343a40;
$gray-900: #212529;
$black:    #000;

Map a ni

Chumi hnuah chuan theme color te chu Sass map ah dah a ni a, chutiang chuan kan utilities, component modifier leh thil dang tam tak siam turin kan loop thei a ni.

$theme-colors: (
  "primary":    $primary,
  "secondary":  $secondary,
  "success":    $success,
  "info":       $info,
  "warning":    $warning,
  "danger":     $danger,
  "light":      $light,
  "dark":       $dark
);

Sass map angin grayscale color pawh a awm bawk. He map hi utility engmah siam nan hman a ni lo.

$grays: (
  "100": $gray-100,
  "200": $gray-200,
  "300": $gray-300,
  "400": $gray-400,
  "500": $gray-500,
  "600": $gray-600,
  "700": $gray-700,
  "800": $gray-800,
  "900": $gray-900
);

RGB color te hi Sass map hran atanga siam a ni:

$theme-colors-rgb: map-loop($theme-colors, to-rgb, "$value");

Tin, color opacities te chuan chu chu anmahni map hmangin an siam a, chu chu utilities API-in a eiral a ni:

$utilities-text: map-merge(
  $utilities-colors,
  (
    "black": to-rgb($black),
    "white": to-rgb($white),
    "body": to-rgb($body-color)
  )
);
$utilities-text-colors: map-loop($utilities-text, rgba-css-var, "$key", "text");

Utilities API hmanga thil tih a ni

Color utilities hi kan utilities API ah hian scss/_utilities.scss. Utilities API hman dan zir rawh.

    "color": (
      property: color,
      class: text,
      local-vars: (
        "text-opacity": 1
      ),
      values: map-merge(
        $utilities-text-colors,
        (
          "muted": $text-muted,
          "black-50": rgba($black, .5), // deprecated
          "white-50": rgba($white, .5), // deprecated
          "reset": inherit,
        )
      )
    ),
    "text-opacity": (
      css-var: true,
      class: text-opacity,
      values: (
        25: .25,
        50: .5,
        75: .75,
        100: 1
      )
    ),