Bootstrap 5 Image Thumbnail
Bootstrap 5's Image Thumbnail component adds a rounded border and padding around an image using the `.img-thumbnail` class, giving it a framed, polished appearance suitable for galleries and media grids. It renders responsively by default — the image scales within its container without overflowing. Use it when you need a consistent, bordered presentation for images rather than raw edge-to-edge display.
Primary Class
.image-thumbnailCommon Use Cases
- →Product image grids on e-commerce pages where each item photo needs a clean bordered frame to visually separate it from the background
- →Team member profile photos displayed in a card grid, where the thumbnail border creates a consistent, structured portrait layout
- →Portfolio or photography gallery pages where multiple images are arranged in a masonry or CSS Grid layout and uniform framing reinforces the design
- →Blog post image previews in an archive listing, where thumbnails sit alongside post metadata and need a subtle visual boundary to anchor them
Variants & Classes
| Variant | Description |
|---|---|
| Image Thumbnail Default | Standard image thumbnail with Bootstrap's default styling. |
| Image Thumbnail Responsive | Responsive variant that adapts to different screen sizes. |
Code Example
<div class="row g-3">
<div class="col-6 col-md-4">
<img src="/images/product-running-shoe.jpg" alt="Running shoe — Trail Pro X" class="img-thumbnail" width="300" height="300">
</div>
<div class="col-6 col-md-4">
<img src="/images/product-trail-boot.jpg" alt="Trail boot — Summit Series" class="img-thumbnail" width="300" height="300">
</div>
<div class="col-6 col-md-4">
<img src="/images/product-sandal.jpg" alt="Sandal — Coastal Drift" class="img-thumbnail" width="300" height="300">
</div>
</div>Live Examples
Basic Image Thumbnail
Canvas Framework Variants
The Canvas template extends Bootstrap 5 with 1,658+ component variants. Generate any of these using Canvas Builder:
- ✓Canvas Builder generated image thumbnail with custom colours
- ✓Image Thumbnail with interactive states
- ✓Responsive image thumbnail for all screen sizes
Best Practices
Set explicit width and height attributes
Always add `width` and `height` attributes to your `<img>` tags when using `.img-thumbnail` — this prevents cumulative layout shift (CLS) as the page loads and improves your Core Web Vitals score.
Combine with anchor tags for lightbox or navigation
Wrap the `<img class="img-thumbnail">` inside an `<a>` tag to make the framed image clickable — either linking to a full-size version or triggering a Bootstrap modal lightbox without any extra markup overhead.
Override the border colour with a CSS custom property
Bootstrap 5 uses `--bs-thumbnail-border-color` (mapped to `--bs-border-color` by default) — you can scope a custom border colour to just your gallery section with `.my-gallery img { --bs-thumbnail-border-color: #your-brand-hex; }` without touching global variables.
Pair with `object-fit: cover` for consistent aspect ratios
If your source images vary in size, add `style="object-fit: cover;"` along with fixed `width` and `height` values to ensure every thumbnail crops uniformly rather than distorting or leaving whitespace inside the border.