Compare commits

...

13 Commits

Author SHA1 Message Date
Romaric Pascal 7298ae0fd6 Refactor to make import of utilities-map explicit in _mixins.scss 2023-02-24 10:44:21 +00:00
Romaric Pascal 046a74303f Make small amends from PR review 2023-02-24 10:44:21 +00:00
Romaric Pascal 4ebdcef96f Update documentation for customizing colors 2023-02-17 11:04:55 +00:00
Romaric Pascal 5df18c3853 Tidy up utilities map code
- use consistent variable name
- use consistent code structure for functions that do similar things
- remove code duplication for utilities-add
2023-02-17 10:23:40 +00:00
Romaric Pascal dc93f6ad19 Add tests for utilities-map functions and mixins
Split the utilities-map helpers in their own file to make tests a little more isolated
2023-02-17 10:03:54 +00:00
Mark Otto 2560a59180 Update copy on new utility API docs 2023-02-17 09:42:44 +00:00
Romaric Pascal 4289ec74b7 Update utility example to avoid cspell error 2023-02-17 09:42:44 +00:00
Mark Otto bf3b21802e Some edits 2023-02-17 09:42:44 +00:00
Mark Otto 47a195e3ac Minor formatting 2023-02-17 09:42:44 +00:00
Romaric Pascal c0ac568ff6 Reorganise headings in utilities page and minor edits 2023-02-17 09:42:42 +00:00
Romaric Pascal 4b06819ac2 Update utilities documentation 2023-02-17 09:38:35 +00:00
Romaric Pascal c30bd63981 Add thorough implementation of utilities functions and mixins 2023-02-17 09:36:14 +00:00
Romaric Pascal aa06a202b2 Add functions and mixins to manipulate the utlities map
- get options, a specific option or a specific value for a given utility
- set options, new values or remove values for a given utility
- add or remove utilities
2023-02-17 09:36:14 +00:00
6 changed files with 638 additions and 167 deletions
+1
View File
@@ -20,6 +20,7 @@
// Utilities
@import "mixins/utilities";
@import "mixins/utilities-map";
// Components
@import "mixins/backdrop";
+128
View File
@@ -0,0 +1,128 @@
//
// Helper functions and mixins for manipulating the utilities map
//
// Helper function to create a map from a list or string
// so we can manipulate utility values consistently
@function map-from($list-or-string) {
$map: ();
@each $item in $list-or-string {
$map: map-merge(
$map,
($item: $item)
);
}
@return $map;
}
// Gets the map of options for a given utility
@function utilities-get-options($utility-name) {
@return map-get($utilities, $utility-name);
}
// Gets the value of a specific option for a given utility
@function utilities-get-option($utility-name, $option-name) {
$utility-options: utilities-get-options($utility-name);
@if ($utility-options) {
@return map-get(
$utility-options,
$option-name
);
}
@return null;
}
// Returns a map of the values for the utility
@function utilities-get-values($utility-name) {
$utility-values: utilities-get-option($utility-name, values);
@if (type-of($utility-values) != map) {
@return map-from($utility-values);
}
@return $utility-values;
}
// Gets a specific value for the given utility
@function utilities-get-value($utility-name, $value-name) {
$utility-values: utilities-get-values($utility-name);
@return map-get(
$utility-values,
$value-name
);
}
// Set options for a given utility, merged with the existing ones by default.
// To completely replace the existing options, set the 3rd `$merge` parameter to false
@mixin utilities-set-options($utility-name, $options, $merge: true) {
@if ($merge) {
$utility-options: utilities-get-options($utility-name);
// Allows the mixin to create a new utility when setting an unknown utility name
// Important: The variable needs to have the same name as the function argument
// here, so that we can have a single merge call at the end of the function
$options: if(
$utility-options,
map-merge(
utilities-get-options($utility-name),
$options
),
$options
);
}
$utilities: map-merge(
$utilities,
($utility-name: $options)
) !global; // !global ensures we modify the global $utilities map
}
// Set a specific option to a new value for the given utility
@mixin utilities-set-option($utility-name, $option-name, $value) {
@include utilities-set-options($utility-name, ($option-name: $value));
}
// Add new values to a given utility
//
// If you want to completely reconfigure the values use `utilities-set-option` to provide a new map for the `values` option
@mixin utilities-add-values($utility-name, $values) {
$utility-values: utilities-get-values($utility-name);
@include utilities-set-option(
$utility-name,
values,
map-merge(
$utility-values,
$values
)
);
}
// Remove specific values from a given utility
@mixin utilities-remove-values($utility-name, $value-names...) {
$utility-values: utilities-get-values($utility-name);
@include utilities-set-option(
$utility-name,
values,
map-remove(
$utility-values,
$value-names...
)
);
}
// Add a new utility to the utilities map
@mixin utilities-add($utility-name, $utility) {
@include utilities-set-options($utility-name, $utility, false);
}
// Remove a utility from the utilities map
@mixin utilities-remove($utility-names...) {
$utilities: map-remove($utilities, $utility-names...) !global;
}
+343
View File
@@ -0,0 +1,343 @@
@mixin before {
$utilities: (
"flex": (
responsive: true,
property: flex,
values: (fill: 1 1 auto)
),
"align": (
property: vertical-align,
class: align,
values: baseline top
),
"margin": (
property: margin,
class: margin,
values: auto
)
) !global;
}
@import "../../mixins/utilities-map";
@include describe("utilities") {
@include describe("utilities-get-options") {
@include it("Returns the options for the given utility") {
@include before ();
@include assert-equal(
utilities-get-options("flex"),
(
responsive: true,
property: flex,
values: (fill: 1 1 auto)
));
}
@include it("Return null if the utility does not exist") {
@include before ();
@include assert-equal(
utilities-get-options("non-existing"),
null
);
}
}
@include describe("utilities-get-option") {
@include it("Returns the option for the given utility") {
@include before ();
@include assert-equal(
utilities-get-option(flex, responsive),
true
);
}
@include it("Returns null if the option is not present") {
@include before ();
@include assert-equal(
utilities-get-option(flex, non-existing),
null
);
}
@include it("Returns null if the utility is not present") {
@include before ();
@include assert-equal(
utilities-get-option(non-existing, responsive),
null
);
}
}
@include describe("utilities-get-value") {
@include describe("utilities with map of values") {
@include it("Returns the value for the given utility") {
@include before ();
@include assert-equal(
utilities-get-value(flex, fill),
1 1 auto
);
}
@include it("Returns null if the value does not exist for the utility") {
@include before ();
@include assert-equal(
utilities-get-value(flex, non-existing),
null
);
}
}
@include describe("utilities with list of values") {
@include it("Returns the value if it is in the list") {
@include before ();
@include assert-equal(
utilities-get-value(align, top),
top
);
}
@include it("Returns null if the value is not in the list") {
@include before ();
@include assert-equal(
utilities-get-value(align, non-existing),
null
);
}
}
@include describe("utilities with single value") {
@include it("Returns the value if it is the one set") {
@include before ();
@include assert-equal(
utilities-get-value(margin, auto),
auto
);
}
@include it("Returns null if it is not the value set") {
@include before ();
@include assert-equal(
utilities-get-value(margin, non-existing),
null
);
}
}
}
@include describe("utilities-set-options") {
@include it("Merges the options with the existing ones") {
@include before ();
@include utilities-set-options(flex, (
responsive: false,
rtl: true
));
// Unedited options are still present
@include assert-equal(utilities-get-option(flex, property), flex, "property");
@include assert-equal(utilities-get-option(flex, values), (fill: 1 1 auto), "values");
// And the updated options have their new values
@include assert-equal(utilities-get-option(flex, responsive), false, "responsive");
@include assert-equal(utilities-get-option(flex, rtl), true, "rtl");
}
@include it("Creates the options if none exist") {
@include assert-equal(utilities-get-option(unknown, responsive), null);
@include utilities-set-options(unknown, (
responsive: true
));
@include assert-equal(utilities-get-option(unknown, responsive), true);
}
@include describe("$merge: false") {
@include it("Completely replaces the options") {
@include utilities-set-options(flex, (
values: auto none
), $merge: false);
@include assert-equal(utilities-get-options(flex), (
values: auto none
));
}
}
}
@include describe("utilities-set-option") {
@include it("sets a specific option for the utility") {
@include before ();
@include utilities-set-option(flex, responsive, false);
@include assert-equal(utilities-get-option(flex, responsive), false);
}
}
@include describe("utilities-add-values") {
@include describe("utilities with map of values") {
@include it("Merges a new map values with the old ones") {
@include before ();
@include utilities-add-values(flex, (
auto: auto,
none: none
));
@include assert-equal(utilities-get-option(flex, values), (
fill: 1 1 auto,
auto: auto,
none: none
));
}
}
@include describe("utilities with list values") {
@include it("Creates a map and merges the new values") {
@include before ();
@include utilities-add-values(align, (
middle: middle
));
@include assert-equal(utilities-get-option(align, values), (
baseline: baseline,
top: top,
middle: middle
));
}
}
@include describe("utilities with single value") {
@include it("Creates a map and merges the new values") {
@include before ();
@include utilities-add-values(margin, (
5pct: 5%
));
@include assert-equal(utilities-get-option(margin, values), (
auto: auto,
5pct: 5%
));
}
}
}
@include describe("utilities-remove-values") {
@include describe("utilities with map of values") {
@include it("removes the value with the given key") {
@include before ();
@include utilities-remove-values(flex, fill);
@include assert-equal(utilities-get-option(flex, values),());
}
}
@include describe("utilities with list of values") {
@include it("removes the value and creates a map") {
@include before ();
@include utilities-remove-values(align, top);
@include assert-equal(
utilities-get-option(align, values),
(
baseline: baseline
)
);
}
}
@include describe("utilities with single value") {
@include it("removes the value and creates a map") {
@include before ();
@include utilities-remove-values(margin, auto);
@include assert-equal(
utilities-get-option(margin, values),
()
);
}
}
@include describe("$values...") {
@include it("allows to remove multiple values") {
@include before ();
@include utilities-remove-values(align, baseline, top);
@include assert-equal(utilities-get-option(align, values),());
}
@include it("ignores unknown values") {
@include before ();
@include utilities-remove-values(flex, unknown, fill, non-existing);
@include assert-equal(utilities-get-option(flex, values), ());
}
}
}
@include describe("utilities-add") {
@include it("adds the utility") {
@include before ();
@include utilities-add(z-index, (
class: z,
property: z-index,
values: (-1, 0, 1, 2, 3)
));
@include assert-equal(utilities-get-options(z-index), (
class: z,
property: z-index,
values: (-1, 0, 1, 2, 3)
));
}
@include it("overrides an existing utility") {
@include before ();
@include utilities-add("flex", (
class: flex,
values: auto none
));
@include assert-equal(utilities-get-options(flex), (
class: flex,
values: auto none
));
}
}
@include describe("utilities-remove") {
@include it("removes a single utility") {
@include before ();
@include utilities-remove(align);
@include assert-equal(utilities-get-options(align), null);
}
@include it("removes a multiple utility") {
@include before ();
@include utilities-remove(align, margin);
@include assert-equal(utilities-get-options(align), null);
@include assert-equal(utilities-get-options(margin), null);
}
@include it("ignores non existing utilities") {
@include before ();
@include utilities-remove(unknown, flex, non-existing);
@include assert-equal(utilities-get-options(flex), null);
}
}
}
+1 -1
View File
@@ -7,7 +7,7 @@ $bd-purple-light: lighten(saturate($bd-purple, 5%), 45%); // stylelint-disable-
$bd-accent: #ffe484;
$bd-gutter-x: 3rem;
$bd-callout-variants: info, warning, danger !default;
$bd-callout-variants: info, warning, danger, success !default;
:root,
[data-bs-theme="light"] {
+2 -17
View File
@@ -473,7 +473,7 @@ Bootstrap doesn't include `color` and `background-color` utilities for every col
1. To start, make sure you've imported our functions, variables, mixins, and utilities.
2. Use our `map-merge-multiple()` function to quickly merge multiple Sass maps together in a new map.
3. Merge this new combined map to extend any utility with a `{color}-{level}` class name.
3. Use our [mixins for modifying the utilities map]({{< docsref "/utilities/api#modify-defaults" >}}) to merge the values to the existing ones
Here's an example that generates text color utilities (e.g., `.text-purple-500`) using the above steps.
@@ -487,22 +487,7 @@ Here's an example that generates text color utilities (e.g., `.text-purple-500`)
$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
),
),
),
),
)
);
@include utilities-add-values('color', $all-colors);
@import "bootstrap/scss/utilities/api";
```
+163 -149
View File
@@ -12,19 +12,19 @@ Bootstrap utilities are generated with our utility API and can be used to modify
The `$utilities` map contains all our utilities and is later merged with your custom `$utilities` map, if present. The utility map contains a keyed list of utility groups which accept the following options:
{{< bs-table "table table-utilities" >}}
| Option | Type | Default&nbsp;value | Description |
| --- | --- | --- | --- |
| [`property`](#property) | **Required** | | Name of the property, this can be a string or an array of strings (e.g., horizontal paddings or margins). |
| [`values`](#values) | **Required** | | List of values, or a map if you don't want the class name to be the same as the value. If `null` is used as map key, `class` is not prepended to the class name. |
| [`class`](#class) | Optional | null | Name of the generated class. If not provided and `property` is an array of strings, `class` will default to the first element of the `property` array. If not provided and `property` is a string, the `values` keys are used for the `class` names. |
| [`css-var`](#css-variable-utilities) | Optional | `false` | Boolean to generate CSS variables instead of CSS rules. |
| [`css-variable-name`](#css-variable-utilities) | Optional | null | Custom un-prefixed name for the CSS variable inside the ruleset. |
| [`local-vars`](#local-css-variables) | Optional | null | Map of local CSS variables to generate in addition to the CSS rules. |
| [`state`](#states) | Optional | null | List of pseudo-class variants (e.g., `:hover` or `:focus`) to generate. |
| [`responsive`](#responsive) | Optional | `false` | Boolean indicating if responsive classes should be generated. |
| `rfs` | Optional | `false` | Boolean to enable [fluid rescaling with RFS]({{< docsref "/getting-started/rfs" >}}). |
| [`print`](#print) | Optional | `false` | Boolean indicating if print classes need to be generated. |
| `rtl` | Optional | `true` | Boolean indicating if utility should be kept in RTL. |
| Option | Type | Default&nbsp;value | Description |
| ---------------------------------------------- | ------------ | ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`property`](#property) | **Required** | | Name of the property, this can be a string or an array of strings (e.g., horizontal paddings or margins). |
| [`values`](#values) | **Required** | | List of values, or a map if you don't want the class name to be the same as the value. If `null` is used as map key, `class` is not prepended to the class name. |
| [`class`](#class) | Optional | null | Name of the generated class. If not provided and `property` is an array of strings, `class` will default to the first element of the `property` array. If not provided and `property` is a string, the `values` keys are used for the `class` names. |
| [`css-var`](#css-variable-utilities) | Optional | `false` | Boolean to generate CSS variables instead of CSS rules. |
| [`css-variable-name`](#css-variable-utilities) | Optional | null | Custom un-prefixed name for the CSS variable inside the ruleset. |
| [`local-vars`](#local-css-variables) | Optional | null | Map of local CSS variables to generate in addition to the CSS rules. |
| [`state`](#states) | Optional | null | List of pseudo-class variants (e.g., `:hover` or `:focus`) to generate. |
| [`responsive`](#responsive) | Optional | `false` | Boolean indicating if responsive classes should be generated. |
| `rfs` | Optional | `false` | Boolean to enable [fluid rescaling with RFS]({{< docsref "/getting-started/rfs" >}}). |
| [`print`](#print) | Optional | `false` | Boolean indicating if print classes need to be generated. |
| `rtl` | Optional | `true` | Boolean indicating if utility should be kept in RTL. |
{{< /bs-table >}}
## API explained
@@ -366,25 +366,54 @@ All utilities generated by the API include `!important` to ensure they override
## Using the API
Now that you're familiar with how the utilities API works, learn how to add your own custom classes and modify our default utilities.
{{< callout success >}}
**New in v5.3.x!** We've added new mixins and functions to better help you use our utilities API. These replace our previous guidance of using Sass's built-in `map-merge()` function and add new functionality for [composing components with utilities](#get-values-and-options).
{{< /callout >}}
### Override utilities
Now that you're familiar with how the utilities API works, you can use it to modify our default utilities and even add your own custom utilities. This can be done in three ways:
Override existing utilities by using the same key. For example, if you want additional responsive overflow utility classes, you can do this:
1. [Creating your own `$utilities` map](#add-or-override-utilities) that gets automatically merged with our default `$utilities` map.
2. [Modify our defaults using mixins](#modify-defaults) to add or remove utilities, update specific options, or modify utility values.
3. You can also use functions to [get specific utility values](#get-values-and-options) for your own use in your Sass.
### Add or override utilities
Add new keys to create your own utilities and override existing utilities by using the same key.
If your code declares a `$utilities` map before importing `bootstrap/scss/utilities`, it'll be merged with our default map. Add new keys to create your own utilities and override existing utilities by using the same key.
```scss
$utilities: (
// Add a new cursor utility
"cursor": (
property: cursor,
class: cursor,
responsive: true,
values: auto pointer grab,
),
// Redefine the existing overflow utility
"overflow": (
responsive: true,
property: overflow,
values: visible hidden scroll auto,
),
);
@import 'bootstrap/scss/utilities';
@import 'bootstrap/scss/utilities/api';
```
### Add utilities
### Modify defaults
New utilities can be added to the default `$utilities` map with a `map-merge`. Make sure our required Sass files and `_utilities.scss` are imported first, then use the `map-merge` to add your additional utilities. For example, here's how to add a responsive `cursor` utility with three values.
After importing `bootstrap/scss/utilities`, you can use mixins to:
- Add or remove utilities
- Update utilities options, like `responsive`, `class`, `rtl`, etc
- Add, remove or update utility values
#### Add and remove utilities
The `utilities-add()` and `utilities-remove()` mixins let you add and remove utilities from the configuration. Adding an existing utility will completely override it.
```scss
@import "bootstrap/scss/functions";
@@ -394,24 +423,25 @@ New utilities can be added to the default `$utilities` map with a `map-merge`. M
@import "bootstrap/scss/mixins";
@import "bootstrap/scss/utilities";
$utilities: map-merge(
$utilities,
(
"cursor": (
property: cursor,
class: cursor,
responsive: true,
values: auto pointer grab,
)
)
);
// Adds a new cursor utility
@include utilities-add(cursor, (
property: cursor,
class: cursor,
responsive: true,
values: auto pointer grab,
));
// Removes user-select and shadow
@include utilities-remove(user-select, shadow);
@import "bootstrap/scss/utilities/api";
```
### Modify utilities
#### Update utility options
Modify existing utilities in the default `$utilities` map with `map-get` and `map-merge` functions. In the example below, we're adding an additional value to the `width` utilities. Start with an initial `map-merge` and then specify which utility you want to modify. From there, fetch the nested `"width"` map with `map-get` to access and modify the utility's options and values.
The `utilities-set-option()` and `utilities-set-options()` mixins let you configure one or several options of a utility. `utilities-set-options()` will merge the new options with the existing ones by default, but you can provide a third `$merge: false` argument to completely override them.
If the utility does not exist, both mixins will create a new one.
```scss
@import "bootstrap/scss/functions";
@@ -421,25 +451,93 @@ Modify existing utilities in the default `$utilities` map with `map-get` and `ma
@import "bootstrap/scss/mixins";
@import "bootstrap/scss/utilities";
$utilities: map-merge(
$utilities,
(
"width": map-merge(
map-get($utilities, "width"),
(
values: map-merge(
map-get(map-get($utilities, "width"), "values"),
(10: 10%),
),
),
),
)
);
// Modify existing overflow utility to be responsive
@include utilities-set-option(overflow, responsive, true);
@import "bootstrap/scss/utilities/api";
// Change an existing utility's class name
@include utilities-set-option(margin-start, class, ml);
// Make an existing utility responsive and override its values
@include utilities-set-options(line-height, (
responsive: true,
values: (
1: 1,
1.25: 1.25,
1.5: 1.5
inherit: inherit
)
));
@import 'bootstrap/scss/utilities/api';
```
#### Enable responsive
#### Update utility values
If you want to keep most of the default values for a utility and just add, remove, or update a few, replacing the `values` option can be overkill. Use the `utilities-add-values()` and `utilities-remove-values()` mixins to help you make more targeted updates.
```scss
@import "bootstrap/scss/functions";
@import "bootstrap/scss/variables";
@import "bootstrap/scss/variables-dark";
@import "bootstrap/scss/maps";
@import "bootstrap/scss/mixins";
@import 'bootstrap/scss/utilities';
// Adds new values to the flex utility
@include utilities-add-values(flex, (
none: none,
auto: auto
));
// Remove specific values from the flex-direction utility
@include utilities-remove-values(flex-direction, row-reverse, column-reverse);
@import 'bootstrap/scss/utilities/api';
```
### Get values and options
Use the `utilities-get-value()` function to get a specific value of a utility. This allows you to use and manipulate specific values from our utilities, like with Sass functions or `calc()`. It also lets you access values that can be modified by other utilities, like how `.bg-*`, `.text-*` and `.border-*` can be affected by `.bg-opacity-*`, `.text-opacity-*` or `.border-opacity-*` respectively.
```scss
@import "bootstrap/scss/functions";
@import "bootstrap/scss/variables";
@import "bootstrap/scss/variables-dark";
@import "bootstrap/scss/maps";
@import "bootstrap/scss/mixins";
@import "bootstrap/scss/utilities";
// The box will be configurable with the bg-opacity and text-opacity classes
.box {
padding: map-get($spacers, 3);
color: utilities-get-value(color, body);
background: utilities-get-value(background-color, body);
border: utilities-get-value(border, null);
}
```
This outputs the following:
```css
.box {
padding: 1rem;
color: rgba(var(--bs-body-color-rgb), var(--bs-text-opacity));
background: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity));
border: var(--bs-border-width) var(--bs-border-style) var(--bs-border-color);
}
```
This is likely the function you'll use the most, but you can also:
- Access all the values of a utility with `utilities-get-values()`, which will always return a map to simplify their processing
- Access a specific option with `utilities-get-option()`
- Access all of a utility's options with `utilities-get-options()`
## Practical examples
### Enable responsive
You can enable responsive classes for an existing set of utilities that are not currently responsive by default. For example, to make the `border` classes responsive:
@@ -449,16 +547,10 @@ You can enable responsive classes for an existing set of utilities that are not
@import "bootstrap/scss/variables-dark";
@import "bootstrap/scss/maps";
@import "bootstrap/scss/mixins";
@import "bootstrap/scss/utilities";
$utilities: map-merge(
$utilities, (
"border": map-merge(
map-get($utilities, "border"),
( responsive: true ),
),
)
);
@include utilities-set-option(border, responsive, true);
@import "bootstrap/scss/utilities/api";
```
@@ -495,9 +587,9 @@ This will now generate responsive variations of `.border` and `.border-0` for ea
}
```
#### Rename utilities
### Rename utilities
Missing v4 utilities, or used to another naming convention? The utilities API can be used to override the resulting `class` of a given utility—for example, to rename `.ms-*` utilities to oldish `.ml-*`:
Missing v4 utilities or another naming convention? Override the `class` option to change the output of a given utility. For example, to rename `.ms-*` utilities to `.ml-*`:
```scss
@import "bootstrap/scss/functions";
@@ -505,108 +597,30 @@ Missing v4 utilities, or used to another naming convention? The utilities API ca
@import "bootstrap/scss/variables-dark";
@import "bootstrap/scss/maps";
@import "bootstrap/scss/mixins";
@import "bootstrap/scss/utilities";
$utilities: map-merge(
$utilities, (
"margin-start": map-merge(
map-get($utilities, "margin-start"),
( class: ml ),
),
)
);
@include utilities-set-option(margin-start, class, ml);
@import "bootstrap/scss/utilities/api";
```
### Remove utilities
Remove any of the default utilities with the [`map-remove()` Sass function](https://sass-lang.com/documentation/modules/map#remove).
```scss
@import "bootstrap/scss/functions";
@import "bootstrap/scss/variables";
@import "bootstrap/scss/variables-dark";
@import "bootstrap/scss/maps";
@import "bootstrap/scss/mixins";
@import "bootstrap/scss/utilities";
// Remove multiple utilities with a comma-separated list
$utilities: map-remove($utilities, "width", "float");
@import "bootstrap/scss/utilities/api";
```
You can also use the [`map-merge()` Sass function](https://sass-lang.com/documentation/modules/map#merge) and set the group key to `null` to remove the utility.
```scss
@import "bootstrap/scss/functions";
@import "bootstrap/scss/variables";
@import "bootstrap/scss/variables-dark";
@import "bootstrap/scss/maps";
@import "bootstrap/scss/mixins";
@import "bootstrap/scss/utilities";
$utilities: map-merge(
$utilities,
(
"width": null
)
);
@import "bootstrap/scss/utilities/api";
```
### Add, remove, modify
You can add, remove, and modify many utilities all at once with the [`map-merge()` Sass function](https://sass-lang.com/documentation/modules/map#merge). Here's how you can combine the previous examples into one larger map.
```scss
@import "bootstrap/scss/functions";
@import "bootstrap/scss/variables";
@import "bootstrap/scss/variables-dark";
@import "bootstrap/scss/maps";
@import "bootstrap/scss/mixins";
@import "bootstrap/scss/utilities";
$utilities: map-merge(
$utilities,
(
// Remove the `width` utility
"width": null,
// Make an existing utility responsive
"border": map-merge(
map-get($utilities, "border"),
( responsive: true ),
),
// Add new utilities
"cursor": (
property: cursor,
class: cursor,
responsive: true,
values: auto pointer grab,
)
)
);
@import "bootstrap/scss/utilities/api";
```
#### Remove utility in RTL
### Remove utility in RTL
Some edge cases make [RTL styling difficult](https://rtlstyling.com/posts/rtl-styling#common-things-that-might-not-work-for-rtl), such as line breaks in Arabic. Thus utilities can be dropped from RTL output by setting the `rtl` option to `false`:
```scss
$utilities: (
"word-wrap": (
property: word-wrap word-break,
class: text,
values: (break: break-word),
rtl: false
),
);
@import "bootstrap/scss/functions";
@import "bootstrap/scss/variables";
@import "bootstrap/scss/variables-dark";
@import "bootstrap/scss/maps";
@import "bootstrap/scss/mixins";
@import "bootstrap/scss/utilities";
@include utilities-set-option(word-wrap, rtl, false);
@import "bootstrap/scss/utilities/api";
```
Output: