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

# Examples

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

Displaying Texts requires the related font face definitions to be loaded.

Find out how to embed [Font Faces](https://cosmos.redbull.design/wip/font-faces)
:::

## Basic usage

Texts can render at different sizes, weights, and contrasts to create structure.

:::hint{type="info"}
**💡 Did you know?**

The visual appearance of a Text is decoupled from its semantic meaning. That means that a Text of small size can still be promoted to the upper range of the semantical hierarchy of a document by setting the tag that is used to mount it to the DOM.
:::

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

:::

## Truncation

Text can be limited to any number of lines.

:::hint{type="info"}
**💡 Did you know?**

When Text is used inside a flex layout, the flex child holding the Text requires the width to be set to a specific value or `100%` and the overflow to be `hidden` in order for the single-line clamp to work correctly.
:::

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

:::

## Rich formatting

Texts do support rich formattings such as strong, emphasis, or hyperlinks.

:::hint{type="info"}
**💡 Did you know**

Even though most user agents display texts that are rendered inside a `<b>` or `<strong>` tags equally to sighted users, screen readers will make a difference and will only accentuate content within `<strong>` tags.
:::

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

:::

### Rich formatting in Nested Content

The Text component's rich formatting is limited to top-level elements. To apply similar styling to nested elements, specific global CSS rules are necessary.

The following example illustrates the use of global CSS and foundational primitives to extend rich formatting to nested slotted elements within the Text component, ensuring consistent visual presentation.

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

:::

## Alignment

The CSS `text-align` is one of the few styles that are inherited by text nodes inside web components. Setting an alignment on a Text component or any of its parents will allow controlling the horizontal alignment of its content.

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

:::

## Spacing and Vertical Rhythm

While Text elements inside user interfaces are layouted using specific spacings to control their proximity, the spacing between pairings of Texts and Titles in long-form reads are automatically determined based on their size to follow a vertical rhythm and preserve legibility and structure.

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

:::

## Appearance

By default, the Text adapts to a light mode environment by appearing dark. When in a dark mode environment, the Text should appear light instead.

The appearance of a Text 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/a240bf27ba2153db3145cbcca5eec0fe?defaultTab=html%2Cresult&#x26;amp;editable=true&#x26;amp;theme-id=39623&#x22; height=&#x22;532px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

## Responsive Size

While Texts are automatically adapting their font size using the fluid typography concept, sometimes the same Text element should render at a very different size at different breakpoints.

The Text's size property does support [Responsive Properties](https://cosmos.redbull.design/wip/responsive-properties) syntax.

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

Open [this page](https://codepen.io/redbulldesign/live/ZEKwOVB/6c7ca5c57688e74e9424941df2b656ea?default-tab=html%2Cresult\&theme-id=39623) in a new browser window and resize it to simulate different breakpoints.
:::

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

:::

## Localization

The Text component is aware of the language of the text displayed and picks the most optimal font family for rendering it.

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

Displaying Texts requires the related font face definitions to be loaded.

Find out how to embed [Font Faces](https://cosmos.redbull.design/wip/font-faces)
:::

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

:::

