{% include '@bolt-components-chip/chip.twig' with {
content: 'This is a chip component.'
} only %}
Prop Name | Description | Type | Default Value | Option(s) |
---|---|---|---|---|
attributes
|
A Drupal attributes object. Applies extra HTML attributes to chip. |
object
| — |
|
content
*
|
The main chip content. |
any
| — |
|
size
|
Controls the size of the chip. |
string
|
small
|
|
border_radius
|
Controls the border radius of the chip. |
string
|
full
|
|
icon_before
|
Append an icon before the chip content. Icon element is recommended. However, <img> elements are also acceptable. |
any
| — |
|
icon_after
|
Append an icon after the chip content. Icon element is recommended. However, <img> elements are also acceptable. |
any
| — |
|
icon_only
|
Append an icon to the chip content and visually hide the text content. This prop trumps icon_before and icon_after. |
any
| — |
|
npm install @bolt/components-chip
{% include '@bolt-components-chip/chip.twig' with {
content: 'This is a chip.'
} only %}
<div class="c-bolt-chip">
This is a chip.
</div>
{% include '@bolt-components-chip/chip.twig' with {
content: 'Size Medium Chip',
size: 'medium',
} only %}
<div class="c-bolt-chip c-bolt-chip--size-medium">
Size Medium Chip
</div>
{% include '@bolt-components-chip/chip.twig' with {
content: 'Border Radius None Chip',
border_radius: 'none',
} only %}
<div class="c-bolt-chip c-bolt-chip--border-radius-none">
Border Radius None Chip
</div>
<img>
element is also acceptable.
// icon var
{% set icon_info_open %}
{% include '@bolt-elements-icon/icon.twig' with {
name: 'info-circle',
} only %}
{% endset %}
// chip include
{% include '@bolt-components-chip/chip.twig' with {
content: 'Chip Icon',
icon_before: icon_info_open,
icon_after: icon_info_open,
} only %}
<div class="c-bolt-chip">
<span class="c-bolt-chip__icon-before"><!-- Icon or image markup --></span>
This is a chip with icons before and after
<span class="c-bolt-chip__icon-after"><!-- Icon or image markup --></span>
</div>
// icon var
{% set icon_info_open %}
{% include '@bolt-elements-icon/icon.twig' with {
name: 'info-circle',
} only %}
{% endset %}
// chip include
{% include '@bolt-components-chip/chip.twig' with {
content: 'Chip Icon',
icon_only: icon_info_open,
} only %}
<div class="c-bolt-chip c-bolt-chip--icon-only" aria-label="Chip Icon">
<span class="c-bolt-chip__icon-center"><!-- Icon or image markup --></span>
</div>
a
element or the button
element is being used, the proper HTML attributes should be passed.
{% include '@bolt-components-chip/chip.twig' with {
content: 'Linked chip.',
attributes: {
href: 'https://google.com',
target: '_blank',
rel: 'noopener'
}
} only %}
<a href="https://google.com" target="_blank" rel="noopener" class="c-bolt-chip">
Linked chip.
</a>
{% include '@bolt-components-chip/chip.twig' with {
content: 'Navy Chip',
attributes: {
class: 't-bolt-navy',
}
} only %}
<div class="c-bolt-chip t-bolt-navy">
Navy Chip
</div>