Skip to content

Commit 8033975

Browse files
authored
Document how to make utilities responsive using the API (#34062)
1 parent e06e6df commit 8033975

File tree

1 file changed

+51
-0
lines changed
  • site/content/docs/5.0/utilities

1 file changed

+51
-0
lines changed

site/content/docs/5.0/utilities/api.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,57 @@ $utilities: map-merge(
289289
);
290290
```
291291

292+
#### Enable responsive
293+
294+
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:
295+
296+
```scss
297+
@import "bootstrap/scss/functions";
298+
@import "bootstrap/scss/variables";
299+
@import "bootstrap/scss/utilities";
300+
301+
$utilities: map-merge(
302+
$utilities, (
303+
"border": map-merge(
304+
map-get($utilities, "border"),
305+
( responsive: true ),
306+
),
307+
)
308+
);
309+
```
310+
311+
This will now generate responsive variations of `.border` and `.border-0` for each breakpoint. Your generated CSS will look like this:
312+
313+
```css
314+
.border { ... }
315+
.border-0 { ... }
316+
317+
@media (min-width: 576px) {
318+
.border-sm { ... }
319+
.border-sm-0 { ... }
320+
}
321+
322+
@media (min-width: 768px) {
323+
.border-md { ... }
324+
.border-md-0 { ... }
325+
}
326+
327+
@media (min-width: 992px) {
328+
.border-lg { ... }
329+
.border-lg-0 { ... }
330+
}
331+
332+
@media (min-width: 1200px) {
333+
.border-xl { ... }
334+
.border-xl-0 { ... }
335+
}
336+
337+
@media (min-width: 1400px) {
338+
.border-xxl { ... }
339+
.border-xxl-0 { ... }
340+
}
341+
```
342+
292343
#### Rename utilities
293344

294345
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-*`:

0 commit comments

Comments
 (0)