AI Generate Bootstrap docs instantly

Bootstrap Cheat Sheet

Quick reference guide with copy-paste ready code snippets

Try DocuWriter Free

Layout

3 snippets

Grid system and containers

Container

<div class="container">Fixed width</div>
<div class="container-fluid">Full width</div>
<div class="container-md">Responsive container</div>

Grid

<div class="row">
  <div class="col-md-8">Main content</div>
  <div class="col-md-4">Sidebar</div>
</div>

<div class="row row-cols-1 row-cols-md-3 g-4">
  <div class="col">Card 1</div>
  <div class="col">Card 2</div>
  <div class="col">Card 3</div>
</div>

Flex Utilities

<div class="d-flex justify-content-between align-items-center">
  <span>Left</span>
  <span>Right</span>
</div>
<div class="d-flex flex-column gap-3">

Components

4 snippets

Common UI components

Buttons

<button class="btn btn-primary">Primary</button>
<button class="btn btn-outline-secondary btn-sm">Small</button>
<button class="btn btn-danger btn-lg" disabled>Disabled</button>
<a href="#" class="btn btn-link">Link</a>

Card

<div class="card">
  <img src="..." class="card-img-top" alt="...">
  <div class="card-body">
    <h5 class="card-title">Title</h5>
    <p class="card-text">Description</p>
    <a href="#" class="btn btn-primary">Go</a>
  </div>
</div>

Alert & Badge

<div class="alert alert-success alert-dismissible fade show">
  Success! <button class="btn-close" data-bs-dismiss="alert"></button>
</div>
<span class="badge bg-primary">New</span>
<span class="badge rounded-pill bg-danger">99+</span>

Modal

<button data-bs-toggle="modal" data-bs-target="#myModal">Open</button>
<div class="modal fade" id="myModal">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">Title</h5>
        <button class="btn-close" data-bs-dismiss="modal"></button>
      </div>
      <div class="modal-body">Content</div>
      <div class="modal-footer">
        <button class="btn btn-primary">Save</button>
      </div>
    </div>
  </div>
</div>

Forms

4 snippets

Form controls and validation

Input & Select

<div class="mb-3">
  <label class="form-label">Email</label>
  <input type="email" class="form-control" placeholder="name@example.com">
</div>
<select class="form-select">
  <option selected>Choose...</option>
  <option value="1">One</option>
</select>

Checkbox & Radio

<div class="form-check">
  <input class="form-check-input" type="checkbox" id="check1">
  <label class="form-check-label" for="check1">Option</label>
</div>
<div class="form-check form-switch">
  <input class="form-check-input" type="checkbox" role="switch">
  <label class="form-check-label">Toggle</label>
</div>

Floating Labels

<div class="form-floating mb-3">
  <input type="email" class="form-control" id="email" placeholder="name@example.com">
  <label for="email">Email address</label>
</div>

Input Group

<div class="input-group">
  <span class="input-group-text">@</span>
  <input type="text" class="form-control" placeholder="Username">
  <button class="btn btn-primary">Search</button>
</div>

Tired of looking up syntax?

DocuWriter.ai generates documentation and explains code using AI.

Try Free

Utilities

4 snippets

Spacing, text, and display

Spacing

m-3     /* margin: 1rem */
mt-5    /* margin-top: 3rem */
px-4    /* padding-x: 1.5rem */
py-2    /* padding-y: 0.5rem */
mx-auto /* center horizontally */
gap-3   /* gap: 1rem */

Text & Colors

text-center text-md-start
text-primary text-muted text-white
fw-bold fw-light
fs-1 through fs-6
text-truncate
text-decoration-none

Display & Visibility

d-none d-md-block      /* Hidden on mobile */
d-block d-md-none      /* Mobile only */
d-flex d-inline-flex
invisible / visible
overflow-auto / overflow-hidden

Backgrounds & Borders

bg-primary bg-light bg-dark
bg-opacity-75
border border-primary
rounded rounded-pill rounded-circle
shadow shadow-sm shadow-lg

More Cheat Sheets

FAQ

Frequently asked questions

What is a Bootstrap cheat sheet?

A Bootstrap cheat sheet is a quick reference guide containing the most commonly used syntax, functions, and patterns in Bootstrap. It helps developers quickly look up syntax without searching through documentation.

How do I learn Bootstrap quickly?

Start with the basics: variables, control flow, and functions. Use this cheat sheet as a reference while practicing. For faster learning, try DocuWriter.ai to automatically explain code and generate documentation as you learn.

What are the most important Bootstrap concepts?

Key Bootstrap concepts include variables and data types, control flow (if/else, loops), functions, error handling, and working with data structures like arrays and objects/dictionaries.

How can I document my Bootstrap code?

Use inline comments for complex logic, docstrings for functions and classes, and README files for projects. DocuWriter.ai can automatically generate professional documentation from your Bootstrap code using AI.

Related resources

Stop memorizing. Start shipping.

Generate Bootstrap Docs with AI

DocuWriter.ai automatically generates comments, docstrings, and README files for your code.

Auto-generate comments
Create README files
Explain complex code
API documentation
Start Free - No Credit Card

Join 33,700+ developers saving hours every week