Tlula eka nhlokomhaka-nkulu Tlula eka docs navigation
Check
in English

Muhlovo

Bootstrap yi seketeriwa hi fambiselo ro anama ra mihlovo leri thyakisaka switayele swa hina ni swiphemu. Leswi swi endla leswaku ku va na ku cinca loku heleleke swinene na ku engeteriwa ka phurojeke yihi na yihi.

Mihlovo ya nhloko-mhaka

Hi tirhisa ntlawa lowutsongo wa mihlovo hinkwayo ku endla phalete ya mihlovo leyitsongo yo tumbuluxa swikimi swa mihlovo, leyi tlhelaka yi kumeka tanihi swilo leswi cinca-cincaka swa Sass na mepe wa Sass eka scss/_variables.scssfayili ya Bootstrap.

Phurayimari
Xikolo xa vumbirhi
Humelela
Nghozi
Xilemukisi
Info
Rivoni
Xinyama

Mihlovo leyi hinkwayo yi kumeka tanihi mepe wa Sass, $theme-colors.

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

Languta mimepe ya hina ya Sass na ti loops docs ku kuma ndlela yo cinca mihlovo leyi.

Mihlovo hinkwayo

Mihlovo hinkwayo ya Bootstrap yi kumeka tanihi swilo leswi cinca-cincaka swa Sass na mepe wa Sass eka scss/_variables.scssfayili. Ku papalata ku engeteleka ka vukulu bya tifayela, a hi endli titlilasi ta matsalwa kumbe ta mihlovo ya le ndzhaku eka xin’wana ni xin’wana xa swilo leswi cinca-cincaka. Ematshan’weni ya sweswo, hi hlawula ntlawa lowutsongo wa mihlovo leyi ya phalete ya nhloko-mhaka .

Tiyiseka leswaku u languta mpimo wa ku hambana loko u ri karhi u endla leswaku mihlovo yi va leyi u yi lavaka. Hilaha swi kombisiweke hakona laha hansi, hi engetele swipimelo swinharhu swa ku hambana eka yin’wana ni yin’wana ya mihlovo leyikulu—yin’wana ya mihlovo ya sweswi ya swatch, yin’wana ya ku lwisana ni yo basa ni yin’wana ya ku lwisana ni ya ntima.

$ya wasi#0d6efd ya xitsonga
$ya wasi-100
$ya wasi-200
$ya wasi-300
$ya wasi-400
$ya wasi-500
$ya wasi-600
$ya wasi-700
$ya wasi-800
$ya wasi-900
$indigo#6610f2
$indigo-100 hi ku tirhisa xitsonga
$indigo-200 yi vula leswaku
$indigo-300 wa swilo leswi
$indigo-400 hi ndlela leyi
$indigo-500 ya swilo leswi
$indigo-600 leyi nga kona
$indigo-700 leyi nga kona
$indigo-800 leyi nga kona
$indigo-900 leyi nga kona
$xivunguvungu#6f42c1
$xivunguvungu-100
$xivunguvungu-200
$xivunguvungu-300
$xivunguvungu-400
$xivunguvungu-500
$xivunguvungu-600
$xivunguvungu-700
$xivunguvungu-800
$xivunguvungu-900
$xitshopana#d63384 wa swifaniso
$xitshopana-100
$xitshopana-200
$xitshopana-300
$xitshopana-400
$xitshopana-500
$xitshopana-600
$xitshopana-700
$xitshopana-800
$xitshopana-900
$yo tshwuka#dc3545 hi ndlela leyi
$yo tshwuka-100
$yo tshwuka-200
$yo tshwuka-300
$yo tshwuka-400
$yo tshwuka-500
$yo tshwuka-600
$yo tshwuka-700
$yo tshwuka-800
$yo tshwuka-900
$orange#fd7e14
$orenji-100
$orenji-200
$orenji-300
$orenji-400
$orenji-500
$orenji-600
$orenji-700
$orenji-800
$orenji-900
$yo tshwuka#ffc107 hi ndlela leyi
$yo tshwuka-100
$yo tshwuka-200
$yo tshwuka-300
$yo tshwuka-400
$yo tshwuka-500
$yo tshwuka-600
$yo tshwuka-700
$yo tshwuka-800
$yo tshwuka-900
$rihlaza#198754 wa swilo
$rihlaza-100
$rihlaza-200
$rihlaza-300
$rihlaza-400
$rihlaza-500
$rihlaza-600
$rihlaza-700
$rihlaza-800
$rihlaza-900
$teal#20c997 hi ndlela leyi
$teal-100 wa swilo
$teal-200 wa swilo
$teal-300 wa swilo
$teal-400 wa swilo
$teal-500 wa swilo
$teal-600 wa swilo
$teal-700 wa swilo
$teal-800 wa swilo
$teal-900 wa swilo
$cyan#0dcaf0
$cyan-100 wa swilo
$cyan-200 wa swilo
$cyan-300 wa swilo
$cyan-400 yi va kona
$cyan-500 ya swikwembu
$cyan-600 yi va kona
$cyan-700 yi va kona
$cyan-800 yi va kona
$cyan-900 yi va kona
$gray-500# xihlamusela-marito
$gray-100
$gray-200
$gray-300
$gray-400
$gray-500
$gray-600
$gray-700
$gray-800
$gray-900
$ntima#000 wa swilo
$yo basa#fff

Tinhlamuselo eka Sass

Sass a yi nge swi koti ku tumbuluxa swilo leswi cinca-cincaka hi ndlela ya nongonoko, hikwalaho hi endle swilo leswi cinca-cincaka hi voko eka tint yin’wana ni yin’wana ni ndzhuti hi hexe. Hi boxa ntikelo wa ndhawu ya le xikarhi (xikombiso, $blue-500) naswona hi tirhisa mintirho ya mihlovo ya ntolovelo ku tint (ku voninga) kumbe ku endla ndzhuti (ku endla ntima) mihlovo ya hina hi ku tirhisa mix()ntirho wa mihlovo wa Sass.

Ku tirhisa mix()a swi fani na lighten()na darken()—leyo sungula yi hlanganisa muvala lowu boxiweke ni wo basa kumbe wa ntima, kasi ya vumbirhi yi lulamisa ntsena ntikelo wa ku olova ka muvala wun’wana ni wun’wana. Vuyelo bya kona i nxaxamelo lowu heleleke swinene wa mihlovo, hilaha swi kombisiweke hakona eka demo leyi ya CodePen .

Mintirho ya hina tint-color()na shade-color()yi tirhisa mix()etlhelo ka $theme-color-intervalxihlawulekisi xa hina, lexi hlamuselaka ntikelo wa tiphesente ta magoza eka muvala wun’wana na wun’wana lowu pfanganisiweke lowu hi wu humesaka. Vona tifayela ta scss/_functions.scssna scss/_variables.scssku kuma khodi ya xihlovo leyi heleleke.

Mihlovo ya mimepe ya Sass

Tifayili ta Sass ta xihlovo xa Bootstrap ti katsa mimepe yinharhu ku ku pfuna ku hatlisa no olova ku rhendzeleka ehenhla ka nxaxamelo wa mihlovo na mimpimo ya yona ya hex.

  • $colorsyi xaxameta mihlovo hinkwayo ya hina ya xisekelo ( 500) leyi kumekaka
  • $theme-colorsyi xaxameta mihlovo hinkwayo ya nhlokomhaka leyi thyiweke mavito ya nhlamuselo (leyi kombisiweke laha hansi) .
  • $graysyi xaxameta tints hinkwato na tinxaka ta grey

Endzeni ka scss/_variables.scss, u ta kuma swilo leswi cinca-cincaka swa mihlovo ya Bootstrap ni mepe wa Sass. Hi lexi xikombiso xa $colorsmepe wa Sass:

$colors: (
  "blue":       $blue,
  "indigo":     $indigo,
  "purple":     $purple,
  "pink":       $pink,
  "red":        $red,
  "orange":     $orange,
  "yellow":     $yellow,
  "green":      $green,
  "teal":       $teal,
  "cyan":       $cyan,
  "black":      $black,
  "white":      $white,
  "gray":       $gray-600,
  "gray-dark":  $gray-800
);

Engetela, susa kumbe ku cinca mimpimo endzeni ka mepe ku pfuxeta ndlela leyi yi tirhisiwaka ha yona eka swiphemu swin’wana swo tala. Khombo ra kona eka nkarhi lowu, a hi xiphemu xin’wana na xin’wana lexi tirhisaka mepe lowu wa Sass. Swilo leswi pfuxetiweke swa nkarhi lowu taka swi ta lwela ku antswisa eka leswi. Ku fikela kwalaho, pulana ku tirhisa ${color}swilo leswi cinca-cincaka na mepe lowu wa Sass.

Xikombiso

Hi leyi ndlela leyi u nga tirhisaka leswi ha yona eka Sass ya wena:

.alpha { color: $purple; }
.beta {
  color: $yellow-300;
  background-color: $indigo-900;
}

Titlilasi ta vukorhokeri bya mihlovo na le ndzhaku na tona ta kumeka ku veka colorna background-colorku tirhisa 500mimpimo ya mihlovo.

Ku tumbuluxa switirhisiwa swa vukorhokeri

Ku engeteriwe eka v5.1.0

Bootstrap a yi katsi colorna background-colorswitirhisiwa swa xihlawulekisi xin’wana na xin’wana xa muvala, kambe u nga tumbuluxa leswi hi wexe hi API ya hina ya vukorhokeri na mimepe ya hina leyi andlariweke ya Sass leyi engeteriweke eka v5.1.0.

  1. Ku sungula, tiyisisa leswaku u nghenise mintirho ya hina, swilo leswi cinca-cincaka, mixins, na switirhisiwa.
  2. Tirhisa map-merge-multiple()ntirho wa hina ku hatlisa u hlanganisa mimepe yo tala ya Sass swin’we eka mepe lowuntshwa.
  3. Hlanganisa mepe lowu wuntshwa lowu hlanganisiweke ku andlala vukorhokeri byihi na byihi hi {color}-{level}vito ra tlilasi.

Hi lexi xikombiso lexi humesaka switirhisiwa swa mihlovo ya matsalwa (xikombiso, .text-purple-500) hi ku tirhisa magoza lama nga laha henhla.

@import "bootstrap/scss/functions";
@import "bootstrap/scss/variables";
@import "bootstrap/scss/maps";
@import "bootstrap/scss/mixins";
@import "bootstrap/scss/utilities";

$all-colors: map-merge-multiple($blues, $indigos, $purples, $pinks, $reds, $oranges, $yellows, $greens, $teals, $cyans);

$utilities: map-merge(
  $utilities,
  (
    "color": map-merge(
      map-get($utilities, "color"),
      (
        values: map-merge(
          map-get(map-get($utilities, "color"), "values"),
          (
            $all-colors
          ),
        ),
      ),
    ),
  )
);

@import "bootstrap/scss/utilities/api";

Leswi swi ta humesa .text-{color}-{level}switirhisiwa leswintshwa eka muvala wun’wana na wun’wana na xiyimo. U nga endla leswi fanaka eka vukorhokeri byin’wana ni byin’wana ni nhundzu na swona.