Images
Use the Image wrapper for responsive images and common image treatments without manually adding their
underlying classes.
Set fluid for responsive sizing, thumbnail for a framed image, rounded for rounded corners,
or roundedCircle for a circular image. Native image attributes such as src, alt, width, and
height pass through.
For semantic image-and-caption groups, use Figure, FigureImage, and FigureCaption.
FigureImage is responsive by default.
Responsive images
Set fluid on Image to constrain its width to the parent while preserving its aspect ratio.
Image thumbnails
Set thumbnail on Image to give it a framed, rounded appearance.
Aligning images
Use layout utilities through className to float or align images. To center an image as a block,
combine mx-auto and d-block; a parent with text alignment can center an inline image.
Figures
Use Figure, FigureImage, and FigureCaption to group an image with an optional caption. Figure
is a flex container, so layout and alignment utilities can be passed through its className.
FigureImage is responsive by default; set fluid={false} to opt out.
And with a reverse alignment:
Picture
Use the native <picture> element when selecting among image sources. Put Image inside it so
image styling applies to the rendered image, not its parent.
Give Image an alt value that describes the image, or alt="" when it is only decorative. The
placeholder value in the example below should be replaced with meaningful text.
<picture>
<source srcset="..." type="image/svg+xml" />
<img src="..." alt="..." />
</picture>
CSS
Variables
Bootstrap exposes CSS variables for customizing image thumbnails and figures.
| Component | CSS variable | Default |
|---|---|---|
| Image thumbnail | --bs-thumbnail-padding | .25rem |
--bs-thumbnail-bg | var(--bs-bg-body) | |
--bs-thumbnail-border-width | var(--bs-border-width) | |
--bs-thumbnail-border-color | var(--bs-border-color) | |
--bs-thumbnail-border-radius | var(--bs-radius-5) | |
--bs-thumbnail-box-shadow | var(--bs-box-shadow-sm) | |
| Figure | --bs-figure-gap | calc(var(--bs-spacer) * .5) |
--bs-figure-caption-font-size | var(--bs-font-size-sm) | |
--bs-figure-caption-color | var(--bs-fg-3) |