Image
Getting Started
An image. Part of the Bolt “Components” CSS framework that powers the Bolt Design System.
Install via NPM
npm install @bolt/components-image
Image sizes
To specify image size (e.g u-bolt-width-1/1
) pass the correct class like so:
{% set classes = create_attribute(imageAttributes | default({})).addClass([
"c-bolt-image__img",
"u-bolt-width-1/1",
])
%}
Then pass it into the component:
{% include '@bolt-components-image/image.twig' with {
src: "/images/placeholders/tout-4x3-climber.jpg",
alt: "A Rock Climber",
imageAttributes: classes,
} only %}
Usage
{% include '@bolt-components-image/image.twig' with {
src: "/src/images/turtle.jpg",
alt: "A Turtle"
} only %}
Schema
Name | Type | Value(s) | Description | Default |
---|---|---|---|---|
src | string
| |
Source url for image. |
N/A |
alt | string
| |
Alt tag for image. |
N/A |
lazyload | boolean
|
|
Lazyload can boost performance by loading images on demand, instead of on initial page load. |
true
|
srcset | string
| |
A comma seperated string of image urls and image widths, used for optimizing image loading performance. |
N/A |
sizes | string
| |
A list of one or more strings separated by commas indicating a set of source sizes. Each source size consists of a media condition (omitted for the last item), and a source size value. |
auto
|
useAspectRatio | boolean
|
|
Use the ratio wrapper around the image to maintain a specific image ratio. This ratio is either determined from the image, or by passing in |
true
|
width |
number OR string |
|
Override the default width of the image. If no height is provided, aspect ratio will be maintained. |
N/A |
height |
number OR string |
|
Override the default height of the image. If no width is provided, aspect ratio will be maintained. |
N/A |