Thumbnail
Display a small preview image representing content, products, or media.
Anchor to propertiesProperties
- string
An alternative text description that describe the image for the reader to understand what it is about. It is extremely useful for both users using assistive technology and sighted users. A well written description provides people with visual impairments the ability to participate in consuming non-text content. When a screen readers encounters an
s-image
, the description is read and announced aloud. If an image fails to load, potentially due to a poor connection, thealt
is displayed on screen instead. This has the benefit of letting a sighted buyer know an image was meant to load here, but as an alternative, they’re still able to consume the text content. Read considerations when writing alternative text to learn more.- Anchor to sizesize"small" | "small-200" | "small-100" | "base" | "large" | "large-100"
Adjusts the size the product thumbnail image.
- string
The image source (either a remote URL or a local file resource).
When the image is loading or no
src
is provided, a placeholder will be rendered.
Thumbnail
- adoptedCallback
() => void
- alt
An alternative text description that describe the image for the reader to understand what it is about. It is extremely useful for both users using assistive technology and sighted users. A well written description provides people with visual impairments the ability to participate in consuming non-text content. When a screen readers encounters an `s-image`, the description is read and announced aloud. If an image fails to load, potentially due to a poor connection, the `alt` is displayed on screen instead. This has the benefit of letting a sighted buyer know an image was meant to load here, but as an alternative, they’re still able to consume the text content. Read [considerations when writing alternative text](https://www.shopify.com/ca/blog/image-alt-text#4) to learn more.
string
- attributeChangedCallback
(name: string) => void
- click
Like the standard `element.click()`, but you can influence the behavior with a `sourceEvent`. For example, if the `sourceEvent` was a middle click, or has particular keys held down, components will attempt to produce the desired behavior on links, such as opening the page in the background tab.
({ sourceEvent }?: ClickOptions) => void
- connectedCallback
() => void
- disconnectedCallback
() => void
- queueRender
Queue a run of the render function. You shouldn't need to call this manually - it should be handled by changes to @property values.
() => void
- setAttribute
(name: string, value: string) => void
- size
Adjusts the size the product thumbnail image.
"small" | "small-200" | "small-100" | "base" | "large" | "large-100"
- src
The image source (either a remote URL or a local file resource). When the image is loading or no `src` is provided, a placeholder will be rendered.
string
declare class Thumbnail extends PreactCustomElement implements ThumbnailProps {
accessor src: ThumbnailProps['src'];
accessor alt: ThumbnailProps['alt'];
accessor size: ThumbnailProps['size'];
constructor();
}
ClickOptions
- sourceEvent
The event you want to influence the synthetic click.
ActivationEventEsque
export interface ClickOptions {
/**
* The event you want to influence the synthetic click.
*/
sourceEvent?: ActivationEventEsque;
}
ActivationEventEsque
- button
number
- ctrlKey
boolean
- metaKey
boolean
- shiftKey
boolean
export interface ActivationEventEsque {
shiftKey: boolean;
metaKey: boolean;
ctrlKey: boolean;
button: number;
}
Anchor to eventsEvents
Learn more about registering events.
- Anchor to errorerrorOnErrorEventHandler
- Anchor to loadloadCallbackEventListener<typeof tagName> | null
ThumbnailEvents
- error
OnErrorEventHandler
- load
CallbackEventListener<typeof tagName> | null
export interface ThumbnailEvents {
load: CallbackEventListener<typeof tagName> | null = null;
error: OnErrorEventHandler = null;
}
CallbackEventListener
(EventListener & {
(event: CallbackEvent<T>): void;
}) | null
CallbackEvent
Event & {
currentTarget: HTMLElementTagNameMap[T];
}
Code
examples
Code
<s-thumbnail alt="White sneakers" src="/assets/products/sneakers.jpg"> </s-thumbnail>
<!DOCTYPE html><html><head><style>html, body {height:100%} body {box-sizing: border-box; margin: 0; padding:0.5rem; display: flex; justify-content: center; align-items: center; gap: 0.5rem;}</style><script src="https://cdn.shopify.com/shopifycloud/app-bridge-ui-experimental.js"></script></head><body><s-thumbnail alt="White sneakers" src="/assets/products/sneakers.jpg"> </s-thumbnail> </body></html>