---
name: bootstrap-utilities
description: This skill should be used when the user asks about Bootstrap utilities, Bootstrap spacing utilities, Bootstrap margin utilities, Bootstrap padding utilities, Bootstrap display utilities, Bootstrap flex utilities, Bootstrap text utilities, Bootstrap color utilities, Bootstrap background utilities, Bootstrap border utilities, Bootstrap shadow utilities, Bootstrap sizing utilities, Bootstrap position utilities, Bootstrap visibility utilities, Bootstrap overflow utilities, Bootstrap opacity utilities, Bootstrap float utilities, Bootstrap vertical align utilities, Bootstrap link utilities, or needs help with Bootstrap utility classes.
---
# Bootstrap 5.3 Utilities
Bootstrap provides extensive utility classes for rapid styling without custom CSS. These are generated via the Utilities API and can be customized.
## Spacing Utilities
### Margin (m-) and Padding (p-)
```html
Margin 1rem all sides
Padding 1rem all sides
Margin top
Margin bottom
Margin start (left in LTR)
Margin end (right in LTR)
Margin horizontal (left + right)
Margin vertical (top + bottom)
Horizontal padding 1rem, vertical 0.5rem
```
### Spacing Scale
| Class | Size |
|-------|------|
| `{m\|p}-0` | 0 |
| `{m\|p}-1` | 0.25rem (4px) |
| `{m\|p}-2` | 0.5rem (8px) |
| `{m\|p}-3` | 1rem (16px) |
| `{m\|p}-4` | 1.5rem (24px) |
| `{m\|p}-5` | 3rem (48px) |
| `{m\|p}-auto` | auto (margin only) |
### Responsive Spacing
```html
No margin, 1rem on md, 3rem on lg+
```
### Gap Utilities (Flexbox/Grid)
```html
Button 1
Button 2
...
```
## Display Utilities
```html
Hidden
Inline
Inline-block
Block
Flexbox
Inline flex
Grid
Table
Table row
Table cell
Hidden on xs/sm, block on md+
Visible until lg
Hidden in print
Only visible in print
```
## Text Utilities
### Alignment
```html
Left aligned (start)
Center aligned
Right aligned (end)
Left on xs/sm, center on md, right on lg+
```
### Transform
```html
lowercased text
UPPERCASED TEXT
Capitalized Text
```
### Decoration
```html
No underline
Underlined text
Strikethrough text
```
### Wrapping and Overflow
```html
Text that wraps normally
Text that won't wrap
Longwordthatwillbreaktopreventoverflow
This text is truncated with ellipsis...
```
### Font Weight and Style
```html
Bold text
Bolder text (relative)
Semibold text
Medium text
Normal weight
Light text
Lighter text (relative)
Italic text
Normal style
```
### Line Height
```html
Line height 1
Small line height
Base line height
Large line height
```
## Flexbox Utilities
### Direction
```html
Horizontal
Horizontal reversed
Vertical
Vertical reversed
```
### Justify Content
```html
Start
End
Center
Space between
Space around
Space evenly
```
### Align Items
```html
Top
Bottom
Center
Baseline
Stretch
```
### Align Self
```html
Top
Center
Bottom
```
### Flex Wrap
```html
Wrap
No wrap
Wrap reverse
```
### Flex Grow/Shrink
```html
Don't grow
Grow to fill
Don't shrink
Can shrink
Fill available space
```
### Order
```html
First
Second
Third
Very first (-1)
Very last (6)
```
## Background Utilities
```html
Primary
Secondary
Success
Danger
Warning
Info
Light
Dark
Body
Body secondary
Body tertiary
White
Black
Transparent
75%
50%
25%
10%
Gradient
```
## Text Color Utilities
```html
Primary text
Secondary text
Success text
Danger text
Warning text
Info text
Muted text
Body text
Body secondary
Body tertiary
Body emphasis
Black text
White text
75% opacity
50% opacity
25% opacity
```
## Border Utilities
```html
All sides
Top
End
Bottom
Start
No border
No top border
Primary
Success
Danger
1px
2px
3px
4px
5px
Rounded
No radius
Small radius
Default radius
Large radius
XL radius
XXL radius
Circle
Pill
Top only
End only
Bottom only
Start only
```
## Shadow Utilities
```html
No shadow
Small shadow
Regular shadow
Large shadow
```
## Sizing Utilities
### Width
```html
25% width
50% width
75% width
100% width
Auto width
Max-width 100%
100vw
Min 100vw
```
### Height
```html
25% height
50% height
75% height
100% height
Auto height
Max-height 100%
100vh
Min 100vh
```
## Position Utilities
### Position Values
```html
Static (default)
Relative
Absolute
Fixed
Sticky
```
### Placement
```html
Top left
Top right
Bottom left
Bottom right
Center (needs transform)
```
### Centering with Translate
```html
Perfectly centered
Horizontally centered
Vertically centered
```
### Common Pattern: Badge Positioning
```html
Notifications
99+
```
## Overflow Utilities
```html
Auto
Hidden
Visible
Scroll
Horizontal auto
Horizontal hidden
Vertical auto
Vertical hidden
```
## Opacity Utilities
```html
100%
75%
50%
25%
0%
```
## Visibility Utilities
```html
Visible
Invisible (takes space)
```
## Z-Index Utilities
```html
-1
0
1
2
3
```
## Object Fit Utilities
```html
```
## Interaction Utilities
```html
Select all on click
Default selection
Cannot select
Pointer events none
Pointer events auto
```
## Float Utilities
Float utilities position elements to the left or right of their container, allowing text to wrap around them.
```html
Float start (left in LTR)
Float end (right in LTR)
No float
Float start on sm+
Float end on md+
No float on lg+
```
| Class | Description |
|-------|-------------|
| `float-start` | Float left (LTR) |
| `float-end` | Float right (LTR) |
| `float-none` | Remove float |
Responsive: `float-{breakpoint}-{start|end|none}`
**Note**: Modern layouts typically use flexbox or grid instead of floats. Floats remain useful for wrapping text around images.
## Vertical Align Utilities
Control vertical alignment of inline, inline-block, inline-table, and table cell elements.
```html
baseline
top
middle
bottom
text-top
text-bottom
```
| Class | Alignment |
|-------|-----------|
| `align-baseline` | Baseline (default) |
| `align-top` | Top of line |
| `align-middle` | Middle of line |
| `align-bottom` | Bottom of line |
| `align-text-top` | Top of parent's font |
| `align-text-bottom` | Bottom of parent's font |
**Note**: These work on inline/inline-block elements and table cells, not block elements. For block vertical alignment, use flexbox (`align-items-*`).
## Link Utilities
Style links with opacity, underline color, offset, and hover effects. Added in Bootstrap 5.3.
```html
10% opacity
25% opacity
50% opacity
75% opacity
100% opacity
50% on hover
Primary underline
Secondary underline
Success underline
1 offset
2 offset
3 offset
No underline
25% underline
50% underline
Styled link
```
| Class | Description |
|-------|-------------|
| `link-opacity-{10\|25\|50\|75\|100}` | Link text opacity |
| `link-opacity-{value}-hover` | Opacity on hover |
| `link-underline-{color}` | Underline color |
| `link-offset-{1\|2\|3}` | Underline distance |
| `link-underline-opacity-{0\|10\|25\|50\|75\|100}` | Underline opacity |
## Utilities API
Bootstrap's utilities are generated via a Sass-based API, allowing full customization.
### API Structure
Each utility is defined as a map with these key options:
| Option | Description |
|--------|-------------|
| `property` | CSS property name (required) |
| `values` | List or map of values (required) |
| `class` | Custom class prefix (optional) |
| `responsive` | Generate responsive variants (default: false) |
| `print` | Generate print variants (default: false) |
| `state` | Generate state variants like `:hover` |
| `css-var` | Output as CSS variables instead of rules |
| `css-variable-name` | Custom CSS variable name (with css-var) |
| `local-vars` | Map of local CSS variables |
| `rfs` | Enable fluid rescaling (default: false) |
| `rtl` | Include in RTL output (default: true) |
**Note**: All utilities include `!important` by default. Disable globally with `$enable-important-utilities: false`.
### Adding Custom Utilities
```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,
(
"cursor": (
property: cursor,
class: cursor,
responsive: true,
values: auto pointer grab grabbing not-allowed
)
)
);
@import "bootstrap/scss/utilities/api";
```
### Modifying Existing Utilities
```scss
// Add responsive variants to an existing utility
$utilities: map-merge(
$utilities,
(
"overflow": map-merge(
map-get($utilities, "overflow"),
(responsive: true)
)
)
);
```
### Removing Utilities
```scss
// Remove entirely
$utilities: map-remove($utilities, "float");
// Or set to null
$utilities: map-merge($utilities, ("float": null));
```
## Common Patterns
Frequently-used utility combinations for real-world scenarios.
### Centered Container (Full Viewport)
```html
Perfectly Centered
Both horizontally and vertically
```
### Sticky Footer Layout
```html
Main content
```
### Card with Spacing and Shadow
```html
```
### Responsive Hide/Show
```html
Desktop only
Mobile only
```
### Icon + Text Alignment
```html
...
Text aligned with icon
```
## When to Use Utilities vs Custom CSS
| Scenario | Recommended Approach |
|----------|---------------------|
| One-off spacing adjustment | Utility classes (`mt-3`, `p-4`) |
| Consistent component styling | Custom component class |
| Responsive show/hide | Display utilities (`d-none d-md-block`) |
| Complex hover/focus states | Custom CSS |
| Values not in Bootstrap scale | Extend via Utilities API or custom CSS |
| Repeated pattern (3+ times) | Extract to custom class |
| Quick prototype | Utilities for speed |
| Production component | Consider extracting repeated utilities |
**Rule of thumb**: If you're applying the same combination of 4+ utilities to multiple elements, consider creating a custom class.
## Additional Resources
### Reference Files
- `references/utilities-reference.md` - Complete utility class reference
- `references/api-customization.md` - Advanced Sass customization examples
### Example Files
- `examples/card-layout.html` - Card styling with spacing, shadows, and borders
- `examples/responsive-utilities.html` - Responsive display and spacing patterns
- `examples/flex-centering.html` - Flexbox centering techniques