{% include '@bolt-elements-type/type.twig' with {
content: 'This is a type element.'
} only %}
Prop Name | Description | Type | Default Value | Option(s) |
---|---|---|---|---|
attributes
|
A Drupal-style attributes object with extra attributes to append to this element. |
object
| — |
|
content
|
Content of the type element. |
any
| — |
|
tag
|
Set the semantic tag for the type element. Use |
string
|
p
|
|
size
|
Control the font-size. If size is not defined or set to auto, font-size inherits from parent container. |
string
|
auto
|
|
hierarchy
|
Control the hierarch of text. Each option comes with specific typographic styles. |
string
|
body
|
|
icon_before
|
Append an icon before the text. Icon element is recommended. However, <img> elements are also acceptable. |
any
| — |
|
icon_after
|
Append an icon after the text. Icon element is recommended. However, <img> elements are also acceptable. |
any
| — |
|
npm install @bolt/elements-type
<p>
HTML element. Only when additional branded typographic styles are needed, the type element should be used.<em>
, <strong>
, <a>
, <small>
, <code>
, and <kbd>
to name a few.This is a type element. Use common inline HTML elements to emphasize, bold, link, and more.
{% include '@bolt-elements-type/type.twig' with {
content: 'This is a type element. Use common inline HTML elements to <em>emphasize</em>, <strong>bold</strong>, <a href="#!">link</a>, and more.'
} only %}
<p>If no props are set, the above is exactly the same as a <p> HTML element.</p>
<p class="e-bolt-type">This is a type element. Use common inline HTML elements to <em>emphasize</em>, <strong>bold</strong>, <a href="#!">link</a>, and more.</p>
<p>If no props are set, the above is exactly the same as a <p> HTML element.</p>
tag
prop only controls semantics, no visual styles are being defined.<span>
for inline text. Inline text can be nested inside another type element.<p>
, <h1>
, <h2>
, <h3>
, <h4>
, <h5>
, <h6>
, or <div>
for block text.<div>
.{% include '@bolt-elements-type/type.twig' with {
content: 'This type element is a level 4 heading. No styles are defined so this looks like plain text.'
tag: 'h4',
} only %}
<h4 class="e-bolt-type">This type element is a level 4 heading. No styles are defined so this looks like plain text.</h4>
This is size auto.
This is size xxsmall.
This is size xsmall.
This is size small.
This is size medium.
This is size large.
This is size xlarge.
This is size xxlarge.
This is size xxxlarge.
{% include '@bolt-elements-type/type.twig' with {
content: 'This is size xxxlarge.'
size: 'xxxlarge',
} only %}
<p class="e-bolt-type e-bolt-type--xxxlarge">This is size xxxlarge.</p>
tag
controls semantics while hierarchy
controls visual styles.<strong>
in tandem with subheadline hierarchy will create the same styles as headline hierarchy. This flexibility allows content authors to create mixed-weight headlines.aria-label
with the proper case to improve accessibility.size
and hierarchy
for a particular pair of headline and subheadline (or body text), make sure to set the headline at least one size larger than subheadline to create the visual hierarchy.Eyebrow
Body text (basic type element).
This is size auto headline
This is size xxsmall headline
This is size xsmall headline
This is size small headline
This is size medium headline
This is size large headline
This is size xlarge headline
This is size xxlarge headline
This is size xxxlarge headline
This is size auto subheadline
This is size xxsmall subheadline
This is size xsmall subheadline
This is size small subheadline
This is size medium subheadline
This is size large subheadline
This is size xlarge subheadline
This is size xxlarge subheadline
This is size xxxlarge subheadline
This is an eyebrow
This is size auto body text
This is size xxsmall body text
This is size xsmall body text
This is size small body text
This is size medium body text
This is size large body text
This is size xlarge body text
This is size xxlarge body text
This is size xxxlarge body text
{# Teaser Text Group #}
{% include '@bolt-elements-type/type.twig' with {
content: 'Eyebrow',
hierarchy: 'eyebrow',
attributes: {
'aria-label': 'Eyebrow',
},
} only %}
{% include '@bolt-elements-type/type.twig' with {
content: 'Headline (size xxxlarge and h1)',
hierarchy: 'headline',
tag: 'h1',
size: 'xxxlarge',
} only %}
{% include '@bolt-elements-type/type.twig' with {
content: 'Subheadline (size xlarge and h2)',
hierarchy: 'subheadline',
tag: 'h2',
size: 'xlarge',
} only %}
{% include '@bolt-elements-type/type.twig' with {
content: 'Paragraph (basic type element).',
} only %}
{# Mixed-weight Headlines #}
{% include '@bolt-elements-type/type.twig' with {
content: 'This entire sentence is a subheadline <strong>but part of it is bold</strong>',
hierarchy: 'subheadline',
tag: 'h1',
size: 'xxxlarge',
} only %}
<!-- Teaser Text Group -->
<p class="e-bolt-type e-bolt-type--eyebrow" aria-label="Eyebrow">
Eyebrow
</p>
<h1 class="e-bolt-type e-bolt-type--headline e-bolt-type--xxxlarge">
Headline (size xxxlarge and h1)
</h1>
<h2 class="e-bolt-type e-bolt-type--subheadline e-bolt-type--xlarge">
Subheadline (size xlarge and h2)
</h2>
<p class="e-bolt-type">
Paragraph (basic type element).
</p>
<!-- Mixed-weight Headlines -->
<h1 class="e-bolt-type e-bolt-type--subheadline e-bolt-type--xxxlarge">
This entire sentence is a subheadline <strong>but part of it is bold</strong>
</h1>
<img>
element is also acceptable.
icon_before
or icon_after
are rendered to flow with text, so its size will grow or shrink with text size. The size
prop for the Icon element is not supported in this scenario.tag
to span
.<span class="e-bolt-type__icon-before">
and <span class="e-bolt-type__icon-after">
are required to wrap around the icon markup. The wrapper ensures that the icon will always wrap with the final word of the text. It will never wrap to the next line on its own.Eyebrow with an icon before
This is a paragraph of text. In the middle of it, it has inline text with icons. This inline text is a type element with its tag set to span
.
{% set icon_pega_thumbs_up %}
{% include '@bolt-elements-icon/icon.twig' with {
name: 'pega-thumbs-up',
size: 'large',
} only %}
{% endset %}
{% set icon_pega_timer %}
{% include '@bolt-elements-icon/icon.twig' with {
name: 'pega-timer',
} only %}
{% endset %}
{% set icon_arrow_left %}
{% include '@bolt-elements-icon/icon.twig' with {
name: 'arrow-left',
} only %}
{% endset %}
{# Block Text #}
{% include '@bolt-elements-type/type.twig' with {
content: 'Eyebrow with an icon before',
icon_before: icon_arrow_left,
hierarchy: 'eyebrow',
} only %}
{% include '@bolt-elements-type/type.twig' with {
content: 'Headline with an icon after',
icon_after: icon_pega_thumbs_up,
hierarchy: 'headline',
tag: 'h1',
size: 'xxxlarge',
} only %}
{% include '@bolt-elements-type/type.twig' with {
content: 'Subheadline with an icon before and after',
icon_before: icon_pega_timer,
icon_after: icon_pega_thumbs_up,
hierarchy: 'subheadline',
tag: 'h2',
size: 'xlarge',
} only %}
{# Inline Text #}
{% set inline_text %}
{% include '@bolt-elements-type/type.twig' with {
content: 'inline text with icons',
icon_before: icon_pega_timer,
icon_after: icon_pega_thumbs_up,
tag: 'span',
} only %}
{% endset %}
{% include '@bolt-elements-type/type.twig' with {
content: 'This is a paragraph of text. In the middle of it, it has ' ~ inline_text|spaceless ~ '. This inline text is a type element with its tag set to <code>span</code>.',
} only %}
<!-- Block Text -->
<h1 class="e-bolt-type e-bolt-type--headline e-bolt-type--xxxlarge"><span class="e-bolt-type__icon-before"><!-- Icon or image markup --></span>Subheadline with an icon before and after<span class="e-bolt-type__icon-after"><!-- Icon or image markup --></span></h1>
<!-- Inline Text -->
<p class="e-bolt-type">This is a paragraph of text. In the middle of it, it has <span class="e-bolt-type"><span class="e-bolt-type__icon-before"><!-- Icon or image markup --></span>inline text with icons<span class="e-bolt-type__icon-after"><!-- Icon or image markup --></span></span>. This inline text is a type element with its tag set to <code>span</code>.</p>
link_attributes
. Same as Text Link element, depending on if the <a>
or the <button>
HTML element is being used, the proper HTML attributes should be passed.link_attributes
will turn the entire paragraph of text into a link, so it is not recommended for body text links. Instead, use the Text Link element or <a>
HTML element for inline links within a paragraph of text.This is a paragraph of text. In the middle of it, it has an inline link. This inline link can be a Text Link element or an HTML anchor element.
{% set icon_chevron_right %}
{% include '@bolt-elements-icon/icon.twig' with {
name: 'chevron-right',
} only %}
{% endset %}
{# Block Link #}
{% include '@bolt-elements-type/type.twig' with {
content: 'Eyebrow link',
hierarchy: 'eyebrow',
icon_after: icon_chevron_right,
link_attributes: {
href: '#!',
},
} only %}
{% include '@bolt-elements-type/type.twig' with {
content: 'Headline link',
hierarchy: 'headline',
tag: 'h1',
size: 'xxxlarge',
icon_after: icon_chevron_right,
link_attributes: {
href: '#!',
},
} only %}
{% include '@bolt-elements-type/type.twig' with {
content: 'Subheadline link',
hierarchy: 'subheadline',
tag: 'h2',
size: 'xlarge',
icon_after: icon_chevron_right,
link_attributes: {
href: '#!',
},
} only %}
{# Inline Link #}
{% include '@bolt-elements-type/type.twig' with {
content: 'This is a paragraph of text. In the middle of it, it has <a href="#!">an inline link</a>. This inline link can be a Text Link element or an HTML anchor element.',
} only %}
<!-- Block Link -->
<h1 class="e-bolt-type e-bolt-type--size-xxxlarge e-bolt-type--headline"><a href="#!" class="e-bolt-text-link e-bolt-text-link--reversed-underline">Headline link<span class="e-bolt-text-link__icon-after"><!-- Icon or image markup --></span></a></h1>
<!-- Inline Link -->
<p class="e-bolt-type">This is a paragraph of text. In the middle of it, it has <a href="#!">an inline link</a>. This inline link can be a Text Link element or an HTML anchor element.</p>
tag
set to div
, spacing
set to small
, and nowrap
set to true
.size
to create the desired design.{% set number %}
{% include '@bolt-elements-shape/shape.twig' with {
content: '<strong>1</strong>',
size: 'small',
attributes: {
class: 't-bolt-teal',
},
} only %}
{% endset %}
{% set headline %}
{% include '@bolt-elements-type/type.twig' with {
content: 'Numbered headline xxlarge',
hierarchy: 'headline',
tag: 'h4',
size: 'xxlarge',
} only %}
{% endset %}
{% include '@bolt-components-list/list.twig' with {
display: 'inline',
nowrap: true,
spacing: 'small',
items: [
number,
headline,
],
} only %}
<bolt-list display="inline" tag="div" spacing="small" nowrap>
<bolt-list-item>
<span class="e-bolt-shape"><span class="e-bolt-shape__content"><strong>1</strong></span></span>
</bolt-list-item>
<bolt-list-item>
<h1 class="e-bolt-type e-bolt-type--headline e-bolt-type--xxxlarge">Numbered headline</h1>
</bolt-list-item>
</bolt-list>