Lumpat menyang isi utama Lumpat menyang pandhu arah docs
Check
in English

werna-werna

Nerangake makna liwat colorkaro sawetara kelas sarana werna. Kalebu dhukungan kanggo tautan gaya karo status hover.

werna-werna

Werna teks kanthi utilitas warna. Yen sampeyan pengin link colorize, sampeyan bisa nggunakake .link-*kelas helper sing duwe :hoverlan :focusnegara.

.teks-utama

.teks-sekunder

.teks-sukses

.teks-bebaya

.text-warning

.teks-info

.teks-lampu

.teks-peteng

.teks-awak

.text-muted

.teks-putih

.teks-ireng-50

.teks-putih-50

html
<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: Kanthi tambahan .text-opacity-*utilitas lan variabel CSS kanggo keperluan teks, .text-black-50lan .text-white-50ora digunakake minangka v5.1.0. Padha bakal dibusak ing v6.0.0.
Nuduhake makna kanggo teknologi assistive

Nggunakake warna kanggo nambah makna mung menehi indikasi visual, sing ora bakal dikirim menyang pangguna teknologi bantu - kayata pembaca layar. Priksa manawa informasi sing dituduhake kanthi warna katon jelas saka isi kasebut (umpamane teks sing katon), utawa kalebu liwat cara alternatif, kayata teks tambahan sing didhelikake karo .visually-hiddenkelas.

Opacity

Ditambahake ing v5.1.0

Ing v5.1.0, utilitas warna teks digawe karo Sass nggunakake variabel CSS. Iki ngidini owah-owahan warna nyata-wektu tanpa kompilasi lan owah-owahan transparansi alpha dinamis.

Cara kerjane

.text-primaryCoba utilitas standar kita .

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

Kita nggunakake versi RGB saka kita --bs-primary(karo Nilai saka 13, 110, 253) variabel CSS lan ditempelake variabel CSS kapindho, --bs-text-opacity, kanggo transparan alpha (karo nilai standar 1thanks kanggo variabel CSS lokal). Tegese kapan wae sampeyan nggunakake saiki, nilai .text-primarydiitung sampeyan yaiku . Variabel CSS lokal ing saben kelas ngindhari masalah warisan supaya conto utilitas ora otomatis duwe transparansi alpha sing diowahi.colorrgba(13, 110, 253, 1).text-*

Tuladha

Kanggo ngganti opacity kasebut, ganti --bs-text-opacityliwat gaya khusus utawa gaya inline.

Iki minangka teks utama standar
Iki minangka teks utama opacity 50%.
html
<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>

Utawa, pilih salah sawijining .text-opacityutilitas:

Iki minangka teks utama standar
Iki minangka teks utama opacity 75%.
Iki minangka teks utama opacity 50%.
Iki minangka teks utama opacity 25%.
html
<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>

Kekhususan

Kadhangkala kelas kontekstual ora bisa ditrapake amarga kekhususan pamilih liyane. Ing sawetara kasus, solusi sing cukup yaiku mbungkus konten unsur sampeyan ing unsur <div>semantik utawa luwih karo kelas sing dikarepake.

Sass

Saliyane fungsi Sass ing ngisor iki, coba maca babagan properti khusus CSS sing kalebu (alias variabel CSS) kanggo warna lan liya-liyane.

Variabel

Umume colorutilitas digawe saka warna tema, ditugasake maneh saka variabel palet warna umum.

$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;

Werna werna abu-abu uga kasedhiya, nanging mung subset sing digunakake kanggo ngasilake keperluan apa wae.

$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;

peta

Werna tema banjur dilebokake ing peta Sass supaya kita bisa ngubengi kanggo ngasilake utilitas, modifier komponen, lan liya-liyane.

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

Werna werna abu-abu uga kasedhiya minangka peta Sass. Peta iki ora digunakake kanggo ngasilake utilitas.

$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
);

Werna RGB digawe saka peta Sass sing kapisah:

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

Lan opacities warna dibangun nganggo peta dhewe sing digunakake dening API utilitas:

$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

Utilitas warna diumumake ing API keperluan kita ing scss/_utilities.scss. Sinau carane nggunakake API keperluan.

    "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
      )
    ),