Loading...
Loading...
Use, extend, and customize Bootstrap 6's utility API. Use when adding a custom utility class, modifying or removing Bootstrap's default utilities, enabling responsive or state variants, or trimming the generated utility CSS.
npx skill4agent add twbs/bootstrap bootstrap-utility-api$utilitiesscss/utilities/_api.scss@include generate-utility-at-properties($utilities);
@layer utilities {
@include generate-utilities-loop($utilities, $breakpoints);
}!importantimportant: true@property--bg--fg--bc--rounded-sizesyntax: "*"; inherits: false.border-inverseconfigbootstrap$utilitiesscss/_config.scssscss/_utilities.scss@use "config" as *// Does NOT work — "This variable was not declared with !default in the @used module."
@use "bootstrap/scss/bootstrap" with (
$utilities: (…)
);
// Works — configure config first, then load Bootstrap
@use "bootstrap/scss/config" with (
$utilities: (…)
);
@use "bootstrap/scss/bootstrap";_config.scss$radius$spacers$breakpoints$zindex-levelsbootstrap.scss$root-tokens$colors$bluebootstrap"overflow": (
property: overflow,
values: auto hidden visible scroll,
),generate-utility()| Key | Required | What it does |
|---|---|---|
| Yes | Property name, space-separated list of names, or a map of property-to-value pairs |
| Yes | List (class suffix equals the value) or map (keys become suffixes; a |
| No | Class name to use instead of the property name |
| No | |
| No | Descendant selector, wrapped in |
| No | Custom properties to emit — a map of static values, or a list that each receive the utility value |
| No | Pseudo-class variants to generate, e.g. |
| No | Generate a class per breakpoint (default |
| No | Generate |
| No | Generate |
| No | Append |
| No | Set |
propertyvalues@errorresponsive@error@warn@use "bootstrap/scss/config" with (
$utilities: (
"cursor": (
property: cursor,
class: cursor,
responsive: true,
values: auto pointer grab,
),
)
);
@use "bootstrap/scss/bootstrap";.cursor-auto.cursor-pointer.cursor-grab.sm:cursor-*.2xl:cursor-*// List — suffix is the value itself: .cursor-pointer
values: auto pointer grab,
// Map — keys become suffixes: .tint-brand
values: (brand: var(--purple-500), muted: var(--gray-200)),
// null key — no suffix at all: .shout
values: (null: uppercase),// Errors: "Utility is missing required `property` key"
"overflow": (
responsive: true,
values: visible hidden scroll auto,
),scss/_utilities.scss@use "bootstrap/scss/config" with (
$utilities: (
// Make overflow responsive
"overflow": (
property: overflow,
values: auto hidden visible scroll,
responsive: true,
),
// Remove a family entirely
"width": null,
// Rename .ms-* to v4-style .ml-*: drop the original, add a replacement
"margin-start": null,
"margin-start-alias": (
property: margin-inline-start,
class: ml,
responsive: true,
values: (0: 0, 1: var(--spacer-1), 2: var(--spacer-2), auto: auto),
),
)
);
@use "bootstrap/scss/bootstrap";config$spacers$negative-spacersmap-merge-multiple()var(--spacer-2)class"width-extra": (
property: width,
class: w,
responsive: true,
values: (10: 10%, 15: 15%),
),.w-10.w-15.w-25.w-100enabled: falsenull| Option | Generated class | Notes |
|---|---|---|
| | One pass per key in |
| | Selector is |
| | Wrapped in |
| | Wrapped in |
responsivestate.md:hover:cursor-pointer"tint": (
property: (
"--tint": null,
"background-color": var(--tint),
),
class: tint,
values: (brand: var(--purple-500)),
),null.tint-brand {
--tint: var(--purple-500);
background-color: var(--tint);
}variablespropertyvaluesselector: attr-startsattr-includes[class^="…"][class*="…"]class.ratio-16x9aspect-ratio--ratiochild-selector:where():where(.stack-gap-1 > *)--bs-@use "bootstrap/scss/config" with ($utilities: (…));
@use "bootstrap/scss/bootstrap-utilities";nullenabled: falseresponsivevalues$utilitiesscss/_utilities.scss// scss-docs-start utils-<name>// scss-docs-end utils-<name>$spacers$util-opacitytheme-color-refs()site/src/content/docs/utilities/<ScssDocs name="utils-<name>" file="scss/_utilities.scss" />site/data/sidebar.ymlscss/tests/utilities/_api.test.scssnpm run csscss-docsdist/css/bootstrap-utilities.metadata.jsonnpm run css-lintnpm run css\.md\\:cursor-pointer@propertypropertyvariables@warn!important