Loading...
Skip to main content

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.

Responsive image

Image thumbnails

Set thumbnail on Image to give it a framed, rounded appearance.

A generic square placeholder image with a white border around it, making it resemble a photograph taken with an old instant camera

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.

Image aligned to the startImage aligned to the end
Image centered as a block
Image centered by its parent's text alignment

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.

A sample image inside a figure
A caption for the above image.

And with a reverse alignment:

A sample image inside a reverse-aligned figure
A caption for the above image.

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.

ComponentCSS variableDefault
Image thumbnail--bs-thumbnail-padding.25rem
--bs-thumbnail-bgvar(--bs-bg-body)
--bs-thumbnail-border-widthvar(--bs-border-width)
--bs-thumbnail-border-colorvar(--bs-border-color)
--bs-thumbnail-border-radiusvar(--bs-radius-5)
--bs-thumbnail-box-shadowvar(--bs-box-shadow-sm)
Figure--bs-figure-gapcalc(var(--bs-spacer) * .5)
--bs-figure-caption-font-sizevar(--bs-font-size-sm)
--bs-figure-caption-colorvar(--bs-fg-3)
Documentation navigation
On this page
On this page