Thumbnail ​
A Thumbnail is a visual element used to display a small preview of an image. Thumbnails provide users with a quick glimpse of the associated content.
| Name | Value |
|---|---|
| View | |
Reading direction | |
Overview ​
When to use Thumbnail ​
Use the Thumbnail component to display small previews of images that can provide context or support the meaning of the content included in components such as Card or MenuItem.
Avoid using the Thumbnail component for high-resolution images. Use the Image component instead.
About Thumbnail ​
Thumbnail includes the following elements.
Image ​
The Thumbnail displays a preview of an image if one has been uploaded.
Placeholder icon ​
If the Thumbnail's image is missing or loading, a placeholder icon on a light background is displayed.
- Customize the icon within placeholder Thumbnails.
- Use icons that provide clear context for the use of the Thumbnail.
Size ​
Thumbnails have a minimum width and height of size-250 (equivalent to 40px in the default Codex theme). A larger Thumbnail size can be specified using CSS if desired (the Card component uses size-300 for its Thumbnail dimensions, for example).
Examples ​
Placeholder ​
The placeholder serves two purposes:
- To display while a Thumbnail image is loading, improving the experience of those with slower connections.
- To display when a Thumbnail image is not provided.
The second case may occur in a group of components, like Cards or MenuItems, when some items have a thumbnail image but some do not. In this case, the placeholder icon helps maintain a consistent layout for all items. Refer to the Card groups demo for an example.
Default placeholder ​
Custom placeholder icon ​
Developer notes
To customize the placeholder icon, use the placeholderIcon prop.
Technical implementation ​
Vue usage ​
Props ​
| Prop name | Description | Type | Default |
|---|---|---|---|
thumbnail | Thumbnail data. | Thumbnail|null | null |
placeholderIcon | Thumbnail placeholder icon. | Icon | cdxIconImageLayoutFrameless |
CSS-only version ​
Markup structure ​
For the CSS-only version, a background-image rule must be set on the inner span. You can do this via a style attribute (like in the example below), or by adding a custom CSS class to the inner span and adding the background-image rule in your styles.
Placeholder ​
Default placeholder ​
To show the default placeholder icon, add two nested <span> elements inside the wrapper <span>:
- An outer
<span>with the classcdx-thumbnail__placeholder - An inner
<span>with the classcdx-thumbnail__placeholder__icon
The default placeholder icon will automatically be added as a background image to the inner <span>.
Custom placeholder icon ​
To show a custom placeholder icon, add two nested <span> elements inside the wrapper <span>:
- An outer
<span>with the classcdx-thumbnail__placeholder - An inner
<span>with your own custom CSS class
In your Less code, use your custom CSS class to add a CSS-only icon. Be sure to use @color-placeholder as the fill color.