Image Stroke
Outline a vector or transparent raster image so it stays legible on a shaded background. Set the stroke width and color with the image stroke utilities.
Usage
Preset size modifiers set the stroke width on an image. The default stroke is 1.5px white, with additional options for base (1.5px, equivalent to default), small (1px), medium (2px), large (2.5px), and extra large (3px). The image-stroke--base modifier explicitly sets the default stroke width and is useful for responsive layouts.
Image Stroke is the right tool for photos and multi-color logos that cannot be recolored.
It also composes with image--adaptive, outlining the recolored shape (see
Image
Image
Optimize images using dithering techniques for 1-bit rendering
Place images on a screen and control their size, object fit, and inversion. On 1-bit displays, dithering arranges black and white pixels so an image still reads as shades of gray.
).
<img src="path to image">
<img class="image-stroke image-stroke--small" src="path to image">
<img class="image-stroke image-stroke--base" src="path to image">
<img class="image-stroke" src="path to image">
<img class="image-stroke image-stroke--medium" src="path to image">
<img class="image-stroke image-stroke--large" src="path to image">
<img class="image-stroke image-stroke--xlarge" src="path to image">
Stroke Colors
Use the image-stroke--{shade} modifier to change the stroke color, black for images on dark backgrounds. The shades are the same palette tokens the background scale uses:
image-stroke--blackandimage-stroke--white.image-stroke--gray-10throughimage-stroke--gray-75, in steps of five, plus the legacygray-1togray-7aliases.- Ten hues (red, orange, yellow, lime, green, cyan, blue, violet, purple, pink) as a bare name such as
image-stroke--redand on the same 10 to 75 steps, soimage-stroke--red-40works on a color panel.
For the shade scale and how it adapts across bit depths, see Background Background Apply color tokens as backgrounds with bg--{token} Use the color palette defined in Colors. Apply these shades with bg--{token} for backgrounds. On 1-bit displays, grayscale uses dither patterns; on 2-bit and 4-bit+, solid colors render. .
A shade modifier and a width modifier combine: image-stroke image-stroke--black image-stroke--small is a 1px black ring. Both take the bit-depth prefixes, so 2bit:image-stroke--gray-30 restyles the ring on 2-bit screens only.
A shade class also draws on its own: a lone image-stroke--black is the default 1.5px ring in black.
Text Stroke
Text Stroke
Legible text when displayed on shaded backgrounds
Outline text so it stays legible on a shaded background. Set the stroke width and color with the text stroke utilities.
differs here, where a shade class only colors a stroke that text-stroke or a width modifier applies.
<img src="path to light image">
<img class="image-stroke image-stroke--black image-stroke--small" src="path to light image">
<img class="image-stroke image-stroke--black image-stroke--base" src="path to light image">
<img class="image-stroke image-stroke--black" src="path to light image">
<img class="image-stroke image-stroke--black image-stroke--medium" src="path to light image">
<img class="image-stroke image-stroke--black image-stroke--large" src="path to light image">
<img class="image-stroke image-stroke--black image-stroke--xlarge" src="path to light image">