Examples
Examples
Basic Usage
The Link Card only needs a few data points to render a fully functional card.
Extended Usage
Optionally, the Link Card can be extended with additional information
Preview Video
A great way to turn the Link Cards into an engaging teaser is to add a video that appears on the hover gesture.
Responsive Image and Performance
A great way to balance client-side performance and responsive images is by using srcset in conjunction with sizes and loading attributes. Read more about responsive image best practices here: Image
Logo
Instead of a tag, Link Cards can display a logo.
Best practices:
- Logos should be SVG or PNG images with a transparent background
- Logos with a width/height ratio lower than 1.5 should have logo-narrow enabled to optimized the appearance on the card
Preview Image
To improve the user experience Link Cards can optionally display preview images while waiting for the high-resolution image to be loaded.
Note: The example below demonstrates the rendering of the preview image only. In a production environment, a high-resolution _image_ would be set alongside.
Best Practices :
- To ensure optimal performance and a seamless transition, use preview images that are scaled versions of the featured image, with a maximum width of 50px.
- To ensure meaningful content is shown as fast as possible without any additional network requests preview images should be provided as base64 encoded data URIs
Mode and Appearance
By default, Link Cards adapt to a light mode environment and appear light themselves. In a dark mode environment, we recommend changing the Link Card appearance to dark.
💡 Pro Tip
The appearance of a Link Card can be set using the appearance property or by nesting it into a cosmos-mode component. Read more about the Mode & Appearance concept.
Compact Layout
Link Cards support a compact layout for use cases where it doesn't have enough space available.
💡 Pro Tip
The Link Card's layout is a Responsive Properties and can be configured per breakpoint. Try out this example
Listen to Resize Events
When initially mounting and whenever the media container of the Story Card resizes, the card emits a mediaresize event including the media's width and height.
A common use case is to update the image to make it perfectly fit the available space.