Bootstrap

Containers are used to pad the content inside of them, and there are two container classes available:

  1. The .container class provides a responsive fixed width container
  2. The .container-fluid class provides a full width container, spanning the entire width of the viewport

Fixed Container

Use the .container class to create a responsive, fixed-width container.

Note that its width (max-width) will change on different screen sizes:

Extra small
<576px
Small
≥576px
Medium
≥768px
Large
≥992px
Extra large
≥1200px
max-width100%540px720px960px1140px

Open the example below and resize the browser window to see that the container width will change at different breakpoints:

Example

<div class=”container”>
  <h1>My First Bootstrap Page</h1>
  <p>This is some text.</p>
</div>

Fluid Container

Use the .container-fluid class to create a full width container, that will always span the entire width of the screen (width is always 100%):

Example

<div class=”container-fluid”>
  <h1>My First Bootstrap Page</h1>


  <p>This is some text.</p>
</div>

Responsive Containers

You can also use the .container-sm|md|lg|xl classes to create responsive containers.

The max-width of the container will change on different screen sizes/viewports:

ClassExtra small
<576px
Small
≥576px
Medium
≥768px
Large
≥992px
Extra large
≥1200px
.container-sm100%540px720px960px1140px
.container-md100%100%720px960px1140px
.container-lg100%100%100%960px1140px
.container-xl100%100%100%100%1140px

Example

<div class=”container-sm”>.container-sm</div>
<div class=”container-md”>.container-md</div>
<div class=”container-lg”>.container-lg</div>
<div class=”container-xl”>.container-xl</div>

Bootstrap 4 Grid System

Bootstrap’s grid system is built with flexbox and allows up to 12 columns across the page.

If you do not want to use all 12 columns individually, you can group the columns together to create wider columns:

The grid system is responsive, and the columns will re-arrange automatically depending on the screen size.

Make sure that the sum adds up to 12 or fewer (it is not required that you use all 12 available columns).

Grid Classes

The Bootstrap 4 grid system has five classes:

  • .col- (extra small devices – screen width less than 576px)
  • .col-sm- (small devices – screen width equal to or greater than 576px)
  • .col-md- (medium devices – screen width equal to or greater than 768px)
  • .col-lg- (large devices – screen width equal to or greater than 992px)
  • .col-xl- (xlarge devices – screen width equal to or greater than 1200px)

The classes above can be combined to create more dynamic and flexible layouts.

Tip: Each class scales up, so if you wish to set the same widths for sm and md, you only need to specify sm.

Basic Structure of a Bootstrap 4 Grid

The following is a basic structure of a Bootstrap 4 grid:

<!– Control the column width, and how they should appear on different devices –>
<div class=”row”>
  <div class=”col-*-*”></div>
  <div class=”col-*-*”></div>
</div>
<div class=”row”>
  <div class=”col-*-*”></div>
  <div class=”col-*-*”></div>
  <div class=”col-*-*”></div>
</div>

<!– Or let Bootstrap automatically handle the layout –>
<div class=”row”>
  <div class=”col”></div>
  <div class=”col”></div>
  <div class=”col”></div>
</div>

First example: create a row (<div class="row">). Then, add the desired number of columns (tags with appropriate .col-*-* classes). The first star (*) represents the responsiveness: sm, md, lg or xl, while the second star represents a number, which should add up to 12 for each row.

Second example: instead of adding a number to each col, let bootstrap handle the layout, to create equal width columns: two "col" elements = 50% width to each col. three cols = 33.33% width to each col. four cols = 25% width, etc. You can also use .col-sm|md|lg|xl to make the columns responsive.

Below we have collected some examples of basic Bootstrap 4 grid layouts.

Three Equal Columns

.col

.col

.col

The following example shows how to create three equal-width columns, on all devices and screen widths:

Example

<div class=”row”>
  <div class=”col”>.col</div>
  <div class=”col”>.col</div>
  <div class=”col”>.col</div>
</div>

Responsive Columns

.col-sm-3

.col-sm-3

.col-sm-3

.col-sm-3

The following example shows how to create four equal-width columns starting at tablets and scaling to extra large desktops. On mobile phones or screens that are less than 576px wide, the columns will automatically stack on top of each other:

Example

<div class=”row”>
  <div class=”col-sm-3″>.col-sm-3</div>
  <div class=”col-sm-3″>.col-sm-3</div>
  <div class=”col-sm-3″>.col-sm-3</div>
  <div class=”col-sm-3″>.col-sm-3</div>
</div>

Two Unequal Responsive Columns

.col-sm-4

.col-sm-8

The following example shows how to get two various-width columns starting at tablets and scaling to large extra desktops:

Example

<div class=”row”>
  <div class=”col-sm-4″>.col-sm-4</div>
  <div class=”col-sm-8″>.col-sm-8</div>
</div>

Bootstrap 4 Text/Typography

Bootstrap 4 Default Settings

Bootstrap 4 uses a default font-size of 16px, and its line-height is 1.5.

The default font-family is “Helvetica Neue”, Helvetica, Arial, sans-serif.

In addition, all <p> elements have margin-top: 0 and margin-bottom: 1rem (16px by default).

ClassDescriptionExample
.font-weight-boldBold text
.font-weight-bolderBolder text
.font-italicItalic text
.font-weight-lightLight weight text
.font-weight-lighterLighter weight text
.font-weight-normalNormal text
.leadMakes a paragraph stand out
.smallIndicates smaller text (set to 80% of the size of the parent)
.text-leftIndicates left-aligned text
.text-*-leftIndicates left-aligned text on small, medium, large or xlarge screens
.text-breakPrevents long text from breaking layout
.text-centerIndicates center-aligned text
.text-*-centerIndicates center-aligned text on small, medium, large or xlarge screens
.text-decoration-noneRemoves the underline from a link
.text-rightIndicates right-aligned text
.text-*-rightIndicates right-aligned text on small, medium, large or xlarge screens
.text-justifyIndicates justified text
.text-monospaceMonospaced text
.text-nowrapIndicates no wrap text
.text-lowercaseIndicates lowercased text
.text-resetResets the color of a text or a link (inherits the color from its parent)
.text-uppercaseIndicates uppercased text
.text-capitalizeIndicates capitalized text
.initialismDisplays the text inside an <abbr> element in a slightly smaller font size
.list-unstyledRemoves the default list-style and left margin on list items (works on both <ul> and <ol>). This class only applies to immediate children list items (to remove the default list-style from any nested lists, apply this class to any nested lists as well)
.list-inlinePlaces all list items on a single line (used together with .list-inline-item on each <li> elements)
.pre-scrollableMakes a <pre> element scrollable

Bootstrap 4 Colors

Text Colors

Bootstrap 4 has some contextual classes that can be used to provide “meaning through colors”.

The classes for text colors are: .text-muted, .text-primary, .text-success, .text-info, .text-warning, .text-danger, .text-secondary, .text-white, .text-dark, .text-body (default body color/often black) and .text-light:

Background Colors

The classes for background colors are: .bg-primary, .bg-success, .bg-info, .bg-warning, .bg-danger, .bg-secondary, .bg-dark and .bg-light.

Note that background colors do not set the text color, so in some cases you’ll want to use them together with a .text-* class.

Bootstrap 4 Basic Table

A basic Bootstrap 4 table has a light padding and horizontal dividers.

The .table class adds basic styling to a table:

Bordered Table

The .table-bordered class adds borders on all sides of the table and cells

Hover Rows

The .table-hover class adds a hover effect (grey background color) on table rows

Black/Dark Table

The .table-dark class adds a black background to the table

Dark Striped Table

Combine .table-dark and .table-striped to create a dark, striped table

Hoverable Dark Table

The .table-hover class adds a hover effect (grey background color) on table rows

Borderless Table

The .table-borderless class removes borders from the table

The contextual classes that can be used are:

ClassDescription
.table-primaryBlue: Indicates an important action
.table-successGreen: Indicates a successful or positive action
.table-dangerRed: Indicates a dangerous or potentially negative action
.table-infoLight blue: Indicates a neutral informative change or action
.table-warningOrange: Indicates a warning that might need attention
.table-activeGrey: Applies the hover color to the table row or table cell
.table-secondaryGrey: Indicates a slightly less important action
.table-lightLight grey table or table row background
.table-darkDark grey table or table row background

Responsive Tables

The .table-responsive class creates a responsive table: an horizontal scrollbar is added to the table on screens that are less than 992px wide (if needed). When viewing on anything larger than 992px wide, there is no difference

You can also decide when the table should get a scrollbar, depending on screen width:

ClassScreen width
.table-responsive-sm< 576px
.table-responsive-md< 768px
.table-responsive-lg< 992px
.table-responsive-xl< 1200px

Example

<div class=”table-responsive-sm”>
  <table class=”table”>
    …
  </table>
</div>

Bootstrap 4 Images

Rounded Corners

The .rounded class adds rounded corners to an image:

Example

<img src=”cinqueterre.jpg” class=”rounded” alt=”Cinque Terre”>

Circle

The .rounded-circle class shapes the image to a circle:

Example

<img src=”cinqueterre.jpg” class=”rounded-circle” alt=”Cinque Terre”>

Bootstrap 4 Jumbotron

A jumbotron indicates a big grey box for calling extra attention to some special content or information.

Bootstrap 4 Alerts

Alerts are created with the .alert class, followed by one of the contextual classes .alert-success, .alert-info, .alert-warning, .alert-danger, .alert-primary, .alert-secondary, .alert-light or .alert-dark:

Example

<div class=”alert alert-success”>
  <strong>Success!</strong> Indicates a successful or positive action.
</div>

Alert Links

Add the alert-link class to any links inside the alert box to create “matching colored links”:

<div class=”alert alert-success”>
  <strong>Success!</strong> You should <a href=”#” class=”alert-link”>read this message</a>.
</div>

Closing Alerts

To close the alert message, add a .alert-dismissible class to the alert container. Then add class="close" and data-dismiss="alert" to a link or a button element (when you click on this the alert box will disappear).

<div class=”alert alert-success alert-dismissible”>
  <button type=”button” class=”close” data-dismiss=”alert”>&times;</button>
  <strong>Success!</strong> Indicates a successful or positive action.
</div>  

Button Outline

Bootstrap 4 provides eight outline/bordered buttons:

Example

<button type=”button” class=”btn btn-outline-primary”>Primary</button>
<button type=”button” class=”btn btn-outline-secondary”>Secondary</button>
<button type=”button” class=”btn btn-outline-success”>Success</button>
<button type=”button” class=”btn btn-outline-info”>Info</button>
<button type=”button” class=”btn btn-outline-warning”>Warning</button>
<button type=”button” class=”btn btn-outline-danger”>Danger</button>
<button type=”button” class=”btn btn-outline-dark”>Dark</button>
<button type=”button” class=”btn btn-outline-light text-dark”>Light</button>

Active/Disabled Buttons

A button can be set to an active (appear pressed) or a disabled (unclickable) state:

Example

<button type=”button” class=”btn btn-primary active”>Active Primary</button>
<button type=”button” class=”btn btn-primary” disabled>Disabled Primary</button>
<a href=”#” class=”btn btn-primary disabled”>Disabled Link</a>

Spinner Buttons

You can also add “spinners” to a button,

<button class=”btn btn-primary”>
  <span class=”spinner-border spinner-border-sm”></span>
</button>

<button class=”btn btn-primary”>
  <span class=”spinner-border spinner-border-sm”></span>
  Loading..
</button>

<button class=”btn btn-primary” disabled>
  <span class=”spinner-border spinner-border-sm”></span>
  Loading..
</button>

<button class=”btn btn-primary” disabled>
  <span class=”spinner-grow spinner-grow-sm”></span>
  Loading..
</button>

Button Groups

Bootstrap 4 allows you to group a series of buttons together (on a single line) in a button group:

Use a <div> element with class .btn-group to create a button group:

<div class=”btn-group”>
  <button type=”button” class=”btn btn-primary”>Apple</button>
  <button type=”button” class=”btn btn-primary”>Samsung</button>
  <button type=”button” class=”btn btn-primary”>Sony</button>
</div>

Use the class .btn-group-vertical to create a vertical button group:

<div class=”btn-group-vertical”>
  <button type=”button” class=”btn btn-primary”>Apple</button>
  <button type=”button” class=”btn btn-primary”>Samsung</button>
  <button type=”button” class=”btn btn-primary”>Sony</button>
</div>

Bootstrap 4 Badges

Badges are used to add additional information to any content. Use the .badge class together with a contextual class (like .badge-secondary) within <span> elements to create rectangular badges. Note that badges scale to match the size of the parent element (if any):

Example

<h1>Example heading <span class=”badge badge-secondary”>New</span></h1>
<h2>Example heading <span class=”badge badge-secondary”>New</span></h2>
<h3>Example heading <span class=”badge badge-secondary”>New</span></h3>
<h4>Example heading <span class=”badge badge-secondary”>New</span></h4>
<h5>Example heading <span class=”badge badge-secondary”>New</span></h5>
<h6>Example heading <span class=”badge badge-secondary”>New</span></h6>

Contextual Badges

Use any of the contextual classes (.badge-*) to change the color of a badge:

Example

<span class=”badge badge-primary”>Primary</span>
<span class=”badge badge-secondary”>Secondary</span>
<span class=”badge badge-success”>Success</span>
<span class=”badge badge-danger”>Danger</span>
<span class=”badge badge-warning”>Warning</span>
<span class=”badge badge-info”>Info</span>
<span class=”badge badge-light”>Light</span>
<span class=”badge badge-dark”>Dark</span>

Basic Progress Bar

A progress bar can be used to show a user how far along he/she is in a process.

To create a default progress bar, add a .progress class to a container element and add the .progress-bar class to its child element. Use the CSS width property to set the width of the progress bar:

Example

<div class=”progress”>
  <div class=”progress-bar” style=”width:70%”></div>
</div>

Use the .progress-bar-striped class to add stripes to the progress bars:

<div class=”progress”>
  <div class=”progress-bar progress-bar-striped” style=”width:40%”></div>
</div>

Growing Spinners

Use the .spinner-grow class if you want the spinner/loader to grow instead of “spin”:

Example

<div class=”spinner-grow text-muted”></div>
<div class=”spinner-grow text-primary”></div>
<div class=”spinner-grow text-success”></div>
<div class=”spinner-grow text-info”></div>
<div class=”spinner-grow text-warning”></div>
<div class=”spinner-grow text-danger”></div>
<div class=”spinner-grow text-secondary”></div>
<div class=”spinner-grow text-dark”></div>
<div class=”spinner-grow text-light”></div>

Basic Pagination

If you have a web site with lots of pages, you may wish to add some sort of pagination to each page.

To create a basic pagination, add the .pagination class to an <ul> element. Then add the .page-item to each <li> element and a .page-link class to each link inside <li>:

Example

<ul class=”pagination”>
  <li class=”page-item”><a class=”page-link” href=”#”>Previous</a></li>
  <li class=”page-item”><a class=”page-link” href=”#”>1</a></li>
  <li class=”page-item”><a class=”page-link” href=”#”>2</a></li>
  <li class=”page-item”><a class=”page-link” href=”#”>3</a></li>
  <li class=”page-item”><a class=”page-link” href=”#”>Next</a></li>
</ul>

Active State

The .active class is used to “highlight” the current page:

Example

<ul class=”pagination”>
  <li class=”page-item”><a class=”page-link” href=”#”>Previous</a></li>
  <li class=”page-item”><a class=”page-link” href=”#”>1</a></li>
  <li class=”page-item active”><a class=”page-link” href=”#”>2</a></li>
  <li class=”page-item”><a class=”page-link” href=”#”>3</a></li>
  <li class=”page-item”><a class=”page-link” href=”#”>Next</a></li>
</ul>

Bootstrap 4 Cards

Cards

A card in Bootstrap 4 is a bordered box with some padding around its content. It includes options for headers, footers, content, colors, etc.

Basic Card

A basic card is created with the .card class, and content inside the card has a .card-body class:

Basic card

Example

<div class=”card”>
  <div class=”card-body”>Basic card</div>
</div>

The .card-header class adds a heading to the card and the .card-footer class adds a footer to the card:

Example

<div class=”card”>
  <div class=”card-header”>Header</div>
  <div class=”card-body”>Content</div>
  <div class=”card-footer”>Footer</div>
</div>

Contextual Cards

To add a background color the card, use contextual classes (.bg-primary, .bg-success, .bg-info, .bg-warning, .bg-danger, .bg-secondary, .bg-dark and .bg-light.

Titles, text, and links

Card title

Some example text. Some example text.

Card link Another link

Use .card-title to add card titles to any heading element. The .card-text class is used to remove bottom margins for a <p> element if it is the last child (or the only one) inside .card-body. The .card-link class adds a blue color to any link, and a hover effect.

Example

<div class=”card”>
  <div class=”card-body”>
    <h4 class=”card-title”>Card title</h4>
    <p class=”card-text”>Some example text. Some example text.</p>
    <a href=”#” class=”card-link”>Card link</a>
    <a href=”#” class=”card-link”>Another link</a>
  </div>
</div>

Add .card-img-top or .card-img-bottom to an <img> to place the image at the top or at the bottom inside the card. Note that we have added the image outside of the .card-body to span the entire width:

Example

<div class=”card” style=”width:400px”>
  <img class=”card-img-top” src=”img_avatar1.png” alt=”Card image”>
  <div class=”card-body”>
    <h4 class=”card-title”>John Doe</h4>
    <p class=”card-text”>Some example text.</p>
    <a href=”#” class=”btn btn-primary”>See Profile</a>
  </div>
</div>

The .card-columns class creates a masonry-like grid of cards (like pinterest). The layout will automatically adjust as you insert more cards.

Note: The cards are displayed vertically on small screens (less than 576px):

Example

<div class=”card-columns”>
  <div class=”card bg-primary”>
    <div class=”card-body text-center”>
      <p class=”card-text”>Some text inside the first card</p>
    </div>
  </div>
  <div class=”card bg-warning”>
    <div class=”card-body text-center”>
      <p class=”card-text”>Some text inside the second card</p>
    </div>
  </div>
  <div class=”card bg-success”>
    <div class=”card-body text-center”>
      <p class=”card-text”>Some text inside the third card</p>
    </div>
  </div>
  <div class=”card bg-danger”>
    <div class=”card-body text-center”>
      <p class=”card-text”>Some text inside the fourth card</p>
    </div>
  </div>
  <div class=”card bg-light”>
    <div class=”card-body text-center”>
      <p class=”card-text”>Some text inside the fifth card</p>
    </div>
  </div>
  <div class=”card bg-info”>
    <div class=”card-body text-center”>
      <p class=”card-text”>Some text inside the sixth card</p>
    </div>
  </div>
</div>

Basic Collapsible

Collapsibles are useful when you want to hide and show large amount of content:

<button data-toggle=”collapse” data-target=”#demo”>Collapsible</button>

<div id=”demo” class=”collapse”>
Lorem ipsum dolor text….
</div>

Example Explained

The .collapse class indicates a collapsible element (a <div> in our example); this is the content that will be shown or hidden with a click of a button.

To control (show/hide) the collapsible content, add the data-toggle="collapse" attribute to an <a> or a <button> element. Then add the data-target="#id" attribute to connect the button with the collapsible content (<div id=”demo”>).

Note: For <a> elements, you can use the href attribute instead of the data-target attribute:

Accordion

Example

<div id=”accordion”>

  <div class=”card”>
    <div class=”card-header”>
      <a class=”card-link” data-toggle=”collapse” href=”#collapseOne”>
        Collapsible Group Item #1
      </a>
    </div>
    <div id=”collapseOne” class=”collapse show” data-parent=”#accordion”>
      <div class=”card-body”>
        Lorem ipsum..
      </div>
    </div>
  </div>

  <div class=”card”>
    <div class=”card-header”>
      <a class=”collapsed card-link” data-toggle=”collapse” href=”#collapseTwo”>
        Collapsible Group Item #2
      </a>
    </div>
    <div id=”collapseTwo” class=”collapse” data-parent=”#accordion”>
      <div class=”card-body”>
        Lorem ipsum..
      </div>
    </div>
  </div>

  <div class=”card”>
    <div class=”card-header”>
      <a class=”collapsed card-link” data-toggle=”collapse” href=”#collapseThree”>
        Collapsible Group Item #3
      </a>
    </div>
    <div id=”collapseThree” class=”collapse” data-parent=”#accordion”>
      <div class=”card-body”>
        Lorem ipsum..
      </div>
    </div>
  </div>

</div>

Navbar

Very often, especially on small screens, you want to hide the navigation links and replace them with a button that should reveal them when clicked on.

To create a collapsible navigation bar, use a button with class="navbar-toggler", data-toggle="collapse" and data-target="#thetarget". Then wrap the navbar content (links, etc) inside a div element with class="collapse navbar-collapse", followed by an id that matches the data-target of the button: “thetarget“.

Example

<nav class=”navbar navbar-expand-md bg-dark navbar-dark”>
  <!– Brand –>
  <a class=”navbar-brand” href=”#”>Navbar</a>

  <!– Toggler/collapsibe Button –>
  <button class=”navbar-toggler” type=”button” data-toggle=”collapse” data-target=”#collapsibleNavbar”>
    <span class=”navbar-toggler-icon”></span>
  </button>

  <!– Navbar links –>
  <div class=”collapse navbar-collapse” id=”collapsibleNavbar”>
    <ul class=”navbar-nav”>
      <li class=”nav-item”>
        <a class=”nav-link” href=”#”>Link</a>
      </li>
      <li class=”nav-item”>
        <a class=”nav-link” href=”#”>Link</a>
      </li>
      <li class=”nav-item”>
        <a class=”nav-link” href=”#”>Link</a>
      </li>
    </ul>
  </div>
</nav>

Form Validation

You can use different validation classes to provide valuable feedback to users. Add either .was-validated or .needs-validation to the <form> element, depending on whether you want to provide validation feedback before or after submitting the form. The input fields will have a green (valid) or red (invalid) border to indicate what’s missing in the form. You can also add a .valid-feedback or .invalid-feedback message to tell the user explicitly what’s missing, or needs to be done before submitting the form.

Example

In this example, we use .was-validated to indicate what’s missing before submitting the form:

<form action=”/action_page.php” class=”was-validated”>
  <div class=”form-group”>
    <label for=”uname”>Username:</label>
    <input type=”text” class=”form-control” id=”uname” placeholder=”Enter username” name=”uname” required>
    <div class=”valid-feedback”>Valid.</div>
    <div class=”invalid-feedback”>Please fill out this field.</div>
  </div>
  <div class=”form-group”>
    <label for=”pwd”>Password:</label>
    <input type=”password” class=”form-control” id=”pwd” placeholder=”Enter password” name=”pswd” required>
    <div class=”valid-feedback”>Valid.</div>
    <div class=”invalid-feedback”>Please fill out this field.</div>
  </div>
  <div class=”form-group form-check”>
    <label class=”form-check-label”>
      <input class=”form-check-input” type=”checkbox” name=”remember” required> I agree on blabla.
      <div class=”valid-feedback”>Valid.</div>
      <div class=”invalid-feedback”>Check this checkbox to continue.</div>
    </label>
  </div>
  <button type=”submit” class=”btn btn-primary”>Submit</button>
</form>

Bootstrap supports the following form controls:

  • input
  • textarea
  • checkbox
  • radio
  • select

Bootstrap 4 Input Groups

The .input-group class is a container to enhance an input by adding an icon, text or a button in front or behind the input field as a “help text”.

Use .input-group-prepend to add the help text in front of the input, and .input-group-append to add it behind the input.

At last, add the .input-group-text class to style the specified help text.

<form>
  <div class=”input-group mb-3″>
    <div class=”input-group-prepend”>
      <span class=”input-group-text”>@</span>
    </div>
    <input type=”text” class=”form-control” placeholder=”Username”>
  </div>

  <div class=”input-group mb-3″>
    <input type=”text” class=”form-control” placeholder=”Your Email”>
    <div class=”input-group-append”>
      <span class=”input-group-text”>@example.com</span>
    </div>
  </div>
</form>

How To Create a Carousel

The following example shows how to create a basic carousel with indicators and controls:

Example

<div id=”demo” class=”carousel slide” data-ride=”carousel”>

  <!– Indicators –>
  <ul class=”carousel-indicators”>
    <li data-target=”#demo” data-slide-to=”0″ class=”active”></li>
    <li data-target=”#demo” data-slide-to=”1″></li>
    <li data-target=”#demo” data-slide-to=”2″></li>
  </ul>

  <!– The slideshow –>
  <div class=”carousel-inner”>
    <div class=”carousel-item active”>
      <img src=”la.jpg” alt=”Los Angeles”>
    </div>
    <div class=”carousel-item”>
      <img src=”chicago.jpg” alt=”Chicago”>
    </div>
    <div class=”carousel-item”>
      <img src=”ny.jpg” alt=”New York”>
    </div>
  </div>

  <!– Left and right controls –>
  <a class=”carousel-control-prev” href=”#demo” data-slide=”prev”>
    <span class=”carousel-control-prev-icon”></span>
  </a>
  <a class=”carousel-control-next” href=”#demo” data-slide=”next”>
    <span class=”carousel-control-next-icon”></span>
  </a>

</div>

Example explained

A description of what each class from the example above do:

ClassDescription
.carouselCreates a carousel
.carousel-indicatorsAdds indicators for the carousel. These are the little dots at the bottom of each slide (which indicates how many slides there are in the carousel, and which slide the user are currently viewing)
.carousel-innerAdds slides to the carousel
.carousel-itemSpecifies the content of each slide
.carousel-control-prevAdds a left (previous) button to the carousel, which allows the user to go back between the slides
.carousel-control-nextAdds a right (next) button to the carousel, which allows the user to go forward between the slides
.carousel-control-prev-iconUsed together with .carousel-control-prev to create a “previous” button
.carousel-control-next-iconUsed together with .carousel-control-next to create a “next” button
.slideAdds a CSS transition and animation effect when sliding from one item to the next. Remove this class if you do not want this effect

How To Create a Modal

The following example shows how to create a basic modal:

Example

<!– Button to Open the Modal –>
<button type=”button” class=”btn btn-primary” data-toggle=”modal” data-target=”#myModal”>
  Open modal
</button>

<!– The Modal –>
<div class=”modal” id=”myModal”>
  <div class=”modal-dialog”>
    <div class=”modal-content”>

      <!– Modal Header –>
      <div class=”modal-header”>
        <h4 class=”modal-title”>Modal Heading</h4>
        <button type=”button” class=”close” data-dismiss=”modal”>&times;</button>
      </div>

      <!– Modal body –>
      <div class=”modal-body”>
        Modal body..
      </div>

      <!– Modal footer –>
      <div class=”modal-footer”>
        <button type=”button” class=”btn btn-danger” data-dismiss=”modal”>Close</button>
      </div>

    </div>
  </div>
</div>

How To Create a Tooltip

To create a tooltip, add the data-toggle="tooltip" attribute to an element.

Use the title attribute to specify the text that should be displayed inside the tooltip:

<a href=”#” data-toggle=”tooltip” title=”Hooray!”>Hover over me</a>

Note: Tooltips must be initialized with jQuery: select the specified element and call the tooltip() method.

The following code will enable all tooltips in the document:

Example

<script>
$(document).ready(function(){
  $(‘[data-toggle=”tooltip”]’).tooltip();
});
</script>

How To Create a Popover

To create a popover, add the data-toggle="popover" attribute to an element.

Use the title attribute to specify the header text of the popover, and use the data-content attribute to specify the text that should be displayed inside the popover’s body:

<a href=”#” data-toggle=”popover” title=”Popover Header” data-content=”Some content inside the popover”>Toggle popover</a>

Note: Popovers must be initialized with jQuery: select the specified element and call the popover() method.

The following code will enable all popovers in the document:

Example

<script>
$(document).ready(function(){
  $(‘[data-toggle=”popover”]’).popover();
});
</script>

How To Create a Scrollspy

The following example shows how to create a scrollspy:

Example

<!– The scrollable area –>
<body data-spy=”scroll” data-target=”.navbar” data-offset=”50″>

<!– The navbar – The <a> elements are used to jump to a section in the scrollable area –>
<nav class=”navbar navbar-expand-sm bg-dark navbar-dark fixed-top”>

  <ul class=”navbar-nav”>
    <li><a href=”#section1″>Section 1</a></li>
    …
</nav>

<!– Section 1 –>
<div id=”section1″>
  <h1>Section 1</h1>
  <p>Try to scroll this page and look at the navigation bar while scrolling!</p>
</div>


</body>

Example Explained

Add data-spy="scroll" to the element that should be used as the scrollable area (often this is the <body> element).

Then add the data-target attribute with a value of the id or the class name of the navigation bar (.navbar). This is to make sure that the navbar is connected with the scrollable area.

Note that scrollable elements must match the ID of the links inside the navbar’s list items (<div id="section1"> matches <a href="#section1">).

The optional data-offset attribute specifies the number of pixels to offset from top when calculating the position of scroll. This is useful when you feel that the links inside the navbar changes the active state too soon or too early when jumping to the scrollable elements. Default is 10 pixels.

Requires relative positioning: The element with data-spy=”scroll” requires the CSS position property, with a value of “relative” to work properly.

Responsive Flex Classes

All flex classes comes with additional responsive classes, which makes it easy to set a specific flex class on a specific screen size.

The * symbol can be replaced with sm, md, lg or xl, which represents small, medium, large or xlarge screens.

ClassDescriptionExample
Flex Container  
.d-*-flexCreates a flexbox container for different screens
.d-*-inline-flexCreates an inline flexbox container for different screens
Direction  
.flex-*-rowDisplay flex items horizontally on different screens
.flex-*-row-reverseDisplay flex items horizontally, and right-aligned, on different screens
.flex-*-columnDisplay flex items vertically on different screens
.flex-*-column-reverseDisplay flex items vertically, with reversed order, on different screens screens
Justified Content  
.justify-content-*-startDisplay flex items from the start (left-aligned) on different screens
.justify-content-*-endDisplay flex items at the end (right-aligned) on different screens
.justify-content-*-centerDisplay flex items in the center of a flex container on different screens
.justify-content-*-betweenDisplay flex items in “between” on different screens
.justify-content-*-aroundDisplay flex items “around” on different screens
Fill / Equal Width  
.flex-*-fillForce flex items into equal widths on different screens
Grow  
.flex-*-grow-0Don’t make the items grow on different screens 
.flex-*-grow-1Make items grow on different screens 
Shrink  
.flex-*-shrink-0Don’t make the items shrink on diferent screens 
.flex-*-shrink-1Make items shrink on different screens 
Order  
.order-*-0-12Change the order from 0 to 12 on small screens
Wrap  
.flex-*-nowrapDon’t wrap items on different screens
.flex-*-wrapWrap items on different screens
.flex-*-wrap-reverseReverse the wrapping of items on different screens
Align Content  
.align-content-*-startAlign gathered items from the start on different screens
.align-content-*-endAlign gathered items at the end on different screens
.align-content-*-centerAlign gathered items in the center on different screens
.align-content-*-aroundAlign gathered items “around” on different screens
.align-content-*-stretchStretch gathered items on different screens
Align Items  
.align-items-*-startAlign single rows of items from the start on different screens
.align-items-*-endAlign single rows of items at the end on different screens
.align-items-*-centerAlign single rows of items in the center on different screens
.align-items-*-baselineAlign single rows of items on the baseline on different screens
.align-items-*-stretchStretch single rows of items on different screens
Align Self  
.align-self-*-startAlign a flex item from the start on different screens
.align-self-*-endAlign a flex item at the end on different screens
.align-self-*-centerAlign a flex item in the center on different screens
.align-self-*-baselineAlign a flex item on the baseline on different screens
.align-self-*-stretchStretch a flex item on different screens

Filter Tables

Perform a case-insensitive search for items in a table:

jQuery

<script>
$(document).ready(function(){
  $(“#myInput”).on(“keyup”, function() {
    var value = $(this).val().toLowerCase();
    $(“#myTable tr”).filter(function() {
      $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
    });
  });
});
</script>

Example explained: We use jQuery to loop through each table rows to check if there are any text values that matches the value of the input field. The toggle method hides the row (display:none) that does not match the search. We use the toLowerCase() method to convert the text to lower case, which makes the search case insensitive (allows “john”, “John”, and even “JOHN” on search).

Bootstrap 4 Grid System

Bootstrap’s grid system is responsive, and the columns will re-arrange depending on the screen size: On a big screen it might look better with the content organized in three columns, but on a small screen it would be better if the content items were stacked on top of each other.


Grid Classes

The Bootstrap 4 grid system has five classes:

  • .col- (extra small devices – screen width less than 576px)
  • .col-sm- (small devices – screen width equal to or greater than 576px)
  • .col-md- (medium devices – screen width equal to or greater than 768px)
  • .col-lg- (large devices – screen width equal to or greater than 992px)
  • .col-xl- (xlarge devices – screen width equal to or greater than 1200px)

The classes above can be combined to create more dynamic and flexible layouts.

Tip: Each class scales up, so if you wish to set the same widths for sm and md, you only need to specify sm.


Grid System Rules

Some Bootstrap 4 grid system rules:

  • Rows must be placed within a .container (fixed-width) or .container-fluid (full-width) for proper alignment and padding
  • Use rows to create horizontal groups of columns
  • Content should be placed within columns, and only columns may be immediate children of rows
  • Predefined classes like .row and .col-sm-4 are available for quickly making grid layouts
  • Columns create gutters (gaps between column content) via padding. That padding is offset in rows for the first and last column via negative margin on .rows
  • Grid columns are created by specifying the number of 12 available columns you wish to span. For example, three equal columns would use three .col-sm-4
  • Column widths are in percentage, so they are always fluid and sized relative to their parent element
  • The biggest difference between Bootstrap 3 and Bootstrap 4 is that Bootstrap 4 now uses flexbox, instead of floats. One big advantage with flexbox is that grid columns without a specified width will automatically layout as “equal width columns” (and equal height). Example: Three elements with .col-sm will each automatically be 33.33% wide from the small breakpoint and up. Tip: If you want to learn more about Flexbox, you can read our CSS Flexbox Tutorial.

Note that Flexbox is not supported in IE9 and earlier versions.

Basic Structure of a Bootstrap 4 Grid

The following is a basic structure of a Bootstrap 4 grid:

<!– Control the column width, and how they should appear on different devices –>
<div class=”row”>
  <div class=”col-*-*”></div>
  <div class=”col-*-*”></div>
  <div class=”col-*-*”></div>
</div>

<!– Or let Bootstrap automatically handle the layout –>
<div class=”row”>
  <div class=”col”></div>
  <div class=”col”></div>
  <div class=”col”></div>
  <div class=”col”></div>
</div>

First example: create a row (<div class="row">). Then, add the desired number of columns (tags with appropriate .col-*-* classes). The first star (*) represents the responsiveness: sm, md, lg or xl, while the second star represents a number, which should always add up to 12 for each row.

Second example: instead of adding a number to each col, let bootstrap handle the layout, to create equal width columns: two "col" elements = 50% width to each col. three cols = 33.33% width to each col. four cols = 25% width, etc. You can also use .col-sm|md|lg|xl to make the columns responsive.

Grid Options

The following table summarizes how the Bootstrap 4 grid system works across different screen sizes:

 Extra small (<576px)Small (>=576px)Medium (>=768px)Large (>=992px)Extra Large (>=1200px)
Class prefix.col-.col-sm-.col-md-.col-lg-.col-xl-
Grid behaviourHorizontal at all timesCollapsed to start, horizontal above breakpointsCollapsed to start, horizontal above breakpointsCollapsed to start, horizontal above breakpointsCollapsed to start, horizontal above breakpoints
Container widthNone (auto)540px720px960px1140px
Suitable forPortrait phonesLandscape phonesTabletsLaptopsLaptops and Desktops
# of columns1212121212
Gutter width30px (15px on each side of a column)30px (15px on each side of a column)30px (15px on each side of a column)30px (15px on each side of a column)30px (15px on each side of a column)
NestableYesYesYesYesYes
OffsetsYesYesYesYesYes
Column orderingYesYesYesYesYes

Complete List of All Bootstrap 4 Classes

.activeAdds a white text color to the active link in a navbar.
Navbar
.activeAdds a blue background color to the active list item in a list group
List Groups
.activeAdds a dark-blue background color to simulate a “pressed” button
Buttons
.activeAdds a blue background color to the active dropdown item in a dropdown
Dropdowns
.activeAdds a blue background color to the active pagination link (to highlight the current page)
Pagination
.activeDisplays/shows the current carousel item
Carousel
.alertCreates an alert message box
Alerts
.alert-dangerRed alert. Indicates a dangerous or potentially negative action
Alerts
.alert-darkDark alert. Dark grey alert box
Alerts
.alert-dismissibleIndicates a closable alert box. Together with the .close class, this class is used to close the alert (adds extra padding)
Alerts
.alert-headingAdds color:inherit to the specified element
Alerts
.alert-infoTeal alert. Indicates a neutral informative change or action
Alerts
.alert-lightLight alert. Light grey alert box
Alerts
.alert-linkUsed on links inside alerts to provide matching colored links
Alerts
.alert-primaryBlue alert. Indicates an important action
Alerts
.alert-secondaryGrey alert. Indicates a “less” important action
Alerts
.alert-successGreen alert. Indicates a successful or positive action
Alerts
.alert-warningYellow alert. Indicates caution should be taken with this action
Alerts
.align-baselineThe element is aligned with the baseline of the parent. This is default
Utilities
.align-bottomThe element is aligned with the lowest element on the line
Utilities
.align-middleThe element is placed in the middle of the parent element
Utilities
.align-topThe element is aligned with the top of the tallest element on the line
Utilities
.align-text-topThe element is aligned with the top of the parent element’s font
Utilities
.align-text-bottomThe element is aligned with the bottom of the parent element’s font
Utilities
.align-content-aroundAlign gathered items “around”
Flex
.align-content-*-aroundAlign gathered items “around” on different screens
Flex
.align-content-centerAlign gathered items in the center
Flex
.align-content-*-centerAlign gathered items in the center on different screens
Flex
.align-content-endAlign gathered items at the end
Flex
.align-content-*-endAlign gathered items at the end on different screens
Flex
.align-content-startAlign gathered items from the start
Flex
.align-content-*-startAlign gathered items from the start on different screens
Flex
.align-content-stretchStretch gathered items
Flex
.align-content-*-stretchStretch gathered items on different screens
Flex
.align-items-startAlign single rows of items from the start
Flex
.align-items-*-startAlign single rows of items from the start on different screens
Flex
.align-items-endAlign single rows of items at the end
Flex
.align-items-*-endAlign single rows of items at the end on different screens
Flex
.align-items-centerAlign single rows of items in the center
Flex
.align-items-*-centerAlign single rows of items in the center on different screens
Flex
.align-items-baselineAlign single rows of items at the baseline
Flex
.align-items-*-baselineAlign single rows of items at the baseline on different screens
Flex
.align-items-stretchStretch single rows of items
Flex
.align-items-*-stretchStretch single rows of items on different screens
Flex
.align-self-startAlign a flex item from the start
Flex
.align-self-*-startAlign a flex item from the start on different screens
Flex
.align-self-endAlign a flex item at the end
Flex
.align-self-*-endAlign a flex item at the end on different screens
Flex
.align-self-centerAlign a flex item in the center
Flex
.align-self-*-centerAlign a flex item in the center on different screens
Flex
.align-self-baselineAlign a flex item at the baseline
Flex
.align-self-*-baselineAlign a flex item at the baseline on different screens
Flex
.align-self-stretchStretch a flex item
Flex
.align-self-*-stretchStretch a flex item on different screens
Flex
.badgeCreates a circular badge (grey circle – often used as a numerical indicator)
Badges
.badge-dangerRed badge. Indicates a dangerous or potentially negative action
Badges
.badge-darkDark badge. Dark grey alert box
Badges
.badge-infoTeal badge. Indicates a neutral informative change or action
Badges
.badge-lightLight badge. Light grey alert box
Badges
.badge-pillMakes a badge more round
Badges
.badge-primaryBlue badge. Indicates an important action
Badges
.badge-secondaryGrey badge. Indicates a “less” important action
Badges
.badge-successGreen badge. Indicates a successful or positive action
Badges
.badge-warningYellow badge. Indicates caution should be taken with this action
Badges
.bg-dangerAdds a red background color to an element. Represents danger or a negative action
Colors
.bg-darkAdds a dark grey background color to an element
Colors
.bg-infoAdds a teal background color to an element. Represents some information
Colors
.bg-lightAdds a light grey background color to an element
Colors
.bg-primaryAdds a blue background color to an element. Represents something important
Colors
.bg-secondaryAdds a grey background color to an element. Indicates a “less” important action
Colors
.bg-successAdds a green background color to an element. Indicates success or a positive action
Colors
.bg-warningAdds a yellow/orange background color to an element. Represents a warning or a negative action
Colors
.blockquoteStyles quoted blocks of content from another source (adds a larger font-size (1.25rem))
Typography
.blockquote-footerStyles the source title inside the blockquote (light grey text with indentation)
Typography
.borderAdds a border to an element
Utilities
.border-bottom-0Removes the bottom border from an element
Utilities
.border-dangerAdds a red border to an element (indicates danger)
Utilities
.border-darkAdds a dark border to an element
Utilities
.border-infoAdds a teal border to an element (indicates information)
Utilities
.border-left-0Removes the left border from an element
Utilities
.border-lgAdds a large border to an element
Utilities
.border-lightAdds a light grey border to an element
Utilities
.border-primaryAdds a blue border to an element
Utilities
.border-right-0Removes the right border from an element
Utilities
.border-top-0Removes the top border from an element
Utilities
.border-secondaryAdds a grey border to an element
Utilities
.border-smAdds a small border to an element
Utilities
.border-successAdds a green border to an element (indicates success)
Utilities
.border-warningAdds a orange border to an element (indicates warning)
Utilities
.border-whiteAdds a white border to an element
Utilities
.border-0Removes all borders from an element
Utilities
.breadcrumbA pagination. Indicates the current page’s location within a navigational hierarchy
Pagination
.breadcrumb-itemStyles list items or links inside the breadcrumb
Pagination
.btnCreates a basic button (gray background and rounded corners)
Buttons
.btn-blockCreates a block level button that spans the entire width of the parent element
Buttons
.btn-darkDark grey button
Buttons
.btn-dangerRed button. Indicates danger or a negative action
Buttons
.btn-groupGroups buttons together on a single line
Button Groups
.btn-group-lgLarge button group (makes all buttons in a button group larger – increased font-size and padding)
Button Groups
.btn-group-smSmall button group (makes all buttons in a button group smaller)
Button Groups
.btn-group-verticalMakes a button group appear vertically stacked
Button Groups
.btn-infoTeal button. Represents a neutral informative change or action
Buttons
.btn-lightLight grey button
Buttons
.btn-linkMakes a button look like a link (get button behavior)
Buttons
.btn-lgLarge button
Buttons
.btn-outline-darkDark grey bordered/outlined button
Buttons
.btn-outline-dangerRed bordered/outlined button. Indicates danger or a negative action
Buttons
.btn-outline-infoTeal bordered/outlined button. Represents a neutral informative change or action
Buttons
.btn-outline-lightLight grey bordered/outlined button
Buttons
.btn-outline-primaryBlue bordered/outlined button.
Buttons
.btn-outline-secondaryGrey bordered/outlined button. Indicates a “less” important action
Buttons
.btn-outline-successGreen bordered/outlined button. Indicates success or a positive action
Buttons
.btn-outline-warningOrange bordered/outlined button. Represents warning or a negative action
Buttons
.btn-primaryBlue button. Indicates a something important
Buttons
.btn-smSmall button
Buttons
.btn-secondaryGrey button. Indicates a “less” important action
Buttons
.btn-successGreen button. Indicates success or a positive action
Buttons
.btn-toolbarCombine sets of button groups into button toolbars for more complex components
Button Groups
.btn-warningOrange button. Represents warning or a negative action
Buttons
.cardCreates a card
Cards
.card-bodyContainer for card content
Cards
.card-columnsContainer to create a masonry-like grid of cards
Cards
.card-dangerAdds a red background color to the card. Represents danger or a negative action
Cards
.card-darkAdds a grey background color to the card
Cards
.card-deckContainer to create a grid of cards that are of equal height and width
Cards
.card-footerCard footer
Cards
.card-groupContainer to create a grid of cards that are of equal height and width, without side margins
Cards
.card-headerCard header
Cards
.card-header-tabsStyles navigation tabs inside the card header
Cards
.card-header-pillsStyles navigation pills inside the card header
Cards
.card-img-bottomPlace the image at the bottom inside a card
Cards
.card-img-overlayTurns an image into a card background. Often used to add text on top of the image
Cards
.card-img-topPlace the image at the top inside a card
Cards
.card-infoAdds a teal background color to the card. Represents some information
Cards
.card-lightAdds a light grey background color to the card
Cards
.card-linkAdds a blue color to any link and a hover effect inside the card
Cards
.card-primaryAdds a blue background color to the card. Represents something important
Cards
.card-secondaryAdds a grey background color to the card. Represents something “less” important
Cards
.card-subtitleThe .card-subtitle is used after a .card-title, and adds the following to an element: margin-top: -.375rem; margin-bottom: 0;
Cards
.card-successAdds a green background color to the card. Indicates success or a positive action
Cards
.card-textUsed to remove bottom margins for a p element if it is the last child (or the only one), inside .card-body
Cards
.card-titleAdds a title to any heading element inside the card
Cards
.card-warningAdds a yellow/orange background color to the card. Represents a warning or a negative action
Cards
.carouselCreates a carousel (slideshow)
Carousel
.carousel-captionCreates a caption text for each slide in the carousel
Carousel
.carousel-control-nextContainer for “next” carousel/item link
Carousel
.carousel-control-next-iconUsed together with .carousel-control-next to create a “next” icon/button (right-pointed arrow)
Carousel
.carousel-control-prevContainer for “previous” carousel/item link
Carousel
.carousel-control-prev-iconUsed together with .carousel-control-prev to create a “previous” icon/button (left-pointed arrow)
Carousel
.carousel-indicatorsAdds little dots/indicators at the bottom of each slide (which indicates how many slides there is in the carousel, and which slide the user are currently viewing)
Carousel
.carousel-innerContainer for slide items
Carousel
.carousel-itemSpecifies the content of each slide
Carousel
.clearfixClears floats
Utilities
.closeStyles a close icon. This is often used for alerts and modals. Often used together with the &times; symbol to create the actual icon (a better looking “x”). It floats right by default
Utilities
.col-autoMake form columns automatically size themselves based on their content
Forms
.col-*Creates a column layout for extra small devices (and up/all devices, if not combined with other column classes). The * can be a number between 1 and 12
Grid System
.col-sm-*Creates a column layout for small devices (and up, if not combined with other column classes). The * can be a number between 1 and 12
Grid System
.col-md-*Creates a column layout for medium devices (and up, if not combined with other column classes). The * can be a number between 1 and 12
Grid System
.col-lg-*Creates a column layout for large devices (and up, if not combined with other column classes). The * can be a number between 1 and 12
Grid System
.col-xl-*Creates a column layout for extra large devices. The * can be a number between 1 and 12
Grid System
.collapseIndicates collapsible content – which can be hidden or shown on demand
Collapse
.collapse showShow the collapsible content by default
Collapse
.containerFixed width container with widths determined by screen sites. Equal margin on the left and right.
Containers
.container-fluidA container that spans the full width of the screen
Containers
.container-*Responsive containers
Containers
.custom-checkboxA wrapper/container for custom checkboxes
Custom Forms
.custom-controlA wrapper/container for custom forms
Custom Forms
.custom-control-inputCustomized form control
Custom Forms
.custom-control-inlineInline (horizontally – side by side) customized form controls
Custom Forms
.custom-control-labelCustomized label, when used together with a custom form control
Custom Forms
.custom-fileCustomized file upload
Custom Forms
.custom-file-inputCustomized file upload
Custom Forms
.custom-file-labelCustomized file label
Custom Forms
.custom-radioA wrapper/container for custom radio buttons
Custom Forms
.custom-rangeCustomized range control
Custom Forms
.custom-selectCustomized select menu
Custom Forms
.custom-select-lgLarge customized select menu
Custom Forms
.custom-select-smSmall customized select menu
Custom Forms
.custom-switchCustomized toggle switch
Custom Forms
.disabledDisables a button (adds opacity and a “no-parking-sign” icon on hover)
Buttons
.disabledDisables a dropdown item (adds a grey text color and a “no-parking-sign” icon on hover)
Dropdowns
.disabledDisables a pagination link (cannot be clicked – adds a grey text color and a “no-parking-sign” icon on hover)
Pagination
.disabledDisables a list item in a list group (cannot be clicked – adds a light grey color and removes the hover effect on list item links)
List Groups
.dropdownCreates a toggleable menu that allows the user to choose one value from a predefined list
Dropdowns
.dropdown-dividerUsed to separate links in the dropdown menu with a thin horizontal border
Dropdowns
.dropdown-headerUsed to add headers inside the dropdown menu
Dropdowns
.dropdown-itemCreates a dropdown item (added to links or buttons inside .dropdown-menu)
Dropdowns
.dropdown-item-textUsed to add plain text to a dropdown item, or used on links for default link styling
Dropdowns
.dropdown-menuAdds the default styles for the dropdown menu container
Dropdowns
.dropdown-menu-rightRight-aligns a dropdown menu
Dropdowns
.dropdown-toggleUsed on the button that should hide and show (toggle) the dropdown menu
Dropdowns
.dropleftLeft-aligns the dropdown
Dropdowns
.droprightRight-aligns the dropdown
Dropdowns
.dropupIndicates a dropup menu (upwards instead of downwards)
Dropdowns
.d-blockCreates a block element (adds display:block)
Utilities
.d-*-blockCreates a block element on a specific screen width
Utilities
.d-inlineMakes an element inline
Utilities
.d-*-inlineMakes an element inline on a specific screen size
Utilities
.d-inline-blockMakes an element inline block
Utilities
.d-*-inline-blockMakes an element inline block on a specific screen size
Utilities
.d-flexCreates a flexbox container and transforms direct children into flex items
Flex
.d-*-flexCreates a flexbox container on a specific screen size
Flex
.d-inline-flexCreates an inline flexbox container
Flex
.d-*-inline-flexCreates an inline flexbox container on a specific screen size
Flex
.d-noneHides an element
Utilities
.d-*-noneHides an element on a specific screen size
Utilities
.d-tableMakes an element display as a table
Utilities
.d-*-tableMakes an element display as a table on a specific screen size
Utilities
.d-table-cellMakes an element display as a table cell
Utilities
.d-*-table-cellMakes an element display as a table cell on a specific screen size
Utilities
.d-table-rowMakes an element display as a table row
Utilities
.d-*-table-rowMakes an element display as a table row on a specific screen size
Utilities
.embed-responsiveContainer for embedded content. Makes videos or slideshows scale properly on any device
Images
.embed-responsive-16by9Container for embedded content. Creates an 16:9 aspect ratio embedded content
Images
.embed-responsive-3by4Container for embedded content. Creates an 3:4 aspect ratio embedded content
Images
.embed-responsive-itemUsed inside .embed-responsive. Scales the video nicely to the parent element
Images
.fadeAdds a fading effect when closing an alert box
Alerts
.fadeAdds a fading effect when showing tab/pill content
Navs
.fadeAdds a fading effect when opening a modal
Modal
.fixed-bottomMakes an element stay at the bottom of the screen (sticky/fixed)
Utilities
.fixed-topMakes an element stay at the top of the screen (sticky/fixed)
Utilities
.flex-columnDisplay flex items vertically
Flex
.flex-*-columnDisplay flex items vertically on different screen sizes:
Flex
.flex-column-reverseDisplay flex items vertically, reversed
Flex
.flex-*-column-reverseDisplay flex items vertically, reversed, on different screen sizes
Flex
.flex-fillUsed on flex items to force it/them into equal width columns
Flex
.flex-*-fillForce flex items into equal widths on different screens
Flex
.flex-grow-0|1Used on a single flex item to take up the rest of the available space
Flex
.flex-nowrapDon’t wrap flex items
Flex
.flex-*-nowrapDon’t wrap items on different screens
Flex
.flex-shrink-0|1Used on a single flex item to shrink it if necessary Flex
.flex-rowDisplay flex items horizontally (side by side)
Flex
.flex-*-rowDisplay flex items horizontally on a specific screen size
Flex
.flex-row-reverseDisplay flex items right-aligned and horizontally
Flex
.flex-*-row-reverseDisplay flex items right-aligned and horizontally on a specific screen size
Flex
.flex-wrapWrap flex items
Flex
.flex-*-wrapWrap items on different screens
Flex
.flex-wrap-reverseWrap flex items, in reversed order
Flex
.flex-*-wrap-reverseWrap flex items, in reversed order on different screens
Flex
.float-leftFloats an element to the left
Utilities
.float-*-leftFloats an element to the left on different screens
Utilities
.float-noneRemove floats from an element
Utilities
.float-rightFloats an element to the right
Utilities
.float-*-rightFloats an element to the left on different screens
Utilities
.font-italicItalic text
Typography
.font-weight-boldBold text
Typography
.font-weight-bolderBolder text (font-weight:bolder)
Typography
.font-weight-lightLight weight text (font-weight:300)
Typography
.font-weight-lighterLighter weight text (font-weight:lighter)
Typography
.font-weight-normalNormal text (font-weight:400)
Typography
.form-checkContainer for checkboxes. Adds proper padding
Forms
.form-check-inlineMakes checkboxes appear on the same line (horizontally)
Forms
.form-check-inputStyles checkboxes with proper margins
Forms
.form-check-labelEnsures proper margins for labels used together with checkboxes
Forms
.form-controlUsed on input, textarea, and select elements to span the entire width of the page and make them responsive
Forms
.form-control-fileAdds display:block and width:100% to input filed with type=”file”
Forms
.form-control-lgLarge form control
Forms
.form-control-plaintextStyles a form control as plain text
Forms
.form-control-rangeAdds display:block and width:100% to input filed with type=”range”
Forms
.form-control-smSmall form control
Forms
.form-groupContainer for form input and label
Forms
.form-inlineMakes a <form> left-aligned with inline-block controls (This only applies to forms within viewports that are at least 768px wide)
Forms
.form-rowContainer for responsive columns (less left and right margins than .row/overrides default column gutters)
Forms
.h1 - .h6Makes an element look like a heading of the chosen class (h1-h6)
Typography
.h-25Sets the height of an element to 25%
Utilities
.h-50Sets the height of an element to 50%
Utilities
.h-75Sets the height of an element to 75%
Utilities
.h-100Sets the height of an element to 100%
Utilities
.img-fluidResponsive image (adds max-width:100% and height:auto)
Images
.img-thumbnailShapes an image to a thumbnail (thin light grey borders)
Images
.initialismDisplays the text inside an <abbr> element in a slightly smaller font size
Typography
.input-groupContainer to enhance an input by adding an icon, text or a button in front or behind the input field as a “help text”
Input Group
.input-group-appendInput group container for adding help text behind an input field
Input Group
.input-group-lgLarge input group
Input Group
.input-group-prependInput group container for adding help text in front of an input field
Input Group
.input-group-smSmall input group
Input Group
.input-group-textStyles the specified help text in an input group
Input Group
.input-lgLarge input field
Input Sizing
.input-smSmall input field
Input Sizing
.invalid-feedbackCreates a custom validation message used in validated forms (red text color)
Forms
.invalid-tooltipCreates a custom validation message used in validated forms (red tooltip)
Forms
.invisibleMake an element invisible
Utilities
.is-invalidValidates a form element (adds a red border to input fields). Note: for server side
Forms
.is-validValidates a form element (adds a green border to input fields). Note: for server side
Forms
.jumbotronCreates a padded grey heading/box with rounded corners that enlarges the font sizes of the text inside it. Used for calling extra attention to some special content or information
Jumbotron
.jumbotron-fluidCreates a full-width jumbotron (grey padded heading) without rounded borders
Jumbotron
.justify-content-*Aligns flex items from the start, at the end, centered, in between and “around
Flex
.justify-content-*-aroundAligns flex items “around” on different screen sizes
Flex
.justify-content-*-betweenAligns flex items in “between” on different screen sizes
Flex
.justify-content-*-centerAligns flex items in the center on different screen sizes
Flex
.justify-content-*-endAligns flex items at the end on different screen sizes
Flex
.justify-content-*-startAligns flex items from the start on different screen sizes
Flex
.leadIncrease the font size and line height of a paragraph
Typography
.list-groupCreates a bordered list group for <li> elements
List Group
.list-group-flushRemoves some borders and rounded corners from list items in a list group
List Group
.list-group-horizontalDisplay list items horizontally instead of vertically (side-by-side instead of on top of each other)
List Group
.list-group-horizontal-*Display list items horizontally instead of vertically on different screen sizes
List Group
.list-group-itemAdded to each <li> element in the list group
List Group
.list-group-item-actionAdded to links inside the list group to make them stand out on hover (darker background)
List Group
.list-group-item-dangerRed background color for a list item in a list group
List Group
.list-group-item-darkDark grey background color for a list item in a list group
List Group
.list-group-item-infoLight-blue background color for a list item in a list group
List Group
.list-group-item-lightLight grey background color for a list item in a list group
List Group
.list-group-item-primaryBlue background color for a list item in a list group
List Group
.list-group-item-successGreen background color for a list item in a list group
List Group
.list-group-item-warningYellow background color for a list item in a list group
List Group
.list-inlinePlaces all list items on a single line (used together with .list-inline-item on each <li> elements)
Typography
.list-inline-itemPlaces all list items on a single line (used together with .list-inline on the parent <ul> element)
Typography
.list-unstyledRemoves all default list-style (bullets, left margin, etc.) styling from a <ul> or <ol> list
Typography
.markHighlights text: Highlighted text
Typography
.mediaAligns media objects together with content (like images or videos – often used for comments in a blog post etc)
Media Objects
.media-bodyContainer for media content
Media Objects
.modalIdentifies the content as a modal and brings focus to it
Modals
.modal-bodyDefines the style for the body of the modal. Add any HTML markup here (p, img, etc)
Modals
.modal-contentStyles the modal (border, background-color, etc). Inside this, add the modal’s header, body and footer, if needed
Modals
.modal-dialog-centeredCenters the modal vertically and horizontally within the page
Modals
.modal-dialog-scrollableAdds a scrollbar inside the modal
Modals
.modal-footerThe footer of the modal (often contains an action button and a close button)
Modals
.modal-headerThe header of the modal (often contains a title and a close button)
Modals
.modal-lgLarge modal (wider than default)
Modals
.modal-smSmall modal (less width)
Modals
.modal-xlExtra large modal
Modals
.m-# / m-*-#Responsive margin classes. * can be sm, md, lg or xl. # can be a number between 0 and 5
Utilities
.mt-# / mt-*-#Responsive top margin classes. * can be sm, md, lg or xl. # can be a number between 0 and 5
Utilities
.mb-# / mb-*-#Responsive bottom margin classes. * can be sm, md, lg or xl. # can be a number between 0 and 5
Utilities
.ml-# / ml-*-#Responsive left margin classes. * can be sm, md, lg or xl. # can be a number between 0 and 5
Utilities
.mr-# / mr-*-#Responsive right margin classes. * can be sm, md, lg or xl. # can be a number between 0 and 5
Utilities
.mx-# / mx-*-#Responsive left and right margin auto (horizontal) classes. * can be sm, md, lg or xl. # can be a number between 0 and 5
Utilities
.my-# / my-*-#Responsive top and bottom margin auto (vertical) classes. * can be sm, md, lg or xl. # can be a number between 0 and 5
Utilities
.mx-autoCenters an element horizontally
Utilities
.nav nav-tabsCreates a tabbed menu
Tabs
.nav nav-pillsCreates a pill menu
Tabs
.nav-justifiedJustifies tab/pill links with an equal width
Tabs
.navbarCreates a navigation bar
Navbar
.navbar-navContainer for navigation links inside the .navbar container
Navbar
.navbar-brandAdded to a link or a header element inside the navbar to represent a logo or a header
Navbar
.navbar-collapseCollapses the navbar (hidden and replaced with a menu/hamburger icon on mobile phones and small tablets)
Navbar
.navbar-expand-*Responsive collapsible class – stacks the navbar vertically on small (sm), medium (md), large (lg) or extra large (xl) screens
Navbar
.navbar-darkAdds a white text color to all links in the navbar
Navbar
.navbar-lightAdds a black text color to all links in the navbar
Navbar
.navbar-textVertically align any elements inside the navbar that are not links (ensures proper padding)
Navbar
.navbar-togglerStyles the button that should open the navbar on small screens. Automatically styled as a hamburger/three bars
Navbar
.nav-linkUsed to style links/anchors inside the navbar
Navbar
.nav-itemUsed to style list items inside the navbar
Navbar
.needs-validationAdds validation styles to a submitted form
Forms
.no-guttersRemove gutters/extra space from columns
Grid System
.page-itemStyles list items inside a pagination
Pagination
.page-linkStyles links inside a pagination
Pagination
.paginationCreates a pagination (Useful when you have a web site with lots of pages
Pagination
.pagination-lgLarge pagination (each pagination link gets a bigger font-size and more padding)
Pagination
.pagination-smSmall pagination (each pagination link gets a smaller font size and less padding)
Pagination
.pre-scrollableMakes a <pre> element scrollable (max-height of 350px and provide a y-axis scrollbar)
Helpers
.progressContainer for progress bars
Progress Bars
.progress-barCreates a progress bar
Progress Bars
.progress-bar-animatedAnimates the progress bar (used together with stripes)
Progress Bars
.progress-bar-stripedAdds stripes to the progress bar
Progress Bars
.p-# / p-*-#Responsive padding classes. * can be sm, md, lg or xl. # can be a number between 0 and 5
Utilities
.pt-# / pt-*-#Responsive top padding classes. * can be sm, md, lg or xl. # can be a number between 0 and 5
Utilities
.pb-# / pb-*-#Responsive bottom padding classes. * can be sm, md, lg or xl. # can be a number between 0 and 5
Utilities
.pl-# / pl-*-#Responsive left padding classes. * can be sm, md, lg or xl. # can be a number between 0 and 5
Utilities
.pr-# / pr-*-#Responsive right padding classes. * can be sm, md, lg or xl. # can be a number between 0 and 5
Utilities
.py-# / py-*-#Responsive top and bottom padding classes. * can be sm, md, lg or xl. # can be a number between 0 and 5
Utilities
.px-# / px-*-#Responsive left and right padding classes. * can be sm, md, lg or xl. # can be a number between 0 and 5
Utilities
.roundedAdds rounded corners to an element
Utilities
.rounded-bottomAdds bottom rounded corners to an element
Utilities
.rounded-circleShapes an element to a circle (not supported in IE8 and earlier)
Utilities
.rounded-leftAdds left rounded corners of an element
Utilities
.rounded-rightAdds right rounded corners to an element
Utilities
.rounded-topAdds top rounded corners to an element
Utilities
.rounded-0Removes rounded corners from an element
Utilities
.rowContainer for responsive columns
Grid System
.row-cols-*Set the number of columns that should appear next to each other
Grid System
.shadowAdds a shadow to an element
Utilities
.shadow-lgAdds a large shadow to an element
Utilities
.shadow-noneRemoves shadows from an element
Utilities
.shadow-smAdds a small shadow to an element
Utilities
.smallCreates a lighter, secondary text in any heading
Typography
.spinner-borderCreates a spinner/loader
Spinners
.spinner-border-smCreates a smaller spinner/loader
Spinners
.spinner-growCreates a spinner/loader that “grows”
Spinners
.spinner-grow-smCreates a smaller spinner/loader that “grows”
Spinners
.sr-onlyHides an element on all devices except for screen readers
Utilities
.sr-only-focusableHides an element on all devices except for screen readers
Utilities
.sticky-topMakes an element stay sticky/fixed at the top of the page when you scroll past it
Utilities
.stretched-linkAdded to a link to make its containing block (parent) clickable (works only for parent elements with position:relative)
Utilities
.tab-contentUsed together with .tab-pane to creates toggleable/dynamic tabs/pills
Tabs
.tab-paneUsed together with .tab-content to creates toggleable/dynamic tabs/pills
Tabs
.tableAdds basic styling to a table (padding, bottom borders, etc)
Tables
.table-activeAdds a grey background color to the table row (<tr> or table cell (<td>) (same color used on hover)
Tables
.table-borderedAdds borders on all sides of the table and cells
Tables
.table-borderlessRemove borders from a table
Tables
.table-condensedMakes a table more compact by cutting cell padding in half
Tables
.table-darkAdds a black background with white text to the table
Tables
.table-hoverCreates a hoverable table (adds a grey background color on table rows on hover)
Tables
.table-responsive-*Makes a table responsive (adds a horizontal scrollbar when needed). By default, the scrollbar is added to the table on screens that are less than 992px wide (if needed). There’s no difference when viewing anything lager than 992px wide. However, you can use sm|md|lg|xl to decide WHEN the table should get a scrollbar, depending on the screen width
Tables
.table-stripedAdds zebra-stripes to a table
Tables
.text-breakPrevents long text from breaking layout
Typography
.text-capitalizeIndicates capitalized text
Typography
.text-centerCenter-aligns text
Typography
.text-*-centerCenter-aligns text on different screens
Typography
.text-dangerRed text color. Indicates danger
Colors
.text-darkDark grey text color
Typography
.text-decoration-noneRemoves the underline from a link
Typography
.text-hideHides text (helps replace an element’s text content with a background image)
Typography
.text-infoLight-blue text color. Indicates information
Colors
.text-lightLight grey text color
Colors
.text-justifyIndicates justified text
Typography
.text-leftAligns the text to the left
Typography
.text-*-leftLeft-aligns text on different screens
Typography
.text-lowercaseChanges text to lowercase
Typography
.text-mutedGrey text color
Colors
.text-nowrapPrevents the text from wrapping
Typography
.text-primaryBlue text color. Indicates something important
Colors
.text-secondaryGrey text color. Indicates something “less” important
Colors
.text-resetResets the color of a text or a link (inherits the color from its parent)
Typography
.text-rightAligns text to the right
Typography
.text-*-rightRight-aligns text on different screens
Typography
.text-successGreen text color. Indicates success
Colors
.text-uppercaseMakes text uppercase
Typography
.text-warningYellow/orange text color. Indicates warning
Colors
.text-whiteWhite text color
Colors
.thead-darkAdds a black background color to table headers
Tables
.thead-lightAdds a grey background color to table headers
Tables
.toastCreates a toast (alert box that disappears after a few seconds)
Toast
.toast-bodyToast body
Toast
.toast-headerToast header
Toast
.valid-feedbackCreates a custom validation message used in validated forms (green text color)
Forms
.valid-tooltipCreates a custom validation message used in validated forms (green tooltip)
Forms
.visibleMake an element visible
Utilities
.was-validatedAdds validation styles to a form element
Forms
.w-25Sets the width of an element to 25%
Utilities
.w-50Sets the width of an element to 50%
Utilities
.w-75Sets the width of an element to 75%
Utilities
.w-100Sets the width of an element to 100%

Utilities

Leave a comment