Responsive Grid System

A lightweight, Bootstrap-inspired grid system with Container, Row, and Column components for React applications

v1.0.0

Overview

The Responsive Grid System is a lightweight, Bootstrap-inspired toolkit designed for React applications. It provides an essential responsive 12-column grid system without the overhead of a full CSS framework.

.col
.col-6
.col-6
.col-md-4
.col-md-4
.col-md-4

Key Features

12-Column Grid

Flexible layout system with 12 columns and 7 configurable breakpoints

React Components

Easy-to-use Container, Row and Column components with TypeScript support

Mobile-First

Responsive design that works on all devices from mobile to desktop

Lightweight

Only 5KB minified - no unnecessary bloat or dependencies

Customizable

Easily configure breakpoints, container widths and spacing

Developer Friendly

Clean API with intuitive props and comprehensive documentation

Breakpoints

The grid system leverages 7 distinct breakpoints to control layout across various screen sizes. Styles defined at a specific breakpoint apply to that size and all larger screen sizes.

xxs XX-Small
0px +
Base for all devices
No container constraint
xs X-Small
≥576px
540px max-width
sm Small
≥768px
720px max-width
md Medium
≥992px
960px max-width
lg Large
≥1200px
1140px max-width
xl X-Large
≥1400px
1320px max-width
xxl XX-Large
≥1600px
1500px max-width

Breakpoint Usage

Breakpoint prefixes are used with grid columns to apply styles conditionally:

// Applies to medium screens (≥992px) and larger
<Col md={6} /> // Renders as .col-md-6

// Multiple breakpoints
<Col xs={12} sm={6} md={4} lg={3} />

// Auto-sizing at large breakpoints
<Col lg="auto" /> // Renders as .col-lg-auto

Container Max-Widths

The grid system applies max-width constraints at different breakpoints to prevent content from becoming too wide:

// Container max-width configuration in SCSS:
$container-max-widths: (
  xs: 540px,
  sm: 720px,
  md: 960px,
  lg: 1140px,
  xl: 1320px,
  xxl: 1500px
);

Mobile-First Principle

This grid system follows a mobile-first approach:

  • Base styles apply to all screen sizes (xxs breakpoint)
  • Larger breakpoint styles override smaller screen styles
  • No media query is needed for the xxs (0px) breakpoint
  • Design for mobile first, then enhance for larger screens

Grid Components

The grid system provides three core React components for building responsive layouts. These components work together to create a flexible grid system.

Container

The Container component provides the foundational wrapper for the grid system. It centers content horizontally and applies responsive max-widths at different breakpoints.

Props

fluid
boolean Default: false

When true, creates a full-width container that spans the entire viewport

children
ReactNode

Content to be wrapped inside the container

className
string

Additional CSS classes to apply to the container

Usage

// Fixed-width container
<Container>
  <Row>
    <Col>Content</Col>
  </Row>
</Container>

// Full-width container
<Container fluid>
  <Row>
    <Col>Full-width content</Col>
  </Row>
</Container>

Row

The Row component creates a horizontal group of columns. It handles negative margins to offset column padding for proper alignment.

Props

noGutters
boolean Default: false

When true, removes spacing between columns

children
ReactNode

Columns or other content inside the row

className
string

Additional CSS classes to apply to the row

Usage

// Basic row with columns
<Row>
  <Col>Column 1</Col>
  <Col>Column 2</Col>
</Row>

// Row without gutters
<Row noGutters>
  <Col>Column without spacing</Col>
</Row>

Column (Col)

The Col component defines a column within a row. It supports responsive width and offset settings across 7 breakpoints.

Props

xxs, xs, sm, md, lg, xl, xxl
number | 'auto'

Column width for each breakpoint (1-12 or 'auto')

offsetXxs, offsetXs, etc.
number

Left offset for column (0-11)

children
ReactNode

Content inside the column

className
string

Additional CSS classes to apply to the column

Usage

// Responsive column sizing
<Col xs={12} md={6}>
  Full width on mobile, half width on medium screens
</Col>

// Column with offset
<Col md={4} offsetMd={4}>
  Column pushed by 4 columns on medium screens
</Col>

// Auto-sizing column
<Col lg="auto">
  Column that sizes to its content on large screens
</Col>

Utility Classes

Utility classes provide single-purpose, immutable styles to quickly build and modify components.

Aspect Ratio Properties

Control the aspect ratio of elements, ensuring that they maintain a consistent width-to-height proportion regardless of their content or container width. This is particularly useful for embedding responsive videos, iframes, or images where a specific aspect ratio must be preserved.

How it Works

These utilities leverage a common CSS technique that uses a `padding-top` percentage, which is relative to the element's width, to create a fixed aspect ratio container. The base class, `.ratio`, sets up the necessary positioning context (`position: relative; width: 100%;`) and applies the `padding-top` via a CSS variable (`--bs-aspect-ratio`).

Child elements within the `.ratio` container are then absolutely positioned to `top: 0; left: 0; width: 100%; height: 100%;`, allowing them to fill the space created by the padding hack while maintaining the desired aspect ratio of the parent. This method ensures responsiveness by scaling the height proportionally with the width.

Aspect Ratio Class Selector Reference

The following patterns outline all available aspect ratio utility classes. These classes are applied to the *parent* container of the content you want to maintain an aspect ratio for.

Aspect Ratio Classes:

.ratio Base Class

Applies the base styles for the aspect ratio container: position: relative; width: 100%; and a `::before` pseudo-element with `padding-top: var(--bs-aspect-ratio);` to define the ratio. All direct children will be absolutely positioned to fill this ratio.

.ratio-1x1 Utility Class

Sets the aspect ratio to 1:1 (square). Internally, sets --bs-aspect-ratio: 100%;.

.ratio-4x3 Utility Class

Sets the aspect ratio to 4:3. Internally, sets --bs-aspect-ratio: 75%;.

.ratio-16x9 Utility Class

Sets the aspect ratio to 16:9 (common widescreen video). Internally, sets --bs-aspect-ratio: 56.25%;.

.ratio-21x9 Utility Class

Sets the aspect ratio to 21:9 (ultrawide video). Internally, sets --bs-aspect-ratio: 42.857143%;.

Example: Usage Example

<div class="ratio ratio-16x9"><iframe src="..."></iframe></div>

<div class="ratio ratio-1x1"><img src="..." alt="..."></div>

Borders Properties

Control borders with these utility classes. You can add or remove borders from all sides or individual sides, adjust border width, and apply various border radius styles.

Additive Borders

Add borders to an element or just to specific sides.

.border
.border-top
.border-end
.border-bottom
.border-start
<div class="border">...</div>
<div class="border-top">...</div>
<div class="border-end">...</div>
<div class="border-bottom">...</div>
<div class="border-start">...</div>

Subtractive Borders

Remove borders from an element or specific sides.

.border-0
.border-top-0
.border-end-0
.border-bottom-0
.border-start-0
<div class="border border-0">...</div>
<div class="border border-top-0">...</div>
<div class="border border-end-0">...</div>
<div class="border border-bottom-0">...</div>
<div class="border border-start-0">...</div>

Border Width

Change the width of an element's border.

.border-1
.border-2
.border-3
.border-4
.border-5
<div class="border border-1">...</div>
<div class="border border-2">...</div>
<div class="border border-3">...</div>
<div class="border border-4">...</div>
<div class="border border-5">...</div>

Border Radius

Apply different levels of border-radius to elements.

.rounded-0
.rounded-1
.rounded-2
.rounded-3
.rounded-4
.rounded-5
.rounded-circle
.rounded-pill
<div class="rounded-0">...</div>
<div class="rounded-1">...</div>
<div class="rounded-2">...</div>
<div class="rounded-3">...</div>
<div class="rounded-4">...</div>
<div class="rounded-5">...</div>
<div class="rounded-circle">...</div>
<div class="rounded-pill">...</div>

Border Radius by Side

Apply border-radius to specific corners or sides.

.rounded-top
.rounded-end
.rounded-bottom
.rounded-start
<div class="rounded-top">...</div>
<div class="rounded-end">...</div>
<div class="rounded-bottom">...</div>
<div class="rounded-start">...</div>

Border Class Selector Reference

The following patterns outline all available border utility classes.

Additive Borders:

.border Utility Class

Adds a default border to all sides (1px solid var(--border-color)).

.border-top Utility Class

Adds a border to the top side.

.border-end Utility Class

Adds a border to the right side (end in LTR).

.border-bottom Utility Class

Adds a border to the bottom side.

.border-start Utility Class

Adds a border to the left side (start in LTR).

Example: Usage Example

.border, .border-top

Subtractive Borders:

.border-0 Utility Class

Removes all borders from an element.

.border-top-0 Utility Class

Removes the border from the top side.

.border-end-0 Utility Class

Removes the border from the right side (end in LTR).

.border-bottom-0 Utility Class

Removes the border from the bottom side.

.border-start-0 Utility Class

Removes the border from the left side (start in LTR).

Example: Usage Example

.border-0, .border-bottom-0

Border Width:

.border-{width} Utility Class

Sets the border width (e.g., .border-1 for 1px). Available widths: 1-5.

Example: Usage Example

.border-1, .border-5

Border Radius:

.rounded Utility Class

Applies a default border-radius (0.375rem).

.rounded-0 Utility Class

Removes border-radius (0).

.rounded-{size} Utility Class

Applies specific border-radius sizes (e.g., .rounded-1 for 0.25rem). Sizes: 1-5.

.rounded-circle Utility Class

Applies a circular border-radius (50%).

.rounded-pill Utility Class

Applies a pill-shaped border-radius (50rem).

Example: Usage Example

.rounded-3, .rounded-circle

Border Radius by Side:

.rounded-top Utility Class

Applies border-radius to the top-left and top-right corners.

.rounded-end Utility Class

Applies border-radius to the top-right and bottom-right corners (end in LTR).

.rounded-bottom Utility Class

Applies border-radius to the bottom-left and bottom-right corners.

.rounded-start Utility Class

Applies border-radius to the top-left and bottom-left corners (start in LTR).

Example: Usage Example

.rounded-top, .rounded-end

Colors

Control the appearance of your content with a rich set of color utilities for text, backgrounds, and borders. These classes are designed to be fully customizable via SCSS variables, ensuring your application's styling remains consistent and easy to manage across all components.

Beyond basic solid colors, this system also provides utilities for background gradients and background colors with adjustable opacity, giving you precise control over visual depth and layering.

Customizable Theme Colors

The grid system's color palette is defined through SCSS variables, allowing for easy customization. Below is the default list of colors and their corresponding variable names and hex values:

$primary #007bff

Represents the main brand color (default: blue).

$secondary #6c757d

A neutral, supporting color (default: gray).

$success #28a745

Indicates a successful or positive action (default: green).

$info #17a2b8

Provides informational context (default: cyan).

$warning #ffc107

Highlights a warning or caution (default: yellow).

$danger #dc3545

Denotes a critical or negative action (default: red).

$light #f8f9fa

A very light, near-white color (default: off white).

$dark #343a40

A very dark, near-black color (default: off black).

$white #fff

Pure white color.

$black #000

Pure black color.

$body #212529

The default text color for body content (default: off gray).

$muted #6c757d

A subdued text color, often used for secondary information (default: gray).

Examples

See how different color utilities can be applied:

Text Colors

Apply distinct colors to your text content using .text-{color-name}.

.text-primary - This is primary text.

.text-success - This is success text.

.text-danger - This is danger text.

.text-info - This is info text.

.text-warning - This is warning text.

.text-dark - This is dark text.

.text-muted - This is muted text.

.text-white - White text on dark background.

Background Colors

Apply solid background colors to elements using .bg-{color-name}.

.bg-primary
.bg-success
.bg-danger
.bg-info
.bg-warning
.bg-dark
.bg-light
Border Colors

Apply borders with specific theme colors using .border-{color-name}. (Requires a base border utility like .border to be present).

.border-primary
.border-success
.border-danger
.border-dark
.border-warning
Background Gradients

Add subtle linear gradients using .bg-gradient-{color-name}. These ascend from a lighter tint of the color to the full color.

.bg-gradient-primary
.bg-gradient-success
.bg-gradient-danger
Background with Opacity

Apply background colors with predefined opacity levels (10%, 25%, 50%, 75%, 90%) using .bg-{color}-opacity-{level}.

.bg-primary-opacity-25
.bg-success-opacity-50
.bg-danger-opacity-75
.bg-dark-opacity-90

Code Examples

<!-- Text Colors -->
<p class="text-primary">Primary colored text.</p>
<p class="text-success">Success colored text.</p>
<p class="text-white bg-dark">White text on dark background.</p>

<!-- Background Colors -->
<div class="bg-primary p-3">Primary background.</div>
<div class="bg-success p-3">Success background.</div>

<!-- Border Colors -->
<div class="border border-primary p-3">Primary border.</div>
<div class="border border-danger p-3">Danger border.</div>

<!-- Background Gradients -->
<div class="bg-gradient-primary p-3 text-white">Primary gradient background.</div>
<div class="bg-gradient-success p-3 text-white">Success gradient background.</div>

<!-- Background with Opacity -->
<div class="bg-primary-opacity-25 p-3 text-primary">Primary background with 25% opacity.</div>
<div class="bg-success-opacity-50 p-3 text-success">Success background with 50% opacity.</div>

Color Class Selector Reference

The following patterns outline all available color utility classes. These classes apply !important to ensure they override other styles.

Text Color Classes:

.text-{color-name} Utility Class

Sets the color property to the specified theme color.

Available color names: primary, secondary, success, info, warning, danger, light, dark, white, black, body, muted.

Example: Usage Example

.text-primary, .text-dark

Background Color Classes:

.bg-{color-name} Utility Class

Sets the background-color property to the specified theme color.

Available color names: primary, secondary, success, info, warning, danger, light, dark, white, black, body, muted.

Example: Usage Example

.bg-success, .bg-light

Border Color Classes:

.border-{color-name} Utility Class

Sets the border-color property to the specified theme color. Typically used in conjunction with border width or side utilities (e.g., .border, .border-2, .border-top).

Available color names: primary, secondary, success, info, warning, danger, light, dark, white, black, body, muted.

Example: Usage Example

.border-primary, .border-dark

Background Gradient Classes:

.bg-gradient-{color-name} Utility Class

Applies a linear-gradient background, transitioning from a lighter tint of the specified color to the full color.

Available color names: primary, secondary, success, info, warning, danger, light, dark, white, black, body, muted.

Example: Usage Example

.bg-gradient-primary, .bg-gradient-info

Background with Opacity Classes:

.bg-{color}-opacity-{level} Utility Class Pattern

Sets the background-color with a specific opacity level (e.g., rgba({color}, {level}/100)).

Available color names: All theme colors (primary, secondary, etc.).

Available opacity levels: 10, 25, 50, 75, 90.

Example: Usage Example

.bg-primary-opacity-25, .bg-dark-opacity-75

Display Properties

Control the display property of elements with these utilities. These classes can also be applied responsively using the .d-{breakpoint}-{value} format, and for print-specific layouts with .d-print-{value}.

Basic Display Classes

Apply fundamental display behaviors to any element.

Individual examples for each display property:

.d-block

Block Element 1
Block Element 2

Block elements take up the full width available and stack vertically.

.d-inline

This is inline item 1 and inline item 2 in the same line.

Inline elements only take up as much width as their content and flow horizontally.

.d-inline-block

Inline-Block 1
Inline-Block 2

Inline-block elements behave like inline elements but can have a defined width and height.

.d-flex

Item A
Item B

.d-flex turns an element into a flex container, enabling powerful layout options for its direct children.

.d-grid

Grid Cell 1
Grid Cell 2

.d-grid transforms an element into a grid container, allowing for two-dimensional layouts.

.d-none

The following text contains a .d-none element. You should not see the word "HIDDEN".

Visible text. HIDDEN TEXT. More visible text.

This entire box is hidden by .d-none.

Use .d-none to completely hide an element, visually and for screen readers.

// .d-block example
<div class="d-block">Block Element 1</div>
<div class="d-block">Block Element 2</div>

// .d-inline example
<span>This is</span> <span class="d-inline">inline item 1</span> and <span class="d-inline">inline item 2</span> in the same line.

// .d-inline-block example
<div class="d-inline-block">Inline-Block 1</div>
<div class="d-inline-block">Inline-Block 2</div>

// .d-flex example
<div class="d-flex">
  <div>Flex Item 1</div>
  <div>Flex Item 2</div>
</div>

// .d-grid example
<div class="d-grid">
  <div>Grid Cell 1</div>
  <div>Grid Cell 2</div>
</div>

// .d-none example
<span class="d-none">HIDDEN TEXT</span>
<div class="d-none">This entire box is hidden.</div>

Responsive Display

Apply display utilities responsively by using breakpoint prefixes. For example, .d-md-block will set the display to block on medium screens and up, while .d-lg-none will hide the element on large screens and up.

Hidden on XXS/XS, Block on SM+
Block on XXS/XS/SM/MD, Hidden on LG+
Flex (XXS-MD), Inline-Flex (MD+)
<div class="d-none d-sm-block">Hidden on XXS/XS, Block on SM+</div>
<div class="d-block d-lg-none">Block on XXS/XS/SM/MD, Hidden on LG+</div>
<div class="d-flex d-md-inline-flex">Flex (XXS-MD), Inline-Flex (MD+)</div>

Print Display

Control the display property specifically for print media. These classes are applied only when the page is printed.

Hidden When Printing
Block When Printing
<div class="d-print-none">This content is hidden when printing</div>
<div class="d-print-block">This content is displayed as block when printing</div>

Display Class Selector Reference

The following patterns outline all available display utility classes.

General Display Classes:

.d-none Utility Class

Sets display: none !important; Hides the element and removes it from the document flow.

.d-inline Utility Class

Sets display: inline !important; Element flows with text, width/height ignored.

.d-inline-block Utility Class

Sets display: inline-block !important; Element flows inline but respects width/height and vertical margins.

.d-block Utility Class

Sets display: block !important; Element takes full width and starts on a new line.

.d-grid Utility Class

Sets display: grid !important; Establishes a block-level grid container.

.d-table Utility Class

Sets display: table !important; Behaves like an HTML <table> element.

.d-table-cell Utility Class

Sets display: table-cell !important; Behaves like an HTML <td> or <th> element.

.d-table-row Utility Class

Sets display: table-row !important; Behaves like an HTML <tr> element.

.d-flex Utility Class

Sets display: flex !important; Establishes a block-level flex container.

.d-inline-flex Utility Class

Sets display: inline-flex !important; Establishes an inline-level flex container.

Example: Usage Example

.d-block, .d-flex

Responsive Display Classes:

Apply display utilities responsively by appending the breakpoint abbreviation to the class name. For example, .d-sm-none to hide on small screens and up, or .d-lg-block to make an element block-level on large screens and up.

.d-{breakpoint}-{value} Utility Class Pattern

Sets display: {value} !important; starting from the specified breakpoint and up. The utility applies to the indicated breakpoint and all larger breakpoints unless overridden by another display utility.

Available Breakpoints: Breakpoints

xxs (Extra Extra Small, default / no min-width)
xs (Extra Small, e.g., @media (min-width: 576px))
sm (Small, e.g., @media (min-width: 768px))
md (Medium, e.g., @media (min-width: 992px))
lg (Large, e.g., @media (min-width: 1200px))
xl (Extra Large, e.g., @media (min-width: 1400px))
xxl (Extra Extra Large, e.g., @media (min-width: 1600px))

Available Values: Display Values

none, inline, inline-block, block, grid, table, table-cell, table-row, flex, inline-flex

Example: Usage Example

.d-none .d-md-block (hidden by default, block on md and up)

.d-lg-flex (flexbox on large and up)

Print Display Classes:

Control the display property of elements specifically for print using the .d-print-{value} classes.

.d-print-{value} Utility Class Pattern

Sets display: {value} !important; only when the page is being printed.

Available Values: Display Values

none, inline, inline-block, block, grid, table, table-cell, table-row, flex, inline-flex

Example: Usage Example

.d-print-none (hide element when printing)

.d-print-block (make inline element block-level when printing)

Flexbox Properties

Utilize these comprehensive flexbox utilities to control the layout, alignment, and responsiveness of content within a flex container. Remember to apply a .d-flex or .d-inline-flex class to the parent element to enable flexbox behavior.

Most flex utilities also support responsive variants (e.g., .flex-md-row, .justify-content-lg-center), allowing you to adapt layouts at different breakpoints.

Flex Direction

Control the direction of flex items along the main axis within a flex container.

.flex-row (default)

Item 1
Item 2
Item 3

Items are laid out in a row (left to right for LTR languages).

.flex-row-reverse

Item 1
Item 2
Item 3

Items are laid out in a row, but in reverse order.

.flex-column

Item 1
Item 2
Item 3

Items are laid out in a column (top to bottom).

.flex-column-reverse

Item 1
Item 2
Item 3

Items are laid out in a column, but in reverse order.

<div class="d-flex flex-row">...</div>
<div class="d-flex flex-row-reverse">...</div>
<div class="d-flex flex-column">...</div>
<div class="d-flex flex-column-reverse">...</div>

Flex Wrap

Control whether flex items wrap onto multiple lines or stay on a single line.

.flex-wrap

Item 1
Item 2
Item 3
Item 4
Item 5

Items wrap onto multiple lines if space is insufficient.

.flex-nowrap (default)

Item 1 (long)
Item 2 (long)
Item 3 (long)

Items stay on a single line, potentially overflowing the container.

.flex-wrap-reverse

Item 1
Item 2
Item 3
Item 4
Item 5

Items wrap onto multiple lines in reverse order.

<div class="d-flex flex-wrap">...</div>
<div class="d-flex flex-nowrap">...</div>
<div class="d-flex flex-wrap-reverse">...</div>

Justify Content

Align flex items along the main axis of the container.

.justify-content-start (default)

Item 1
Item 2

.justify-content-end

Item 1
Item 2

.justify-content-center

Item 1
Item 2

.justify-content-between

Item 1
Item 2

.justify-content-around

Item 1
Item 2

.justify-content-evenly

Item 1
Item 2
Item 3
<div class="d-flex justify-content-start">...</div>
<div class="d-flex justify-content-end">...</div>
<div class="d-flex justify-content-center">...</div>
<div class="d-flex justify-content-between">...</div>
<div class="d-flex justify-content-around">...</div>
<div class="d-flex justify-content-evenly">...</div>

Align Items

Align flex items along the cross axis (perpendicular to the main axis) of the container.

.align-items-start

Item 1
Item 2
Item 3

.align-items-end

Item 1
Item 2
Item 3

.align-items-center

Item 1
Item 2
Item 3

.align-items-baseline

Item 1
Item 2
Item 3

.align-items-stretch (default)

Item 1
Item 2
Item 3
<div class="d-flex align-items-start">...</div>
<div class="d-flex align-items-end">...</div>
<div class="d-flex align-items-center">...</div>
<div class="d-flex align-items-baseline">...</div>
<div class="d-flex align-items-stretch">...</div>

Align Content

Align lines of flex items when there's extra space in the cross axis and items are wrapped.

.align-content-start

Item 1
Item 2
Item 3
Item 4

.align-content-end

Item 1
Item 2
Item 3
Item 4

.align-content-center

Item 1
Item 2
Item 3
Item 4

.align-content-between

Item 1
Item 2
Item 3
Item 4

.align-content-around

Item 1
Item 2
Item 3
Item 4

.align-content-stretch (default)

Item 1
Item 2
Item 3
Item 4
<div class="d-flex flex-wrap align-content-start">...</div>
<div class="d-flex flex-wrap align-content-end">...</div>
<div class="d-flex flex-wrap align-content-center">...</div>
<div class="d-flex flex-wrap align-content-between">...</div>
<div class="d-flex flex-wrap align-content-around">...</div>
<div class="d-flex flex-wrap align-content-stretch">...</div>

Align Self

Align individual flex items along the cross axis, overriding the container's align-items setting.

Start
End
Center
Baseline
Stretch
Auto (default)
<div class="d-flex align-items-center">
  <div class="align-self-start">...</div>
  <div class="align-self-end">...</div>
  <div class="align-self-center">...</div>
  <div class="align-self-baseline">...</div>
  <div class="align-self-stretch">...</div>
  <div class="align-self-auto">...</div>
</div>

Flex Grow & Shrink

Control how flex items grow or shrink to fill available space.

.flex-fill

Flex Fill 1
Flex Fill 2
Item 3

Items with .flex-fill will grow and shrink to fill available space equally.

.flex-grow-1 vs .flex-grow-0

Grow 1
Grow 0
Default

.flex-grow-1 allows an item to grow, .flex-grow-0 prevents it from growing.

.flex-shrink-1 vs .flex-shrink-0

Shrink 1 (will shrink)
Shrink 0 (won't shrink)

.flex-shrink-1 allows an item to shrink, .flex-shrink-0 prevents it from shrinking.

<div class="d-flex">
  <div class="flex-fill">...</div>
  <div class="flex-fill">...</div>
</div>

<div class="d-flex">
  <div class="flex-grow-1">...</div>
  <div class="flex-grow-0">...</div>
</div>

<div class="d-flex">
  <div class="flex-shrink-1">...</div>
  <div class="flex-shrink-0">...</div>
</div>

Flex Class Selector Reference

The following patterns outline all available flexbox utility classes.

Flex Direction:

.flex-row Utility Class

Sets flex-direction: row !important; (horizontal, left-to-right).

.flex-row-reverse Utility Class

Sets flex-direction: row-reverse !important; (horizontal, right-to-left).

.flex-column Utility Class

Sets flex-direction: column !important; (vertical, top-to-bottom).

.flex-column-reverse Utility Class

Sets flex-direction: column-reverse !important; (vertical, bottom-to-top).

.flex-{breakpoint}-{direction} Responsive Pattern

Applies flex direction responsively from the specified breakpoint and up. Directions: row, row-reverse, column, column-reverse.

Available Breakpoints: Breakpoints

xxs, xs, sm, md, lg, xl, xxl

Example: Usage Example

.flex-column .flex-md-row

Flex Wrap:

.flex-wrap Utility Class

Sets flex-wrap: wrap !important; allowing items to wrap to the next line.

.flex-nowrap Utility Class

Sets flex-wrap: nowrap !important; preventing items from wrapping.

.flex-wrap-reverse Utility Class

Sets flex-wrap: wrap-reverse !important; allowing items to wrap to the previous line.

.flex-{breakpoint}-{wrap} Responsive Pattern

Applies flex wrap behavior responsively from the specified breakpoint and up. Wrap values: wrap, nowrap, wrap-reverse.

Available Breakpoints: Breakpoints

xxs, xs, sm, md, lg, xl, xxl

Example: Usage Example

.flex-nowrap .flex-sm-wrap

Justify Content (Main Axis Alignment):

.justify-content-start Utility Class

Sets justify-content: flex-start !important; (items aligned to the start of the main axis).

.justify-content-end Utility Class

Sets justify-content: flex-end !important; (items aligned to the end of the main axis).

.justify-content-center Utility Class

Sets justify-content: center !important; (items centered along the main axis).

.justify-content-between Utility Class

Sets justify-content: space-between !important; (items distributed with space between them, first and last items at edges).

.justify-content-around Utility Class

Sets justify-content: space-around !important; (items distributed with equal space around them).

.justify-content-evenly Utility Class

Sets justify-content: space-evenly !important; (items distributed with equal space between and around them).

.justify-content-{breakpoint}-{value} Responsive Pattern

Applies justify content responsively from the specified breakpoint and up. Values: start, end, center, between, around, evenly.

Available Breakpoints: Breakpoints

xxs, xs, sm, md, lg, xl, xxl

Example: Usage Example

.justify-content-center .justify-content-lg-between

Align Items (Cross Axis Alignment - Single Line):

.align-items-start Utility Class

Sets align-items: flex-start !important; (items aligned to the start of the cross axis).

.align-items-end Utility Class

Sets align-items: flex-end !important; (items aligned to the end of the cross axis).

.align-items-center Utility Class

Sets align-items: center !important; (items centered along the cross axis).

.align-items-baseline Utility Class

Sets align-items: baseline !important; (items aligned based on their baselines).

.align-items-stretch Utility Class

Sets align-items: stretch !important; (items stretch to fill the container along the cross axis, respecting min/max height/width).

.align-items-{breakpoint}-{value} Responsive Pattern

Applies align items responsively from the specified breakpoint and up. Values: start, end, center, baseline, stretch.

Available Breakpoints: Breakpoints

xxs, xs, sm, md, lg, xl, xxl

Example: Usage Example

.align-items-start .align-items-md-center

Align Content (Cross Axis Alignment - Multi-Line):

Note: This only applies when flex items wrap (i.e., when using .flex-wrap).

.align-content-start Utility Class

Sets align-content: flex-start !important; (wrapped lines aligned to the start of the cross axis).

.align-content-end Utility Class

Sets align-content: flex-end !important; (wrapped lines aligned to the end of the cross axis).

.align-content-center Utility Class

Sets align-content: center !important; (wrapped lines centered along the cross axis).

.align-content-between Utility Class

Sets align-content: space-between !important; (wrapped lines distributed with space between them, first and last lines at edges).

.align-content-around Utility Class

Sets align-content: space-around !important; (wrapped lines distributed with equal space around them).

.align-content-stretch Utility Class

Sets align-content: stretch !important; (wrapped lines stretch to fill the remaining space).

.align-content-{breakpoint}-{value} Responsive Pattern

Applies align content responsively from the specified breakpoint and up. Values: start, end, center, between, around, stretch.

Available Breakpoints: Breakpoints

xxs, xs, sm, md, lg, xl, xxl

Example: Usage Example

.flex-wrap .align-content-end

Align Self (Cross Axis Alignment - Individual Item):

.align-self-auto Utility Class

Sets align-self: auto !important; (inherits default alignment or from parent align-items).

.align-self-start Utility Class

Sets align-self: flex-start !important; (item aligned to the start of the cross axis).

.align-self-end Utility Class

Sets align-self: flex-end !important; (item aligned to the end of the cross axis).

.align-self-center Utility Class

Sets align-self: center !important; (item centered along the cross axis).

.align-self-baseline Utility Class

Sets align-self: baseline !important; (item aligned based on its baseline).

.align-self-stretch Utility Class

Sets align-self: stretch !important; (item stretches to fill the available space along the cross axis).

.align-self-{breakpoint}-{value} Responsive Pattern

Applies align self responsively from the specified breakpoint and up. Values: auto, start, end, center, baseline, stretch.

Available Breakpoints: Breakpoints

xxs, xs, sm, md, lg, xl, xxl

Example: Usage Example

.align-self-center .align-self-lg-start

Flex Grow & Shrink:

.flex-fill Utility Class

Sets flex: 1 1 auto !important; (item grows and shrinks as needed to fill available space).

.flex-grow-0 Utility Class

Sets flex-grow: 0 !important; (prevents item from growing).

.flex-grow-1 Utility Class

Sets flex-grow: 1 !important; (allows item to grow to fill available space).

.flex-shrink-0 Utility Class

Sets flex-shrink: 0 !important; (prevents item from shrinking).

.flex-shrink-1 Utility Class

Sets flex-shrink: 1 !important; (allows item to shrink as needed).

.flex-{breakpoint}-fill
.flex-{breakpoint}-grow-0/1
.flex-{breakpoint}-shrink-0/1 Responsive Patterns

Applies flex grow, shrink, or fill behavior responsively from the specified breakpoint and up.

Available Breakpoints: Breakpoints

xxs, xs, sm, md, lg, xl, xxl

Example: Usage Example

.flex-grow-1 .flex-md-grow-0, .flex-xl-fill

Float Properties

Float elements to the left or right of a container, or disable floating, with these utility classes. Floats affect the layout of surrounding content, causing text to wrap around the floated element.

These utilities also include responsive variants (e.g., .float-md-start, .float-lg-none) to control float behavior at specific breakpoints.

.float-start

Floats an element to the left.

Floated Left

This text demonstrates how content will wrap around an element that is floated to the start (left) of its container. The floated item will take up space on the current line, and subsequent inline content will flow alongside it. This is useful for images within text blocks or aligning elements side-by-side without using flexbox or grid for simple layouts.

<div class="float-start">...</div>

.float-end

Floats an element to the right.

Floated Right

Here, the content will wrap around an element that is floated to the end (right) of its container. The principle is the same as .float-start, but the alignment is on the opposite side, allowing for flexible two-column or multi-column layouts primarily driven by content flow.

<div class="float-end">...</div>

.float-none

Disables floating on an element. Useful for resetting float behavior inherited from parent elements or previous responsive breakpoints.

Original (no float)
Initially Floated
.float-none (resets float)

Even though a previous element was floated, this element with .float-none does not float and occupies its own line, demonstrating the reset of float behavior. If this was also floated, it would appear next to the 'Initially Floated' box.

<div class="float-none">...</div>

Clearfix

The .clearfix utility can be applied to a parent element to clear (contain) its floated children. This prevents the parent from collapsing in height and ensures that subsequent content appears below the floated elements, not alongside them.

Before Clearfix (Parent Collapses)

Floated

Parent container with a floated child. Notice how the red dashed border (parent) collapses around the floated element. This text is inside the parent, but the parent's height doesn't encompass the float.

After Clearfix (Parent Contains Floats)

Floated

This parent container uses .clearfix. Notice how the green dashed border (parent) now correctly contains the floated element, preventing collapse. All content (including the floated item) is within the parent's boundaries.

<div class="clearfix">
  <div class="float-start">...</div>
  <!-- Other content -->
</div>

Float Class Selector Reference

The following patterns outline all available float utility classes.

Float Classes:

.float-start Utility Class

Sets float: left !important; to float the element to the left.

.float-end Utility Class

Sets float: right !important; to float the element to the right.

.float-none Utility Class

Sets float: none !important; to reset any float applied to the element.

Example: Usage Example

.float-start, .float-none

Responsive Float Classes:

Apply float utilities responsively by appending the breakpoint abbreviation to the class name. This allows for different float behaviors based on screen size.

.float-{breakpoint}-{value} Utility Class Pattern

Sets the float property from the specified breakpoint and up. Values: start (left), end (right), none.

Available Breakpoints: Breakpoints

xxs, xs, sm, md, lg, xl, xxl

Example: Usage Example

.float-start .float-md-none (floats left by default, but no float on medium screens and up)

.float-lg-end (floats right on large screens and up)

Clearfix Utility:

.clearfix Utility Class

Adds a clear: both; via the ::after pseudo-element, effectively clearing floats within its parent container. Useful for containing floated content without adding extra markup.

CSS applied:


                                            .clearfix::after {
                                            display: block;
                                            clear: both;
                                            content: "";
                                            }
                                        

Example: Usage Example

<div class="clearfix">...floated content...</div>

Gap Properties

The gap utilities allow you to control the spacing between items in flexbox and grid layouts. They provide a shorthand for setting both row-gap and column-gap, or you can specify them individually.

How it Works

The gap CSS property sets the space between rows and columns. It's a shorthand for row-gap and column-gap. These utilities are applied to the *container* of flex items or grid items, not to the items themselves. They are essential for creating clean and consistent spacing within dynamic layouts without resorting to margins on individual items, which can often lead to layout complexities.

These utilities support a range of predefined spacing values, which correspond to a spacing scale (e.g., `0.25rem`, `0.5rem`, `1rem`, `1.5rem`, `3rem`), and include responsive variations for different screen sizes.

Examples

Observe how different gap utilities affect the spacing of items within a flex container.

Default Gap (`.gap-3`)

Applies a 1rem gap between both rows and columns.

Item 1
Item 2
Item 3
Item 4
Item 5
Row Gap Only (`.row-gap-4`)

Applies a 1.5rem gap only between rows (columns will still be next to each other if `column-gap` is not set or is `0`).

Item 1
Item 2
Item 3
Item 4
Item 5
Column Gap Only (`.column-gap-5`)

Applies a 3rem gap only between columns (rows will still be next to each other if `row-gap` is not set or is `0`).

Item 1
Item 2
Item 3
Item 4
Item 5
Responsive Gap (e.g., `.gap-xxs-0 .gap-lg-4`)

No gap on extra-small screens, but 1.5rem gap on large screens and up.

Item 1
Item 2
Item 3
Item 4
Item 5

Code Examples


<!-- General gap (both row and column gap) -->
<div class="d-flex flex-wrap gap-3">
    <div>Item 1</div>
    <div>Item 2</div>
    <div>Item 3</div>
</div>

<!-- Row gap only -->
<div class="d-flex flex-wrap row-gap-4">
    <div>Item 1</div>
    <div>Item 2</div>
    <div>Item 3</div>
</div>

<!-- Column gap only -->
<div class="d-flex flex-wrap column-gap-5">
    <div>Item 1</div>
    <div>Item 2</div>
    <div>Item 3</div>
</div>

<!-- Responsive gap example -->
<div class="d-flex flex-wrap gap-xxs-0 gap-lg-4">
    <div>Item 1</div>
    <div>Item 2</div>
    <div>Item 3</div>
</div>
                            

Gap Class Selector Reference

The following patterns outline all available gap utility classes, including their responsive variations. Values (0-5) correspond to a spacing scale where 0 is 0, 1 is 0.25rem, 2 is 0.5rem, 3 is 1rem, 4 is 1.5rem, and 5 is 3rem.

Base Gap Classes:

.gap-{value} Utility Class

Sets both row-gap and column-gap to the specified spacing {value} (e.g., .gap-3 sets gap: 1rem !important;).

.row-gap-{value} Utility Class

Sets row-gap to the specified spacing {value} (e.g., .row-gap-2 sets row-gap: 0.5rem !important;).

.column-gap-{value} Utility Class

Sets column-gap to the specified spacing {value} (e.g., .column-gap-4 sets column-gap: 1.5rem !important;).

Responsive Gap Classes:

These classes apply the gap only at the specified breakpoint and up. Breakpoints include xxs, xs, sm, md, lg, xl, and xxl.

.gap-{breakpoint}-{value} Utility Class

Sets both row-gap and column-gap to the specified spacing {value} at or above the {breakpoint}.

Example: .gap-md-3 (gap: 1rem !important; from medium screens up).

.row-gap-{breakpoint}-{value} Utility Class

Sets row-gap to the specified spacing {value} at or above the {breakpoint}.

Example: .row-gap-lg-2 (row-gap: 0.5rem !important; from large screens up).

.column-gap-{breakpoint}-{value} Utility Class

Sets column-gap to the specified spacing {value} at or above the {breakpoint}.

Example: .column-gap-sm-5 (column-gap: 3rem !important; from small screens up).

Interactions Properties

Control user interaction with elements, including cursor styles and focus indicators, using these utility classes.

Cursor Utilities

Change the appearance of the mouse cursor when hovering over an element. This is useful for providing visual feedback to the user about interactive elements or non-interactive areas.

auto Default (browser decides)
default Default arrow
pointer Hand (link)
wait Waiting/hourglass
text Text selection
move Move/cross
help Help/question mark
not-allowed Forbidden symbol
<div class="cursor-pointer">...</div>
<div class="cursor-not-allowed">...</div>

Focus Utilities

The .focus-ring utility provides a custom, consistent visual indicator when an interactive element receives keyboard focus (e.g., by tabbing through elements) or is clicked. It overrides the browser's default outline with a styled box-shadow, improving accessibility and visual consistency.

Try tabbing to or clicking the button and input field below to see the focus ring in action.

<button class="focus-ring">...</button>
<input type="text" class="focus-ring">

Interactions Class Selector Reference

The following patterns outline all available interaction utility classes.

Cursor Classes:

.cursor-auto Utility Class

Sets cursor: auto !important;. The browser determines the cursor type based on the context.

.cursor-default Utility Class

Sets cursor: default !important;. The standard arrow cursor.

.cursor-pointer Utility Class

Sets cursor: pointer !important;. A hand icon, typically indicating a clickable element.

.cursor-wait Utility Class

Sets cursor: wait !important;. An hourglass or spinning icon, indicating the program is busy.

.cursor-text Utility Class

Sets cursor: text !important;. A text input I-beam, indicating text can be selected.

.cursor-move Utility Class

Sets cursor: move !important;. A four-pointed arrow, indicating an element can be moved.

.cursor-help Utility Class

Sets cursor: help !important;. An arrow with a question mark, indicating help is available.

.cursor-not-allowed Utility Class

Sets cursor: not-allowed !important;. A circle with a diagonal line, indicating an action is forbidden.

Example: Usage Example

.cursor-pointer

Focus Ring Class:

.focus-ring Utility Class

Applies a consistent box-shadow as a visual focus indicator when the element receives keyboard focus (:focus state). It also removes the default outline.

CSS Applied:


    .focus-ring:focus {
        outline: 0 !important;
        box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25) !important;
        }
                                        

Example: Usage Example

<button class="focus-ring">...</button>

Object Fit Properties

Control how images, videos, and other replaced elements are resized to fit their container. These utilities apply the object-fit CSS property, which is crucial for maintaining aspect ratios and preventing content distortion within responsive layouts.

How it Works

The object-fit property specifies how the content of a replaced element (like <img> or <video>) should be resized to fit its container, while maintaining its aspect ratio if desired. Unlike background images, which use background-size, object-fit applies directly to the element itself.

These utility classes offer five different behaviors: contain, cover, fill, scale-down, and none, providing flexible control over how your media scales and crops within a given dimension.

Examples

See how different object-fit classes affect an image within a fixed-size container. The container for each image is 150px by 150px.

.object-fit-contain

The image is scaled down to fit within the container while maintaining its aspect ratio. Empty space is added if necessary.

Landscape Image
Portrait Image
.object-fit-cover

The image fills the container, maintaining its aspect ratio. Portions of the image may be clipped if its aspect ratio differs from the container.

Landscape Image
Portrait Image
.object-fit-fill

The image fills the container, stretching or squishing to do so. The aspect ratio is **not** maintained.

Landscape Image
Portrait Image
.object-fit-scale (maps to `scale-down`)

The image is scaled down to the smallest size as if `none` or `contain` were specified. The smaller concrete size is used.

Landscape Image
Portrait Image
.object-fit-none

The image is not resized. It maintains its intrinsic size. If larger than the container, it will be clipped.

Landscape Image
Portrait Image

Code Examples


<!-- Container for demonstration (fixed size, overflow hidden) -->
<div style="width: 150px; height: 150px; overflow: hidden;">
    <img src="path/to/your/image.jpg" class="object-fit-contain" alt="Description">
</div>

<!-- object-fit: contain -->
<img src="path/to/your/image.jpg" class="object-fit-contain" style="width: 100%; height: 100%;">

<!-- object-fit: cover -->
<img src="path/to/your/image.jpg" class="object-fit-cover" style="width: 100%; height: 100%;">

<!-- object-fit: fill -->
<img src="path/to/your/image.jpg" class="object-fit-fill" style="width: 100%; height: 100%;">

<!-- object-fit: scale-down (using .object-fit-scale utility) -->
<img src="path/to/your/image.jpg" class="object-fit-scale" style="width: 100%; height: 100%;">

<!-- object-fit: none -->
<img src="path/to/your/image.jpg" class="object-fit-none" style="width: 100%; height: 100%;">
                            

Object Fit Class Selector Reference

The following patterns outline all available object-fit utility classes.

Object Fit Classes:

.object-fit-contain Utility Class

Applies object-fit: contain !important;. The content is scaled to maintain its aspect ratio while fitting within the element's content box.

.object-fit-cover Utility Class

Applies object-fit: cover !important;. The content is scaled to maintain its aspect ratio while filling the element's entire content box. The object will be clipped to fit.

.object-fit-fill Utility Class

Applies object-fit: fill !important;. The content is sized to fill the element's content box. The object's aspect ratio will **not** be maintained.

.object-fit-scale Utility Class

Applies object-fit: scale-down !important;. The content is sized as if none or contain were specified, whichever results in the smaller concrete object size.

.object-fit-none Utility Class

Applies object-fit: none !important;. The content is not resized to fit. It maintains its intrinsic dimensions.

When using this class, ensure the image's container has explicit dimensions (width/height) and potentially overflow: hidden; if clipping is desired.

Example: Usage Example

<img src="..." class="object-fit-cover">

<video src="..." class="object-fit-contain"></video>

Opacity Properties

Control the opacity (transparency) of elements with these utility classes. Opacity values range from `0` (fully transparent) to `100` (fully opaque), affecting the visibility of the element itself and its content.

Examples

.opacity-0 (0% visible)
.opacity-25 (25% visible)
.opacity-50 (50% visible)
.opacity-75 (75% visible)
.opacity-100 (100% visible)
<div class="opacity-0">...</div>
<div class="opacity-25">...</div>
<div class="opacity-50">...</div>
<div class="opacity-75">...</div>
<div class="opacity-100">...</div>

Opacity Class Selector Reference

The following patterns outline all available opacity utility classes.

Opacity Classes:

.opacity-0 Utility Class

Sets opacity: 0 !important;. The element is fully transparent.

.opacity-25 Utility Class

Sets opacity: 0.25 !important;. The element is 25% opaque.

.opacity-50 Utility Class

Sets opacity: 0.5 !important;. The element is 50% opaque.

.opacity-75 Utility Class

Sets opacity: 0.75 !important;. The element is 75% opaque.

.opacity-100 Utility Class

Sets opacity: 1 !important;. The element is fully opaque.

Example: Usage Example

.opacity-50

Order Properties

Control the visual order of flex items with these utility classes. These classes apply the order CSS property, allowing you to reorder items within a flex container regardless of their source order in the HTML.

How it Works

Order utility classes are used on **flex items** (direct children of a flex container, i.e., an element with `display: flex` or `display: inline-flex`). The base classes follow the pattern .order-{value}, where {value} typically ranges from 0 to 5. Additionally, special classes like .order-first and .order-last are available to quickly position items at the beginning or end of the flex line, respectively.

Order utilities also support responsive variations using standard breakpoints (e.g., .order-md-2, .order-lg-first), allowing for different visual orders on various screen sizes.

Examples

Demonstrations of how order utilities reorder flex items:

Default Order
1
2
3

Items are displayed in their source order (default `order: 0`).

Using .order-first and .order-last
1
2 (Last)
3
4 (First)
5

.order-first sets order: -1, and .order-last sets a high order value (e.g., `order: 6`).

Numbered Order
Item A (order 3)
Item B (order 1)
Item C (order 2)
Item D (order 0)

Items are arranged by their `order` value, with lower values appearing first.

Responsive Order (Resize your browser to see effect)
Item A (md-last)
Item B (default)
Item C (md-first)

By default, A, B, C. On medium screens and up, C will be first, B in middle, A last.

<!-- Default Order -->
<div class="d-flex">
    <div>1</div>
    <div>2</div>
    <div>3</div>
</div>

<!-- Using .order-first and .order-last -->
<div class="d-flex">
    <div>Item 1</div>
    <div class="order-last">Item 2 (Last)</div>
    <div>Item 3</div>
    <div class="order-first">Item 4 (First)</div>
</div>

<!-- Numbered Order -->
<div class="d-flex">
    <div class="order-3">Item A</div>
    <div class="order-1">Item B</div>
    <div class="order-2">Item C</div>
    <div class="order-0">Item D</div>
</div>

<!-- Responsive Order -->
<div class="d-flex">
    <div class="order-md-last">Item A</div>
    <div>Item B</div>
    <div class="order-md-first">Item C</div>
</div>

Order Class Selector Reference

The following patterns outline all available order utility classes.

Default Order Classes:

.order-{value} Utility Class

Sets the order of a flex item. {value} can be 0 through 5. Items with lower order values appear first.

.order-first Utility Class

Sets order: -1 !important;, ensuring the item appears first in the visual order.

.order-last Utility Class

Sets a high order value (e.g., order: 6 !important;), ensuring the item appears last in the visual order.

Example: Usage Example

.order-1, .order-last

Responsive Order Classes:

Apply order utilities responsively by appending the breakpoint abbreviation to the class name. This allows for different visual orders based on screen size.

.order-{breakpoint}-{value} Utility Class Pattern

Sets the order from the specified breakpoint and up. {value} can be 0 through 5.

.order-{breakpoint}-first Utility Class Pattern

Sets order: -1 !important; from the specified breakpoint and up.

.order-{breakpoint}-last Utility Class Pattern

Sets a high order value (e.g., order: 6 !important;) from the specified breakpoint and up.

Available Breakpoints: Breakpoints

xxs, xs, sm, md, lg, xl, xxl

Example: Usage Example

.order-sm-2, .order-lg-first

Overflow Properties

Control how content that overflows an element's box is handled. These utilities apply the CSS overflow, overflow-x, and overflow-y properties.

Common Overflow Values

Apply these classes to control overflow on both horizontal and vertical axes simultaneously.

This content is purposefully long to demonstrate the 'auto' overflow behavior. If the content exceeds the box's dimensions, scrollbars will appear as needed for the overflowing axis. This content is purposefully long to demonstrate the 'auto' overflow behavior.
This content is purposefully long to demonstrate the 'hidden' overflow behavior. Any content that exceeds the box's dimensions will be clipped and not visible. There will be no scrollbars. This content is purposefully long to demonstrate the 'hidden' overflow behavior.
This content is purposefully long to demonstrate the 'visible' overflow behavior. Content will render outside the box's dimensions if it overflows. This is the default behavior. There will be no scrollbars. This content is purposefully long to demonstrate the 'visible' overflow behavior.
This content is purposefully long to demonstrate the 'scroll' overflow behavior. Scrollbars will always appear for both axes, even if the content does not overflow on one or both axes. This provides a consistent user experience. This content is purposefully long to demonstrate the 'scroll' overflow behavior.

Horizontal Overflow (overflow-x)

Control horizontal content overflow behavior only, while vertical overflow remains at its default or defined value (e.g., `visible`).

ThisIsAVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongStringOfTextThatWillCauseHorizontalOverflowIfItDoesNotWrap.
ThisIsAVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongStringOfTextThatWillCauseHorizontalOverflowIfItDoesNotWrap.
ThisIsAVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongStringOfTextThatWillCauseHorizontalOverflowIfItDoesNotWrap.
ThisIsAVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongStringOfTextThatWillCauseHorizontalOverflowIfItDoesNotWrap.

Vertical Overflow (overflow-y)

Control vertical content overflow behavior only, while horizontal overflow remains at its default or defined value (e.g., `visible`).

This content is purposefully long to demonstrate vertical overflow-y-auto. Line 2. Line 3. Line 4. Line 5. Line 6. Line 7. Line 8. Line 9. Line 10. More lines to ensure vertical overflow. Line 12. Line 13. Line 14. Line 15. Line 16. Line 17. Line 18. Line 19. Line 20.
This content is purposefully long to demonstrate vertical overflow-y-hidden. Line 2. Line 3. Line 4. Line 5. Line 6. Line 7. Line 8. Line 9. Line 10. More lines to ensure vertical overflow. Line 12. Line 13. Line 14. Line 15. Line 16. Line 17. Line 18. Line 19. Line 20.
This content is purposefully long to demonstrate vertical overflow-y-visible. Line 2. Line 3. Line 4. Line 5. Line 6. Line 7. Line 8. Line 9. Line 10. More lines to ensure vertical overflow. Line 12. Line 13. Line 14. Line 15. Line 16. Line 17. Line 18. Line 19. Line 20.
This content is purposefully long to demonstrate vertical overflow-y-scroll. Line 2. Line 3. Line 4. Line 5. Line 6. Line 7. Line 8. Line 9. Line 10. More lines to ensure vertical overflow. Line 12. Line 13. Line 14. Line 15. Line 16. Line 17. Line 18. Line 19. Line 20.
<div class="overflow-auto">...</div>
<div class="overflow-hidden">...</div>
<div class="overflow-visible">...</div>
<div class="overflow-scroll">...</div>
<div class="overflow-x-auto">...</div>
<div class="overflow-y-hidden">...</div>

Overflow Class Selector Reference

The following patterns outline all available overflow utility classes.

General Overflow Classes:

.overflow-auto Utility Class

Sets overflow: auto !important;. Adds scrollbars only when content overflows.

.overflow-hidden Utility Class

Sets overflow: hidden !important;. Clips overflowing content without providing scrollbars.

.overflow-visible Utility Class

Sets overflow: visible !important;. Overflowing content is not clipped and renders outside the element's box.

.overflow-scroll Utility Class

Sets overflow: scroll !important;. Always shows scrollbars, even if content does not overflow.

Example: Usage Example

.overflow-hidden, .overflow-auto

Horizontal Overflow Classes (X-axis):

.overflow-x-auto Utility Class

Sets overflow-x: auto !important;. Adds a horizontal scrollbar only when content overflows horizontally.

.overflow-x-hidden Utility Class

Sets overflow-x: hidden !important;. Clips horizontal overflowing content.

.overflow-x-visible Utility Class

Sets overflow-x: visible !important;. Horizontal overflowing content is not clipped.

.overflow-x-scroll Utility Class

Sets overflow-x: scroll !important;. Always shows a horizontal scrollbar.

Example: Usage Example

.overflow-x-scroll

Vertical Overflow Classes (Y-axis):

.overflow-y-auto Utility Class

Sets overflow-y: auto !important;. Adds a vertical scrollbar only when content overflows vertically.

.overflow-y-hidden Utility Class

Sets overflow-y: hidden !important;. Clips vertical overflowing content.

.overflow-y-visible Utility Class

Sets overflow-y: visible !important;. Vertical overflowing content is not clipped.

.overflow-y-scroll Utility Class

Sets overflow-y: scroll !important;. Always shows a vertical scrollbar.

Example: Usage Example

.overflow-y-auto

Position Properties

Control the positioning method and exact placement of elements using these utility classes.

Position Types

Apply these classes to change the position property of an element, affecting how it is positioned in the document flow.

.position-static (Default)

Elements are positioned according to the normal flow of the document. `top`, `bottom`, `left`, `right`, and `z-index` properties have no effect.

Static
.position-relative

Elements are positioned relative to their normal position. `top`, `bottom`, `left`, `right` properties will offset them from that normal position. Crucially, a relative element establishes a new positioning context for its children, meaning any `position-absolute` children will be positioned relative to this element.

Relative
.position-absolute

Elements are removed from the normal document flow and positioned relative to their *nearest positioned ancestor* (an ancestor with `position: relative`, `absolute`, `fixed`, or `sticky`). If no such ancestor exists, they are positioned relative to the initial containing block (usually the `html` element).

Absolute
.position-fixed

Elements are removed from the normal document flow and positioned relative to the *viewport*. They remain in the same position even when the page is scrolled, useful for fixed headers, footers, or sidebars.

Fixed

(Scroll down to see the fixed element stick to the viewport)

<!-- In the live documentation, the 'Fixed' element's position styling is commented out to allow scrolling. -->
<!-- If the 'position: fixed;', 'bottom', 'right', and 'z-index' properties below were uncommented, -->
<!-- the green 'Fixed' element would remain locked to the bottom right of the screen during scroll. -->
.position-fixed-example {
  /* position: fixed; */
  /* bottom: 20px; */
  /* right: 20px; */
  /* z-index: 1000; */
  background-color: var(--success);
  width: 100px;
  height: 60px;
  /* ... other non-positioning styling ... */
}
.position-sticky

Elements are positioned based on the user's scroll position. A sticky element is treated as `relative` until a specified offset position is met in the viewport (e.g., `top: 0`), at which point it becomes `fixed` and sticks. It reverts to `relative` if it scrolls past the bottom of its parent.

Sticky Header

Scroll down this box to see the "Sticky Header" element stick to the top of its parent scrollable area when it reaches the top offset (which is `top: 0` in this case).

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.

Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.

Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.

This section ensures there is enough scrollable content to demonstrate the sticky behavior effectively.

Top, Bottom, Start, End Positioning

Use these utilities (e.g., `top-0`, `start-50`, `bottom-100`) to precisely place positioned elements (like `position-absolute` or `position-fixed`) relative to their containing block or the viewport.

top-0 start-0
top-0 end-0
top-50 start-50
bottom-0 start-0
bottom-0 end-0
top-100 start-100

Position Class Selector Reference

.top-0 Utility Class

Sets the element's `top` property to `0`.

.bottom-0 Utility Class

Sets the element's `bottom` property to `0`.

.start-0 Utility Class

Sets the element's `left` (or `inline-start` for RTL) property to `0`.

.end-0 Utility Class

Sets the element's `right` (or `inline-end` for RTL) property to `0`.

.top-50 Utility Class

Sets the element's `top` property to `50%`.

.bottom-50 Utility Class

Sets the element's `bottom` property to `50%`.

.start-50 Utility Class

Sets the element's `left` (or `inline-start` for RTL) property to `50%`.

.end-50 Utility Class

Sets the element's `right` (or `inline-end` for RTL) property to `50%`.

.top-100 Utility Class

Sets the element's `top` property to `100%`.

.bottom-100 Utility Class

Sets the element's `bottom` property to `100%`.

.start-100 Utility Class

Sets the element's `left` (or `inline-start` for RTL) property to `100%`.

.end-100 Utility Class

Sets the element's `right` (or `inline-end` for RTL) property to `100%`.

.translate-middle Utility Class

Applies `transform: translate(-50%, -50%)`, useful for centering an element based on its own size relative to its positioned parent.

.translate-middle-x Utility Class

Applies `transform: translateX(-50%)`, useful for horizontally centering an element relative to its positioned parent.

.translate-middle-y Utility Class

Applies `transform: translateY(-50%)`, useful for vertically centering an element relative to its positioned parent.

Translate for Centering

Conveniently center an absolutely positioned element (both horizontally and vertically) within its parent by combining `top-50`, `start-50`, and the `translate-middle` utility.

Centered
Centered X
Centered Y

You can also center along a single axis:

<!-- General Position Classes -->
<div class="position-static">Static</div>
<div class="position-relative">
  <div class="position-absolute">Absolute Child</div>
</div>
<div class="position-fixed">Fixed Element</div>
<div class="position-sticky">Sticky Element</div>

<!-- Placement Utilities -->
<div class="position-relative">
  <div class="position-absolute top-0 start-0">Top Left</div>
  <div class="position-absolute bottom-50 end-100">Bottom 50% Right 100%</div>
</div>

<!-- Centering Utilities -->
<div class="position-relative">
  <div class="position-absolute top-50 start-50 translate-middle">Fully Centered</div>
  <div class="position-absolute top-0 start-50 translate-middle-x">Centered Horizontally</div>
  <div class="position-absolute top-50 end-0 translate-middle-y">Centered Vertically</div>
</div>

Shadow Properties

Apply various box shadows to elements for depth and visual elevation using these utility classes.

Shadow Class Selector Reference

.shadow-none Utility Class

Removes any box shadow from the element.

.shadow-sm Utility Class

Applies a small, subtle box shadow for a slight elevation effect.

.shadow Utility Class

Applies a standard box shadow for a moderate elevation effect.

.shadow-lg Utility Class

Applies a large box shadow for a pronounced elevation effect.

Examples

.shadow-none
.shadow-sm
.shadow
.shadow-lg
<div class="shadow-none">No Shadow</div>
<div class="shadow-sm">Small Shadow</div>
<div class="shadow">Default Shadow</div>
<div class="shadow-lg">Large Shadow</div>

Sizing Properties

Sizing Class Selector Reference

Set the width and height of elements quickly and responsively using these concise utility classes, supporting percentage and viewport units.

Width Utilities

.w-25 Utility Class

Sets the element's `width` to `25%`.

.w-50 Utility Class

Sets the element's `width` to `50%`.

.w-75 Utility Class

Sets the element's `width` to `75%`.

.w-100 Utility Class

Sets the element's `width` to `100%`.

.w-auto Utility Class

Sets the element's `width` to `auto`.

Height Utilities

.h-25 Utility Class

Sets the element's `height` to `25%`.

.h-50 Utility Class

Sets the element's `height` to `50%`.

.h-75 Utility Class

Sets the element's `height` to `75%`.

.h-100 Utility Class

Sets the element's `height` to `100%`.

.h-auto Utility Class

Sets the element's `height` to `auto`.

Max-Width & Max-Height

.mw-100 Utility Class

Sets the element's `max-width` to `100%`.

.mh-100 Utility Class

Sets the element's `max-height` to `100%`.

Min-Viewport & Viewport Sizing

.min-vw-100 Utility Class

Sets the element's `min-width` to `100vw` (100% of viewport width).

.min-vh-100 Utility Class

Sets the element's `min-height` to `100vh` (100% of viewport height).

.vw-100 Utility Class

Sets the element's `width` to `100vw` (100% of viewport width).

.vh-100 Utility Class

Sets the element's `height` to `100vh` (100% of viewport height).

Examples

Width 50%, Height 25%
Width 75%, Height 50%
Width 100%, Height Auto (content-driven)

Note: To see `vh-100` or `vw-100` in action, you'd typically apply them to a top-level element or test in a separate context to observe full viewport coverage.

<div class="w-50 h-25">Width 50%, Height 25%</div>
<div class="w-75 h-50">Width 75%, Height 50%</div>
<div class="w-100 h-auto">Width 100%, Height Auto (content-driven)</div>

<div class="mw-100">Max Width 100%</div>
<div class="min-vh-100">Min Viewport Height 100%</div>
<div class="vw-100 vh-100">Viewport Width 100%, Viewport Height 100%</div>

Spacing Properties

Control the margin and padding of elements with a comprehensive set of responsive spacing utility classes. These classes are built on a consistent spacing scale, allowing for precise control over element positioning and layout.

How it Works

Spacing classes are named using the format .{property}{sides}-{size} for fixed spacing, .{property}{sides}-{breakpoint}-{size} for responsive spacing, and .m{sides}-n{size} for negative margins.

{property}
Identifier

m for `margin`

p for `padding`

{sides}
Identifier (optional)

(empty): Applies to all 4 sides

t: Applies to `*-top`

b: Applies to `*-bottom`

s: Applies to `*-left` (start in LTR)

e: Applies to `*-right` (end in LTR)

x: Applies to horizontal sides (`*-left` and `*-right`)

y: Applies to vertical sides (`*-top` and `*-bottom`)

{size}
Value

0 through 8 from the spacing scale.

auto (only for margins) for `margin: auto;`.

{breakpoint}
Value (optional)

Standard breakpoints: xxs, xs, sm, md, lg, xl, xxl. Applied from this breakpoint size and up.

n{size}
Value (for negative margin)

n followed by a size (e.g., n1 for negative 0.25rem).

Spacing Scale Values

The spacing scale is based on a default $spacer of 1rem (typically 16px). The sizes correspond to:

0
Size Value

0rem (0px)

1
Size Value

0.25rem (4px)

2
Size Value

0.5rem (8px)

3
Size Value

0.75rem (12px)

4
Size Value

1rem (16px)

5
Size Value

1.5rem (24px)

6
Size Value

2.25rem (36px)

7
Size Value

3rem (48px)

8
Size Value

4rem (64px)

Examples

Here are some practical examples of using spacing utilities:

.p-4 (16px padding all sides)
.mt-5 (24px top margin) .pb-3 (12px bottom padding)
.mx-auto (Horizontally centered element)
.p-sm-2 (8px padding on small screens)
.p-md-5 (24px padding on medium screens and up)
.ms-n3 (-12px left margin, causing overlap)
<!-- Element with padding on all sides (16px) -->
<div class="p-4 border">
This div has padding.
</div>

<!-- Element with margin-top (24px) and padding-bottom (12px) -->
<div class="mt-5 pb-3 bg-light">
Margin Top, Padding Bottom.
</div>

<!-- Horizontally centered block element -->
<div class="mx-auto w-50 border">
Centered Element.
</div>

<!-- Responsive padding: 8px on small screens, 24px on medium screens and up -->
<div class="p-sm-2 p-md-5 bg-info-light">
Responsive Padding.
</div>

<!-- Element with negative margin on the left for overlap -->
<div class="ms-n3 bg-warning-light">
Negative Margin Left.
</div>

Spacing Class Selector Reference

The following patterns outline all available spacing utility classes. Breakpoints (sm, md, lg, xl, xxl) can be inserted before the size for responsive variants.

Margin Classes (m):

.m-{size} Utility Class

Applies margin to all sides. Sizes: 0-8, auto.

.m{side}-{size} Utility Class

Applies margin to specific sides (e.g., mt-, mb-, ms-, me-, mx-, my-). Sizes: 0-8, auto.

.m-{breakpoint}-{size} Utility Class

Responsive `margin` to all sides.

.m{side}-{breakpoint}-{size} Utility Class

Responsive `margin` to specific sides.

.m-n{size} Utility Class

Negative `margin` to all sides. Sizes: 1-8.

.m{side}-n{size} Utility Class

Negative `margin` to specific sides. Sizes: 1-8.

.m-{breakpoint}-n{size} Utility Class

Responsive negative `margin` to all sides.

.m{side}-{breakpoint}-n{size} Utility Class

Responsive negative `margin` to specific sides.

Example: Usage Example

.m-3, .mt-auto, .mx-lg-5, .m-n2, .mb-xl-n4

Padding Classes (p):

.p-{size} Utility Class

Applies padding to all sides. Sizes: 0-8.

.p{side}-{size} Utility Class

Applies padding to specific sides (e.g., pt-, pb-, ps-, pe-, px-, py-). Sizes: 0-8.

.p-{breakpoint}-{size} Utility Class

Responsive `padding` to all sides.

.p{side}-{breakpoint}-{size} Utility Class

Responsive `padding` to specific sides.

Example: Usage Example

.p-4, .py-2, .ps-md-0

Text Properties

Control the appearance and behavior of text content with a comprehensive set of utility classes for alignment, transformation, weight, style, decoration, line height, font size, user selection, and pointer events.

How it Works

Text utility classes are primarily named using descriptive patterns such as .text-{value} for alignment, .fw-{value} for font weight, or .fs-{value} for font size. Many text alignment classes also support responsive variations using standard breakpoints (sm, md, lg, xl, xxl), following the pattern .text-{breakpoint}-{align}.

Responsive Text Alignment

Text alignment can be applied responsively to different screen sizes. For example, applying .text-center will center text on all screen sizes, whereas .text-md-start will align text to the start (left in LTR) only on medium (md) screens and up, overriding any smaller breakpoint alignment.

Examples

Demonstrations of various text utility classes:

Text Alignment

.text-start - Lorem ipsum dolor sit amet.

.text-center - Lorem ipsum dolor sit amet.

.text-end - Lorem ipsum dolor sit amet.

.text-justify - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

.text-start.text-md-center - Aligned start by default, centered on medium screens and up.

Text Transformation

.text-lowercase - This text is lowercase.

.text-uppercase - This text is uppercase.

.text-capitalize - this text is capitalized.

Text Wrapping & Overflow
.text-wrap - This is a very long line of text that should wrap within its container.
.text-nowrap - This is a very long line of text that will not wrap and will be clipped.
.text-break - ThisIsAVeryLongWordWithoutSpacesThatShouldBreakToFitTheContainer.
.text-truncate - This is a very long line of text that should be truncated with an ellipsis.
Font Weight

.fw-light - This text has a light font weight (300).

.fw-lighter - This text has a lighter font weight.

.fw-normal - This text has a normal font weight (400).

.fw-bold - This text has a bold font weight (700).

.fw-bolder - This text has a bolder font weight.

Font Style

.fst-italic - This text is italic.

.fst-normal - This text is normal style.

Text Decoration

.text-decoration-none - No underline on this link.

.text-decoration-underline - This text is underlined.

.text-decoration-line-through - This text has a line through it.

Line Height

.lh-1 - This text has a line height of 1.
This is another line to show spacing.

.lh-sm - This text has a line height of 1.25.
This is another line to show spacing.

.lh-base - This text has a line height of 1.5 (default).
This is another line to show spacing.

.lh-lg - This text has a line height of 2.
This is another line to show spacing.

Font Size

.fs-1 - Font Size 1 (2.5rem)

.fs-2 - Font Size 2 (2rem)

.fs-3 - Font Size 3 (1.75rem)

.fs-4 - Font Size 4 (1.5rem)

.fs-5 - Font Size 5 (1.25rem)

.fs-6 - Font Size 6 (1rem)

User Selection

.user-select-all - This text will be entirely selected when you click on it.

.user-select-auto - This text has default user-select behavior (you can select parts of it).

.user-select-none - You cannot select this text.

Pointer Events
.pe-none (on parent), .pe-auto (on child) - This parent div is unclickable, but this link inside it is clickable.

Note: .pe-none prevents all pointer events, effectively making an element "unclickable". .pe-auto re-enables them, which is useful for selectively making child elements interactive within a .pe-none parent.

<!-- Text Alignment -->
<p class="text-start">This text aligns to the start.</p>
<p class="text-end">This text aligns to the end.</p>
<p class="text-center">This text is centered.</p>
<p class="text-justify">This is a longer paragraph of text that will be justified...</p>
<p class="text-start text-md-center">This text starts aligned, but centers on medium screens and above.</p>
<p class="text-lg-end">This text aligns to the end on large screens and above.</p>

<!-- Text Transformation -->
<p class="text-lowercase">This text will be all lowercase.</p>
<p class="text-uppercase">This text will be all uppercase.</p>
<p class="text-capitalize">this text will have each word capitalized.</p>

<!-- Text Wrapping & Overflow -->
<div class="text-wrap example-width-150 example-border">This is a very long line of text that should wrap...</div>
<div class="text-nowrap example-width-150 example-border example-overflow-hidden">This is a very long line of text that will not wrap...</div>
<div class="text-break example-width-150 example-border">ThisIsAVeryLongWordWithoutSpacesThatShouldBreak...</div>
<div class="text-truncate example-width-200 example-border">This is a very long line of text that should be truncated...</div>

<!-- Font Weight -->
<p class="fw-light">This text has a light font weight.</p>
<p class="fw-lighter">This text has a lighter font weight.</p>
<p class="fw-normal">This text has a normal font weight.</p>
<p class="fw-bold">This text has a bold font weight.</p>
<p class="fw-bolder">This text has a bolder font weight.</p>

<!-- Font Style -->
<p class="fst-italic">This text is italic.</p>
<p class="fst-normal">This text is normal style.</p>

<!-- Text Decoration -->
<a href="#" class="text-decoration-none">This link has no underline.</a>
<p class="text-decoration-underline">This text is underlined.</p>
<p class="text-decoration-line-through">This text has a line through it.</p>

<!-- Line Height -->
<p class="lh-1">This text has a line height of 1.<br>This is another line to show tight spacing.</p>
<p class="lh-sm">This text has a small line height.<br>This is another line to show spacing.</p>
<p class="lh-base">This text has a baseline height.<br>This is another line to show spacing.</p>
<p class="lh-lg">This text has a large line height.<br>This is another line to show wide spacing.</p>

<!-- Font Size -->
<p class="fs-1">Font Size 1</p>
<p class="fs-2">Font Size 2</p>
<p class="fs-3">Font Size 3</p>
<p class="fs-4">Font Size 4</p>
<p class="fs-5">Font Size 5</p>
<p class="fs-6">Font Size 6</p>

<!-- User Selection -->
<p class="user-select-all">This text will be entirely selected when you click on it.</p>
<p class="user-select-auto">This text has default user-select behavior.</p>
<p class="user-select-none">You cannot select this text.</p>

<!-- Pointer Events -->
<a href="#unclickable" class="pe-none d-block bg-light-orange p-2">This entire link is unclickable.</a>
<div class="pe-none bg-light-orange p-2">
    This parent div is unclickable, but<a href="#clickable" class="pe-auto">this link inside it is clickable.</a>
</div>

Text Class Selector Reference

The following patterns outline all available text utility classes. Responsive variants are primarily available for text alignment.

Text Alignment:

.text-start Utility Class

Aligns text to the start (left in LTR, right in RTL).

.text-end Utility Class

Aligns text to the end (right in LTR, left in RTL).

.text-center Utility Class

Centers text.

.text-justify Utility Class

Justifies text.

.text-{breakpoint}-start Utility Class

Aligns text to start from a specific breakpoint and up (e.g., .text-md-start).

.text-{breakpoint}-end Utility Class

Aligns text to end from a specific breakpoint and up.

.text-{breakpoint}-center Utility Class

Centers text from a specific breakpoint and up.

.text-{breakpoint}-justify Utility Class

Justifies text from a specific breakpoint and up.

Example: Usage Example

.text-sm-center, .text-lg-end

Text Transformation:

.text-lowercase Utility Class

Transforms text to lowercase.

.text-uppercase Utility Class

Transforms text to uppercase.

.text-capitalize Utility Class

Capitalizes the first letter of each word.

Text Wrapping & Overflow:

.text-wrap Utility Class

Allows text to wrap normally.

.text-nowrap Utility Class

Prevents text from wrapping onto a new line.

.text-break Utility Class

Forces words to break to prevent overflow, applying word-wrap:break-word and word-break:break-word.

.text-truncate Utility Class

Truncates text with an ellipsis. This class applies overflow:hidden;, text-overflow:ellipsis;, and white-space:nowrap;. It typically requires a defined width or max-width on the element to be effective.

Font Weight:

.fw-light Utility Class

Sets font weight to 300.

.fw-lighter Utility Class

Sets font weight to a lighter value relative to the parent.

.fw-normal Utility Class

Sets font weight to 400.

.fw-bold Utility Class

Sets font weight to 700.

.fw-bolder Utility Class

Sets font weight to a bolder value relative to the parent.

Font Style:

.fst-italic Utility Class

Sets font style to italic.

.fst-normal Utility Class

Sets font style to normal.

Text Decoration:

.text-decoration-none Utility Class

Removes text decoration (e.g., underlines from links).

.text-decoration-underline Utility Class

Adds an underline to text.

.text-decoration-line-through Utility Class

Adds a line-through to text.

Line Height:

.lh-1 Utility Class

Sets line height to 1.

.lh-sm Utility Class

Sets line height to 1.25.

.lh-base Utility Class

Sets line height to 1.5 (default).

.lh-lg Utility Class

Sets line height to 2.

Font Size:

.fs-1 Utility Class

Sets font size to 2.5rem.

.fs-2 Utility Class

Sets font size to 2rem.

.fs-3 Utility Class

Sets font size to 1.75rem.

.fs-4 Utility Class

Sets font size to 1.5rem.

.fs-5 Utility Class

Sets font size to 1.25rem.

.fs-6 Utility Class

Sets font size to 1rem.

User Selection:

.user-select-all Utility Class

Allows the user to select all content with a single click within the element.

.user-select-auto Utility Class

Default browser behavior for user selection.

.user-select-none Utility Class

Prevents text and element selection.

Pointer Events:

.pe-none Utility Class

Prevents all pointer events (like clicks, hovers, scroll) on the element.

.pe-auto Utility Class

Re-enables pointer events on the element (useful for overriding .pe-none applied to a parent).

Vertical Alignment Properties

Easily change the vertical alignment of inline, inline-block, inline-table, and table cell elements with these utility classes. These classes apply the vertical-align CSS property.

How it Works

Vertical alignment utility classes are named using the pattern .align-{value}, where {value} corresponds to standard CSS vertical-align property values. These classes are designed to work effectively on elements that have an intrinsic vertical alignment behavior, such as images, icons, or cells within a table layout.

Examples

Demonstrations of various vertical alignment utility classes, applied to inline elements within a shared baseline:

Vertical Alignment Options
baseline top middle bottom text-top text-bottom
baseline top middle bottom text-top text-bottom
<span class="align-baseline">baseline></span>
<span class="align-top">top</span>
<span class="align-middle">middle</span>
<span class="align-bottom">bottom</span>
<span class="align-text-top">text-top</span>
<span class="align-text-bottom">text-bottom</span>

<!-- Example in table element -->
...same code as above

Vertical Alignment Class Selector Reference

The following patterns outline all available vertical alignment utility classes.

Vertical Alignment:

.align-baseline Utility Class

Sets vertical-align: baseline; Aligns the baseline of the element with the baseline of its parent.

.align-top Utility Class

Sets vertical-align: top; Aligns the top of the element with the top of the tallest element on the line.

.align-middle Utility Class

Sets vertical-align: middle; Aligns the middle of the element with the baseline plus half the x-height of the parent.

.align-bottom Utility Class

Sets vertical-align: bottom; Aligns the bottom of the element with the lowest element on the line.

.align-text-top Utility Class

Sets vertical-align: text-top; Aligns the top of the element with the top of the parent font.

.align-text-bottom Utility Class

Sets vertical-align: text-bottom; Aligns the bottom of the element with the bottom of the parent font.

Example: Usage Example

.align-middle, .align-top

Visibility Properties

Control the visibility of elements without affecting their layout in the document flow. Elements with these utilities will still occupy their designated space even when hidden.

How it Works

Visibility utility classes are straightforward, directly applying the visibility CSS property. The .visible class makes an element visible, while the .invisible class hides it. Importantly, unlike display: none, hidden elements still consume layout space.

Examples

Demonstrations of visibility utility classes and their effect on layout:

Element Visibility

.visible - This text is visible.

This is a follow-up paragraph, demonstrating that the invisible element above still takes up its space.

Comparison with Display Utilities

Observe how .invisible differs from .d-none (display: none):

Box 1 (Visible)
Box 3 (Visible)
Box 1 (Visible)
Box 2 (Display None)
Box 3 (Visible)

Note: In the first row, "Box 2 (Invisible)" occupies its space, leading to a gap. In the second row, "Box 2 (Display None)" is completely removed from the document flow, so "Box 3" immediately follows "Box 1".

<!-- Visible Element -->
<div class="visible">This element is visible.</div>

<!-- Invisible Element -->
<div class="invisible">This element is invisible but takes up space.</div>

<!-- Comparison -->
<span>Hello</span>
<span class="invisible">Invisible Text</span>
<span>World</span>

<!-- Versus display: none -->
<span>Hello</span>
<span class="d-none">Display None Text</span>
<span>World</span>

Visibility Class Selector Reference

The following patterns outline all available visibility utility classes.

Visibility:

.visible Utility Class

Sets visibility: visible !important; The element is visible.

.invisible Utility Class

Sets visibility: hidden !important; The element is hidden but still occupies layout space.

Example: Usage Example

.visible, .invisible

Z-Index Properties

Control the stacking order of elements along the Z-axis (depth). These utilities apply the z-index CSS property, allowing you to specify which elements appear on top of others when they overlap.

How it Works

The z-index property affects elements that are positioned (i.e., have a position value other than static, such as relative, absolute, fixed, or sticky). Elements with a higher z-index value will appear on top of elements with a lower value when they overlap within the same stacking context.

These utilities provide predefined z-index values from -1 to 3, allowing for quick control over stacking order for common UI patterns like modals, tooltips, and overlapping components. Remember that `z-index` only works on positioned elements.

Examples

Observe how different z-index utilities affect the stacking order of overlapping elements. Each example uses absolutely positioned elements within a relative container.

Default Stacking (No Z-Index)

Elements stack according to their order in the DOM (later elements on top).

Box A
Box B
Box C
Positive Z-Index Stacking

Higher z-index values bring elements to the front.

Box A (z-1)
Box B (z-3)
Box C (z-2)
Negative Z-Index Stacking

Negative z-index values push elements behind their parent or other elements.

Parent/Base (z-0)
Box A (z-1)
Box B (z-n1)
Box C (z-0)

Code Examples


<!-- Example of Z-index usage -->
<div class="position-relative" style="height: 150px; border: 1px dashed #ccc;">
    <div class="position-absolute z-1" style="top: 10px; left: 10px; background-color: red;">Element A (z-1)</div>
    <div class="position-absolute z-3" style="top: 30px; left: 30px; background-color: green;">Element B (z-3)</div>
    <div class="position-absolute z-2" style="top: 50px; left: 50px; background-color: blue;">Element C (z-2)</div>
</div>

<!-- Example with negative z-index -->
<div class="position-relative" style="height: 150px; border: 1px dashed #ccc;">
    <div class="position-absolute" style="top: 0; left: 0; width: 100%; height: 100%; background-color: lightyellow; z-index: 0;">Background Layer (z-0)</div>
    <div class="position-absolute z-n1" style="top: 20px; left: 20px; background-color: lightcoral;">Hidden Behind (z-n1)</div>
    <div class="position-absolute z-1" style="top: 40px; left: 40px; background-color: lightblue;">On Top (z-1)</div>
</div>
                        

Z-Index Class Selector Reference

The following patterns outline all available z-index utility classes.

Z-Index Classes:

.z-n1 Utility Class

Applies z-index: -1 !important;. Positions the element behind most other elements in its stacking context.

.z-0 Utility Class

Applies z-index: 0 !important;. Sets the element's stacking order to a base level.

.z-1 Utility Class

Applies z-index: 1 !important;. Positions the element one layer above elements with z-index: 0.

.z-2 Utility Class

Applies z-index: 2 !important;. Positions the element two layers above elements with z-index: 0.

.z-3 Utility Class

Applies z-index: 3 !important;. Positions the element three layers above elements with z-index: 0.

Example: Usage Example

<div class="position-absolute z-1">...</div>

<div class="modal z-3">...</div>

<div class="backdrop z-n1">...</div>

Examples

Explore practical implementation examples to see how the grid system works in real-world scenarios.

Responsive Layout

Header
Sidebar
Main Content
Footer
<Container>
  <Row>
    <Col xs={12}>Header</Col>
  </Row>

  <Row>
    <Col xs={12} md={3}>Sidebar</Col>
    <Col xs={12} md={9}>Main Content</Col>
  </Row>

  <Row>
    <Col xs={12}>Footer</Col>
  </Row>
</Container>

Customization

Learn how to customize the grid system to match your project's design requirements.

SCSS Variables

The grid system can be customized by overriding these SCSS variables:

// Breakpoint configuration
$grid-breakpoints: (
  xxs: 0,
  xs: 576px,
  sm: 768px,
  md: 992px,
  lg: 1200px,
  xl: 1400px,
  xxl: 1600px
);

// Container max-widths
$container-max-widths: (
  xs: 540px,
  sm: 720px,
  md: 960px,
  lg: 1140px,
  xl: 1320px,
  xxl: 1500px
);

// Grid settings
$grid-columns: 12;
$grid-gutter-width: 1.5rem;

Customizing in Your Project

To customize the grid, create a SCSS file with your overrides and import it before the grid system:

// your-custom.scss
$grid-columns: 24; // Use 24-column grid
$grid-gutter-width: 2rem; // Increase gutter size
$container-max-widths: (
  md: 1000px,
  lg: 1200px,
  xl: 1400px
);

// Import the grid after your customizations
@import 'path/to/responsive-grid';