---
title: Examples
slug: wip/Izzw-examples
createdAt: 2023-07-20T14:45:03.180Z
---

# Examples

## Basic Usage

:::Iframe{iframeHeight="0" code="<iframe title=&#x22;Embeded content from codepen.io&#x22; class=&#x22;no-border max-full-width full-height flex-grow&#x22; src=&#x22;https://codepen.io/redbulldesign/embed/vYZYboj/894819b5f9ca5db81cd15948aa4e30ad?default-tab=html%2Cresult&#x26;amp;editable=true&#x26;amp;theme-id=39623&#x22; height=&#x22;538px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

The Story Card only needs a few data points to render a fully functional card.

**Best Practices:**

- The headline and text should use [sentence-case](https://en.wikipedia.org/wiki/Letter_case#Sentence_case)
- Headlines shouldn't hold more than 75 characters, and a maximum of 40 when displaying Asian characters
- Images should always be paired with an alternative text to support assistive technologies

## Extended Usage

Optionally, the Story Card can be extended with additional information

:::Iframe{iframeHeight="0" code="<iframe title=&#x22;Embeded content from codepen.io&#x22; class=&#x22;no-border max-full-width full-height flex-grow&#x22; src=&#x22;https://codepen.io/redbulldesign/embed/e72ea40f635ab3aafec0812aec179d14?default-tab=html%2Cresult&#x26;amp;editable=true&#x26;amp;theme-id=39623&#x22; height=&#x22;538px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

**Best Practices:**

- The tag should use [title-case](https://en.wikipedia.org/wiki/Letter_case#Title_case)
- The tag is used to categorize cards, for example by discipline
- The badge is only used for promoting selected cards
- The estimated reading time is rounded to full minutes using a minimum of one minute

## Preview Video

A great way to turn the Story Card into an engaging teaser is to add a video that appears on hover gesture

:::Iframe{iframeHeight="0" code="<iframe title=&#x22;Embeded content from codepen.io&#x22; class=&#x22;no-border max-full-width full-height flex-grow&#x22; src=&#x22;https://codepen.io/redbulldesign/embed/efd4ae3f7a7b196cf76d800967b06f65?default-tab=html%2Cresult&#x26;amp;editable=true&#x26;amp;theme-id=39623&#x22; height=&#x22;530px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

In some cases it might be preferred to not rely on the hover gesture and play the video depending on other triggers. This can be done by setting the `play-video` attribute on the card.

:::Iframe{iframeHeight="0" code="<iframe title=&#x22;Embeded content from codepen.io&#x22; class=&#x22;no-border max-full-width full-height flex-grow&#x22; src=&#x22;https://codepen.io/redbulldesign/embed/88e02f25655a1ba191ff1d7f67c211cc?default-tab=html%2Cresult&#x26;amp;theme-id=39623&#x26;amp;editable=true&#x22; height=&#x22;564px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

## Preview Image

To improve the user experience Story Cards can display preview images while waiting for the high-resolution image to be loaded.

:::hint{type="info"}
*Note: The example below demonstrates the rendering of the preview image only. In a production environment, a high-resolution* `_image_` *would be set alongside.*
:::

:::Iframe{iframeHeight="0" code="<iframe title=&#x22;Embeded content from codepen.io&#x22; class=&#x22;no-border max-full-width full-height flex-grow&#x22; src=&#x22;https://codepen.io/redbulldesign/embed/5f03ca28dc8de377161c7b79fe93b694?defaultTab=html%2Cresult&#x26;amp;editable=true&#x26;amp;theme-id=39623&#x22; height=&#x22;534px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

**Best practices:**

- Preview images should be a scaled version of the featured image with a maximum of 50px width
- To ensure meaningful content to be shown as fast as possible without any additional network requests preview images should be provided as base64 encoded data URIs

## 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](https://cosmos.redbull.design/wip/image)

:::Iframe{iframeHeight="0" code="<iframe title=&#x22;Embeded content from codepen.io&#x22; class=&#x22;no-border max-full-width full-height flex-grow&#x22; src=&#x22;https://codepen.io/redbulldesign/embed/XWyqGbY/205be893237ebf9497667ed5d1e60ba4?default-tab=html%2Cresult&#x26;amp;editable=true&#x26;amp;theme-id=39623&#x22; height=&#x22;538px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

## Logo

Instead of a tag, Story Cards can display a logo.

:::Iframe{iframeHeight="0" code="<iframe title=&#x22;Embeded content from codepen.io&#x22; class=&#x22;no-border max-full-width full-height flex-grow&#x22; src=&#x22;https://codepen.io/redbulldesign/embed/ea45dc4930354b2e0be73ffffef64f53?default-tab=html%2Cresult&#x26;amp;editable=true&#x26;amp;theme-id=39623&#x22; height=&#x22;545px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

**Best practices:**

- The logo is only to be used for brands or projects, not for sponsors
- 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

## Make it favoritable

Story Cards can be favorited by users – while the favorite button will be persistently displayed on touch-based devices, the button will only show up on hover on devices with pointer-based inputs.

:::Iframe{iframeHeight="0" code="<iframe title=&#x22;Embeded content from codepen.io&#x22; class=&#x22;no-border max-full-width full-height flex-grow&#x22; src=&#x22;https://codepen.io/redbulldesign/embed/9617428fc43512cee5637602dc53eb9a?defaultTab=html%2Cresult&#x26;amp;editable=true&#x26;amp;theme-id=39623&#x22; height=&#x22;537px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

**Best practices:**

- The state of whether the Story has been favorited or not has to be managed outside the component
- The `favorite-aria-label` should reflect the action that will be performed based on the current "favorite" state
- Clicking on the favorite button won't propagate the `click` event to the card component and won't go in the way of catching link redirection.

## Mode and Appearance

By default, Story Cards adapt to a light mode environment and appear to light themselves. In a dark mode environment, we recommend changing the Story Card appearance to dark.

:::hint{type="info"}
**💡 Pro Tip**

The appearance of a Story Card can be set using the appearance property or by nesting it into a cosmos-mode component. Read more about the [Mode & Appearance](https://cosmos.redbull.design/wip/mode-and-appearance) concept.
:::

:::Iframe{iframeHeight="0" code="<iframe title=&#x22;Embeded content from codepen.io&#x22; class=&#x22;no-border max-full-width full-height flex-grow&#x22; src=&#x22;https://codepen.io/redbulldesign/embed/904a82d9cec711c1a30b4f3218c8304b?default-tab=html%2Cresult&#x26;amp;editable=true&#x26;amp;theme-id=39623&#x22; height=&#x22;519px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

**Best practices:**

- The appearance of the card should follow the mode of the environment: The card appears light in a light environment and dark when used inside a dark environment.
- The Story Card can use a light appearance in a dark environment for high-contrast designs, but should not use a dark appearance in a light environment

## Compact Layout

Story Cards support a compact layout for use cases where it doesn't have enough space available.

:::hint{type="info"}
💡 **Pro Tip**

The Story Card's layout is a [Responsive Properties](https://cosmos.redbull.design/wip/responsive-properties) and can be configured per breakpoint. Try out [this example](https://codepen.io/redbulldesign/live/5f54a3975de145ea1c8f89a51439d100)
:::

:::Iframe{iframeHeight="0" code="<iframe title=&#x22;Embeded content from codepen.io&#x22; class=&#x22;no-border max-full-width full-height flex-grow&#x22; src=&#x22;https://codepen.io/redbulldesign/embed/44b10da838a00658c5959d049d4dc523?default-tab=html%2Cresult&#x26;amp;editable=true&#x26;amp;theme-id=39623&#x22; height=&#x22;445px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

**Best Practices:**

- The Story Card should use a compact layout whenever the available width is smaller than 290px

## 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.

:::Iframe{iframeHeight="0" code="<iframe title=&#x22;Embeded content from codepen.io&#x22; class=&#x22;no-border max-full-width full-height flex-grow&#x22; src=&#x22;https://codepen.io/redbulldesign/embed/ba1ceed7e8a8c25ac059923c44164636?defaultTab=html%2Cresult&#x26;amp;editable=true&#x26;amp;theme-id=39623&#x22; height=&#x22;515px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

**Best Practices:**

- Only enable the `observe-media-resize` when needed

