# bootstrap-5
> Comprehensive Bootstrap 5.3.8 reference and rules for building production-grade, creative Bootstrap interfaces. Covers all components, utilities, grid system, color modes, CSS variables, forms, helpers, accessibility, and best practices. Use this skill for ALL Bootstrap-based frontend work.
- Author: GavinHolder
- Repository: GavinHolder/ai-engineer
- Version: 20260208182400
- Stars: 0
- Forks: 0
- Last Updated: 2026-02-08
- Source: https://github.com/GavinHolder/ai-engineer
- Web: https://mule.run/skillshub/@@GavinHolder/ai-engineer~bootstrap-5:20260208182400
---
---
name: bootstrap-5
description: Comprehensive Bootstrap 5.3.8 reference and rules for building production-grade, creative Bootstrap interfaces. Covers all components, utilities, grid system, color modes, CSS variables, forms, helpers, accessibility, and best practices. Use this skill for ALL Bootstrap-based frontend work.
---
# Bootstrap 5.3 — Complete Reference & Rules
**CDN (latest stable 5.3.8):**
```html
```
**Bootstrap Icons:**
```html
```
**Required meta:**
```html
```
---
## Grid System
### Breakpoints
| Breakpoint | Class infix | Dimensions |
|---|---|---|
| Extra small | (none) | <576px |
| Small | `sm` | >=576px |
| Medium | `md` | >=768px |
| Large | `lg` | >=992px |
| Extra large | `xl` | >=1200px |
| XXL | `xxl` | >=1400px |
### Containers
| Class | xs | sm | md | lg | xl | xxl |
|---|---|---|---|---|---|---|
| `.container` | 100% | 540px | 720px | 960px | 1140px | 1320px |
| `.container-sm` | 100% | 540px | 720px | 960px | 1140px | 1320px |
| `.container-md` | 100% | 100% | 720px | 960px | 1140px | 1320px |
| `.container-lg` | 100% | 100% | 100% | 960px | 1140px | 1320px |
| `.container-xl` | 100% | 100% | 100% | 100% | 1140px | 1320px |
| `.container-xxl` | 100% | 100% | 100% | 100% | 100% | 1320px |
| `.container-fluid` | 100% | 100% | 100% | 100% | 100% | 100% |
### Columns
```html
```
- `.col` — equal width
- `.col-{1-12}` — specific width
- `.col-{breakpoint}-{1-12}` — responsive width
- `.col-auto` — natural width
- `.row-cols-{1-6}` / `.row-cols-{breakpoint}-{1-6}` — columns per row
- `.offset-{breakpoint}-{0-11}` — column offsets
- `.g-{0-5}` — gutters (both), `.gx-{0-5}` — horizontal, `.gy-{0-5}` — vertical
### Alignment
- `.align-items-{start|center|end|baseline|stretch}` — row vertical align
- `.align-self-{start|center|end|baseline|stretch}` — column vertical align
- `.justify-content-{start|center|end|between|around|evenly}` — horizontal align
- `.order-{0-5|first|last}` — column ordering
---
## All Components
### Accordion
```html
```
Variants: `.accordion-flush` (no borders/rounded corners)
### Alerts
```html
Primary alert
```
Colors: `alert-{primary|secondary|success|danger|warning|info|light|dark}`
Extras: `.alert-dismissible`, `.alert-link`, `.alert-heading`
Dismiss: ` `
### Badge
```html
Badge
Pill
```
Colors: `text-bg-{primary|secondary|success|danger|warning|info|light|dark}`
### Breadcrumb
```html
Home
Current
```
### Buttons
```html
Primary
Outline
Large
Small
```
Colors: `btn-{primary|secondary|success|danger|warning|info|light|dark|link}`
Outlines: `btn-outline-{same colors}`
Sizes: `btn-lg`, `btn-sm`
States: `.active`, `.disabled`, `aria-disabled="true"`
### Button Group
```html
Left
Middle
Right
```
Variants: `.btn-group-lg`, `.btn-group-sm`, `.btn-group-vertical`
### Card
```html
Title
Subtitle
Text content
Link
```
Parts: `.card-header`, `.card-body`, `.card-footer`, `.card-img-top`, `.card-img-bottom`, `.card-img-overlay`
Layouts: `.card-group`, `.row-cols-*` with cards
### Carousel
```html
```
Options: `data-bs-interval="5000"`, `.carousel-fade`, `.carousel-dark` (deprecated, use `data-bs-theme="dark"`)
### Collapse
```html
Toggle
```
Horizontal: `.collapse-horizontal`
### Dropdowns
```html
Dropdown
```
Directions: `.dropup`, `.dropend`, `.dropstart`, `.dropdown-center`
Alignment: `.dropdown-menu-end`, `.dropdown-menu-{breakpoint}-end`
Auto close: `data-bs-auto-close="true|inside|outside|false"`
### List Group
```html
```
Variants: `.list-group-flush`, `.list-group-numbered`, `.list-group-horizontal`
Colors: `list-group-item-{primary|secondary|success|danger|warning|info|light|dark}`
Actionable: ``
### Modal
```html
Open
```
Sizes: `.modal-sm`, `.modal-lg`, `.modal-xl`, `.modal-fullscreen`, `.modal-fullscreen-{breakpoint}-down`
Options: `.modal-dialog-centered`, `.modal-dialog-scrollable`
Backdrop: `data-bs-backdrop="static"` (no close on outside click)
### Navbar
```html
```
Color schemes: Use `data-bs-theme="dark"` on the nav element
Placement: `.fixed-top`, `.fixed-bottom`, `.sticky-top`, `.sticky-bottom`
### Navs & Tabs
```html
```
Layout: `.nav-fill`, `.nav-justified`, `.flex-column`
### Offcanvas
```html
Open
```
Placement: `.offcanvas-start`, `.offcanvas-end`, `.offcanvas-top`, `.offcanvas-bottom`
Responsive: `.offcanvas-{breakpoint}` (offcanvas below breakpoint, normal above)
Options: `data-bs-scroll="true"`, `data-bs-backdrop="static"`
### Pagination
```html
```
Sizes: `.pagination-lg`, `.pagination-sm`
Alignment: wrap in `.justify-content-center` or `.justify-content-end`
### Progress
```html
```
Variants: `.progress-bar-striped`, `.progress-bar-animated`, `.bg-{color}`
Stacked: Multiple `.progress-bar` inside one `.progress`
### Spinners
```html
Loading...
Loading...
```
Sizes: `.spinner-border-sm`, `.spinner-grow-sm`
### Toasts
```html
```
Container: `.toast-container` with positioning classes
Options: `data-bs-autohide="false"`, `data-bs-delay="5000"`
JS: `const toast = new bootstrap.Toast(el); toast.show();`
### Tooltips (opt-in, requires JS init)
```html
Hover me
```
Placement: `data-bs-placement="top|right|bottom|left"`
HTML: `data-bs-html="true"`
### Popovers (opt-in, requires JS init)
```html
Click me
```
Trigger: `data-bs-trigger="hover|focus|click|manual"`
Dismiss on next click: `data-bs-trigger="focus"`
### Scrollspy
```html
...
```
### Placeholders (loading skeletons)
```html
```
Animations: `.placeholder-glow`, `.placeholder-wave`
Sizes: `.placeholder-lg`, `.placeholder-sm`, `.placeholder-xs`
---
## Forms
### Form Controls
```html
Message
```
Sizes: `.form-control-lg`, `.form-control-sm`
Readonly: `readonly`, `.form-control-plaintext` (readonly no border)
Color: ` `
### Select
```html
Choose...
One
```
Sizes: `.form-select-lg`, `.form-select-sm`
Multiple: `multiple`, `size="3"`
### Checks, Radios, Switches
```html
Check me
Radio
Switch
...
```
### Floating Labels
```html
Email address
```
### Input Group
```html
@
Search
```
### Range
```html
```
### Validation
```html
```
Server-side: `.is-valid`, `.is-invalid` classes directly on inputs
---
## Color Modes (Dark Mode — 5.3+)
### Setup
```html
```
### Toggle via JS
```javascript
function setTheme(theme) {
document.documentElement.setAttribute('data-bs-theme', theme);
localStorage.setItem('theme', theme);
}
// Auto-detect system preference
const preferred = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
setTheme(localStorage.getItem('theme') || preferred);
```
### Color-mode-aware classes (adapt per theme)
- `text-bg-{color}` — combined text + background
- `.bg-body`, `.bg-body-secondary`, `.bg-body-tertiary` — adapt to mode
- `.text-body`, `.text-body-emphasis`, `.text-body-secondary`, `.text-body-tertiary`
- `.bg-{color}-subtle` — subtle background per color
- `.text-{color}-emphasis` — emphasis text per color
- `.border-{color}-subtle` — subtle border per color
### Scoped themes
```html
This section and all Bootstrap components inside adapt to dark mode
```
---
## Utility Classes — Quick Reference
### Spacing
`{m|p}{t|b|s|e|x|y}-{0|1|2|3|4|5|auto}` — margin/padding, sides, sizes
Responsive: `{m|p}{side}-{breakpoint}-{size}`
### Display
`.d-{none|inline|inline-block|block|grid|inline-grid|table|table-row|table-cell|flex|inline-flex}`
Responsive: `.d-{breakpoint}-{value}`
Print: `.d-print-{value}`
### Flex
`.flex-{row|column|row-reverse|column-reverse}`, `.flex-wrap`, `.flex-nowrap`
`.justify-content-{start|end|center|between|around|evenly}`
`.align-items-{start|end|center|baseline|stretch}`
`.align-self-{start|end|center|baseline|stretch}`
`.flex-grow-{0|1}`, `.flex-shrink-{0|1}`, `.gap-{0-5}`
### Text
`.text-{start|end|center}`, `.text-{breakpoint}-{start|end|center}`
`.fs-{1|2|3|4|5|6}` — font sizes
`.fw-{bold|bolder|semibold|medium|normal|light|lighter}`, `.fst-{italic|normal}`
`.text-decoration-{none|underline|line-through}`
`.text-{lowercase|uppercase|capitalize}`
`.text-truncate`, `.text-break`, `.text-nowrap`
`.lh-{1|sm|base|lg}`
### Colors
`.text-{primary|secondary|success|danger|warning|info|light|dark|body|body-emphasis|body-secondary|body-tertiary|black|white|muted}`
`.bg-{primary|secondary|success|danger|warning|info|light|dark|body|body-secondary|body-tertiary|black|white|transparent}`
`.text-opacity-{25|50|75|100}`, `.bg-opacity-{10|25|50|75|100}`
### Borders
`.border`, `.border-{top|end|bottom|start}`, `.border-0`, `.border-{side}-0`
`.border-{primary|secondary|success|danger|warning|info|light|dark|white|black}`
`.border-{1|2|3|4|5}` — width
`.rounded`, `.rounded-{0|1|2|3|4|5|circle|pill|top|end|bottom|start}`
### Shadows
`.shadow-none`, `.shadow-sm`, `.shadow`, `.shadow-lg`
### Position
`.position-{static|relative|absolute|fixed|sticky}`
`.top-{0|50|100}`, `.start-{0|50|100}`, `.bottom-{0|50|100}`, `.end-{0|50|100}`
`.translate-middle`, `.translate-middle-x`, `.translate-middle-y`
### Sizing
`.w-{25|50|75|100|auto}`, `.h-{25|50|75|100|auto}`
`.mw-100`, `.mh-100`, `.min-vw-100`, `.min-vh-100`, `.vw-100`, `.vh-100`
### Overflow
`.overflow-{auto|hidden|visible|scroll}`
`.overflow-x-{auto|hidden|visible|scroll}`, `.overflow-y-{auto|hidden|visible|scroll}`
### Visibility
`.visible`, `.invisible`
`.visually-hidden`, `.visually-hidden-focusable`
### Z-index
`.z-{n1|0|1|2|3}` (n1 = -1)
### Opacity
`.opacity-{0|25|50|75|100}`
### Object Fit
`.object-fit-{contain|cover|fill|scale|none}`, `.object-fit-{breakpoint}-{value}`
### Float
`.float-{start|end|none}`, `.float-{breakpoint}-{start|end|none}`
### Interactions
`.user-select-{all|auto|none}`, `.pe-{none|auto}` (pointer events)
---
## Helpers
- `.clearfix` — clear floats
- `.text-truncate` — single-line ellipsis
- `.vstack` — vertical flex stack with gap
- `.hstack` — horizontal flex stack with gap
- `.stretched-link` — make parent clickable
- `.ratio.ratio-{1x1|4x3|16x9|21x9}` — aspect ratios
- `.visually-hidden` — screen reader only
- `.focus-ring` / `.focus-ring-{color}` — custom focus styles
- `.icon-link` / `.icon-link-hover` — icon + text links
- `.link-opacity-{10|25|50|75|100}` — link transparency
- `.link-underline-{color}` — colored underlines
- `.link-offset-{1|2|3}` — underline offset
---
## Data Attributes Quick Reference
| Attribute | Use |
|---|---|
| `data-bs-toggle="collapse\|modal\|dropdown\|tab\|pill\|offcanvas\|tooltip\|popover\|button"` | Toggle components |
| `data-bs-dismiss="alert\|modal\|offcanvas\|toast"` | Dismiss components |
| `data-bs-target="#id"` | Target element |
| `data-bs-parent="#id"` | Accordion parent |
| `data-bs-ride="carousel"` | Auto-start carousel |
| `data-bs-slide="prev\|next"` | Carousel direction |
| `data-bs-theme="light\|dark"` | Color mode |
| `data-bs-backdrop="static"` | Prevent dismiss on click outside |
| `data-bs-scroll="true"` | Allow body scroll (offcanvas) |
| `data-bs-spy="scroll"` | Enable scrollspy |
| `data-bs-smooth-scroll="true"` | Smooth scroll (scrollspy) |
| `data-bs-placement="top\|right\|bottom\|left"` | Tooltip/popover position |
| `data-bs-trigger="hover\|focus\|click"` | Tooltip/popover trigger |
| `data-bs-title="text"` | Tooltip text |
| `data-bs-content="text"` | Popover body |
| `data-bs-interval="5000"` | Carousel interval |
| `data-bs-autohide="false"` | Persistent toast |
| `data-bs-delay="5000"` | Toast auto-hide delay |
| `data-bs-config='{...}'` | JSON options (any component) |
---
## JS Initialization Pattern
```javascript
document.addEventListener('DOMContentLoaded', () => {
// Tooltips (opt-in)
document.querySelectorAll('[data-bs-toggle="tooltip"]').forEach(el => new bootstrap.Tooltip(el));
// Popovers (opt-in)
document.querySelectorAll('[data-bs-toggle="popover"]').forEach(el => new bootstrap.Popover(el));
// Form validation
document.querySelectorAll('.needs-validation').forEach(form => {
form.addEventListener('submit', e => {
if (!form.checkValidity()) { e.preventDefault(); e.stopPropagation(); }
form.classList.add('was-validated');
});
});
});
```
---
## CSS Variables Customization (No Sass Required)
Override Bootstrap's look with CSS variables directly:
```css
:root {
--bs-primary: #your-color;
--bs-primary-rgb: r, g, b;
--bs-body-font-family: 'Your Font', sans-serif;
--bs-body-bg: #0a0a0a;
--bs-body-color: #e0e0e0;
--bs-border-radius: 0.5rem;
--bs-link-color: #your-accent;
}
```
Per-component overrides:
```html
Custom
...
```
---
## Starter Template
```html
Page Title
Hello World
Start building here.
```
---
## Rules for Creative Bootstrap Work
1. **ALWAYS use the latest CDN** (5.3.8) — never hardcode older versions
2. **ALWAYS use color-mode-aware classes** (`bg-body`, `text-body-emphasis`, `bg-body-tertiary`) instead of hardcoded colors — these adapt to light/dark mode automatically
3. **ALWAYS use `text-bg-{color}`** for badges, alerts, and colored elements — combines text + bg correctly
4. **ALWAYS initialize tooltips and popovers** with JS — they are opt-in
5. **ALWAYS add `aria-*` attributes** for interactive components (modals, accordions, dropdowns, navbars)
6. **ALWAYS use `.visually-hidden`** for accessible text in icon-only buttons and spinners
7. **Use `data-bs-theme` for dark mode** — not deprecated `.navbar-dark` or `.carousel-dark`
8. **Customize via CSS variables** — not inline styles for colors. Override `--bs-*` variables.
9. **Combine with animation libraries** — Bootstrap handles layout and components; pair with GSAP, AOS, or CSS animations for motion
10. **Override the default look** — Bootstrap is a starting point, not the finish. Custom fonts, colors, and spacing make it distinctive