{% set classes = [
  'badge',
  size ? 'badge-' ~ size,
  color ? 'badge-' ~ color,
  variant and variant != 'default' ? 'badge-' ~ variant,
] %}

{% if url %}
  <a {{ attributes.addClass(classes).setAttribute('href', url) }}>
    {{ text }}
  </a>
{% else %}
  <div {{ attributes.addClass(classes) }}>
    {{ text }}
  </div>
{% endif %}
