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

# Examples

:::hint{type="warning"}
**☝️ Watch out**

To support custom fonts used by the Button component, ensure to provide the corresponding [font-face declarations](https://cosmos.redbull.design/wip/font-faces) in your application.
:::

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

:::

### Button with Icon

To render an Icon within a Button, you can use any of the Cosmos Icons and add them as a child of the Button.

To render the Icon correctly, you should assign it the correct "icon" slot.

Use the `icon-placement` property to place the icon before or after the label.

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

:::

When using Icon Buttons, it is recommended to change the button shape accordingly.

:::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/eYrKQBL/271cc492caad2e729e8e87d6a2eef195?default-tab=html%2Cresult&#x26;amp;editable=true&#x26;amp;theme-id=39623&#x22; height=&#x22;177px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

## Extended Usage

### Change the appearance

By default, the Button anticipates a light mode environment by appearing dark. In a dark mode environment, the Button should appear light instead.

The appearance of a Button can be set using the `appearance` property or by nesting it in 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/ZEoRmLj/011a1ca2054b3bc7d578bafd36d9f49d?defaultTab=html%2Cresult&#x26;amp;editable=true&#x26;amp;theme-id=39623&#x22; height=&#x22;290px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

### Decorative Button

In some cases, the Button might be rendered inside another interactive element, such as an `<a>`.

In our example, the entire card is a link. Inside we have a Button that should also be displayed in the hover state when the element is hovered.

Setting the decorative support on the Button makes it a non-interactive and non-semantic `<div>`.

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

:::

### Width

By default, a Button will adapt its width to its content. It is possible to change this behavior and make the width adapt to the parent container's size by setting the `width` property to the `full` value.

The `width` property is a [Responsive Properties](https://cosmos.redbull.design/wip/responsive-properties) and can be configured per breakpoint.

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

:::

