Image
Image displays a photograph at its natural proportions or inside a chosen frame. It follows the available width, with the system’s small rounded corners.
A 16:9 frame crops the photograph while keeping its centre in view.
<ds-image src="/examples/images/forest.webp" alt="A path beneath tall trees in a sunlit forest" ratio="16 / 9" caption="A quiet path through the forest." style="max-width: 640px" loading="eager"></ds-image> Cover fills the square. Contain preserves the complete photograph.
<div style="display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;max-width:640px"><ds-image src="/examples/images/lake.jpg" alt="A mountain reflected in a lake" ratio="1" fit="cover" caption="Cover" loading="eager"></ds-image><ds-image src="/examples/images/lake.jpg" alt="The full portrait photograph of a mountain and its reflection" ratio="1" fit="contain" caption="Contain" loading="eager"></ds-image></div> <ds-image src="/photos/forest.webp" alt="A sunlit path through tall trees" width="1200" height="800" ratio="16 / 9" caption="Along the forest path."></ds-image>srcandaltsupply the image and its text alternative. Usealt=""only for decorative images.widthandheightdescribe the source dimensions and reserve space before it loads.- Omit
ratioto keep natural proportions. Set it to1,4 / 3or16 / 9for a frame. fit="cover"fills that frame;fit="contain"shows the whole image.positionchooses the focal point, such as50% 25%.srcsetandsizeslet the browser select a responsive source.- Images load lazily by default. Use
loading="eager"for a prominent image at the top of the page. captionadds visible text underneath. It does not replacealt.
Copy image through Sync 1. React consumers can import Image from DS1/react/image after registering DS1/2-core/ds-image.
Example photographs
Section titled “Example photographs”Forest by Johannes Plenio on Unsplash, used under the Unsplash License. Mountain reflection by lil artsy on Pexels, used under the Pexels License. Example photos are stored with the documentation, outside the npm package.