vartheme_bs5-2.0.x-dev/src/components/atoms/badge/badge.twig
src/components/atoms/badge/badge.twig
{#
/**
* @file
* Template for a Badge component.
*
* Available config:
* - color: text-bg-primary | text-bg-secondary | text-bg-success | text-bg-info | text-bg-warning | text-bg-danger | text-bg-light | text-bg-dark
* - tag: The HTML tag to use for the bade. Defaults to span.
* - content: The content of the badge.
* - url: if anchor add a url, tag will be set to a automatically.
* - utility_classes: An array of utility classes.
*/
#}
{% set color = color ?? 'text-bg-secondary' %}
{% set classes = [
'badge',
color,
]|merge(utility_classes ? utility_classes : []) %}
{% set tag = tag ?? 'span' %}
{% if url %}
{% set tag = 'a' %}
{% set url = url|render %}
{% endif %}
{% if content %}
<{{tag}} {{ url ? 'href=' ~ url }} class="{{ classes|join(' ') }}">
{% block content %}
{{ content }}
{% endblock %}
</{{tag}}>
{% endif %}
