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

# Examples

## Basic Usage

Every icon symbol is available as an individual icon component that you can render anywhere in your document. By default, the icon inherits the text color from its context and adapts its dimensions to the current font size.

:::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/c232315d66a92bf142e165bf282c4abb?defaultTab=html%2Cresult&#x26;amp;editable=true&#x26;amp;theme-id=39623&#x22; height=&#x22;192px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

## Accessible icons

By default, Icons are treated as decoration images that are ignored by assistive technology. If an icon adds critical information to the context, you can add a descriptive label that will be picked up by assistive technology.

:::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/9913bf810fc02fefeb3c47fd9e02b414?defaultTab=html%2Cresult&#x26;amp;editable=true&#x26;amp;theme-id=39623&#x22; height=&#x22;168px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

## Icon paired with text

Icons resize automatically with the font size of the context in which they're rendered. That allows them to seamlessly work in combination with text of any size

:::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/1d9384d12c81af8f3a5c69f0ebbd9fa8?defaultTab=html%2Cresult&#x26;amp;editable=true&#x26;amp;theme-id=39623&#x22; height=&#x22;349px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

## Resize icons

Icons can be resized to any dimension by setting the `width` and `height` via CSS

:::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/66db88b47dc155ec40e499898d7b0632?defaultTab=html%2Cresult&#x26;amp;editable=true&#x26;amp;theme-id=39623&#x22; height=&#x22;243px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

## Colorize icons

Icons by default adapt to the text color of their context. To change the color of the text you can either set a `color` on the icon itself or to any of its parents.

:::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/2c472bce6dd304455c09d7e9c298185c?defaultTab=html%2Cresult&#x26;amp;editable=true&#x26;amp;theme-id=39623&#x22; height=&#x22;534px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

## Custom icons

Cosmos comes with an icon library that includes almost 300 different symbols. Still, there might be occasions where you'd need to render a custom icon. Cosmos comes with an icon wrapper that you can use to render your custom `svg` shape and still take advantage of the auto-sizing and color-adaption behavior and accessibility features.

Your custom `svg` has to

- be placed on a 22x22 canvas
- paths to have a distance of 1px to the edges minimum
- only use `fill` and not `stroke`
- `fill` to be set to `currentColor`
- `viewBox` set on the `svg` root

:::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/0a6468281a8d293ed709b7f497b614f0?defaultTab=html%2Cresult&#x26;amp;editable=true&#x26;amp;theme-id=39623&#x22; height=&#x22;274px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

