<hk-image>
hk-image: An image with alt text, dimensions, aspect ratio, fit, loading mode and radius. Syntax, props, defaults and examples.
On this page
An image with alt text, dimensions, aspect ratio, fit, loading mode and radius.
Group: Text and media. Name in the editor: Image. Complete props for every tag: Tag reference.
Syntax
<hk-image />Children: None. The tag is self-closing.
Props
Write props as kebab-case attributes.
| Prop | Type | Required | Default | Allowed values | Editor label |
|---|---|---|---|---|---|
src | image | no | - | - | Image |
alt | text | no | "" | - | Alt text |
width | number | no | - | 16 to 2400 | Width |
height | number | no | - | 16 to 2400 | Height |
sizes | text | no | 100vw | - | Image sizes |
aspect-ratio | select | no | - | 1/1, 4/5, 3/4, 16/9, 21/9 | Aspect ratio |
fit | select | no | cover | cover, contain | Fit |
loading | select | no | lazy | lazy, eager | Loading |
radius | number | no | - | 0 to 200 | Radius |
Required props
None. Every prop has a default or can be left out.
Examples
From packages/templates-default/theme/snippets/product-card.snf, lines 4 to 9:
<hk-image
src="{{ product.image }}"
alt="{{ product.title }}"
aspect-ratio="{{ image_ratio }}"
sizes="(min-width: 1024px) 25vw, 50vw"
/>From packages/templates-default/theme/sections/hero.snf, lines 25 to 31:
<hk-image
src="{{ section.settings.image }}"
alt="{{ section.settings.image_alt }}"
loading="eager"
aspect-ratio="4/5"
sizes="(min-width: 1024px) 40vw, 100vw"
/>From packages/templates-default/theme/sections/cart-main.snf, lines 10 to 10:
<hk-image src="{{ section.settings.empty_image }}" alt="" width="240" />Related tags
hk-heading: A heading with a level, size, alignment and colour.hk-text: A paragraph of plain text with size, alignment and colour.hk-rich-text: Formatted text from an HTML string, sanitized before it is rendered.hk-badge: A small label such as New or Sale, with a tone.hk-icon: An icon from the built-in set, with size, stroke and an accessible label.hk-announcement: A bar of up to six short messages that fade or scroll, optionally dismissible.
