{#
/**
 * @file
 * Template for Radio component.
 */
#}
{% set name = name|default(id) %}
{% set value = value|default(id) %}
{% set checked = checked|default(false) %}
{% set disabled = disabled|default(false) %}
{% set error = error|default(false) %}

{% set wrapper_classes = [
  'kern-form-check',
  error ? 'kern-form-check--error',
] %}

{% set radio_classes = [
  'kern-form-check__radio',
  error ? 'kern-form-check__radio--error',
] %}

<div {{ attributes.addClass(wrapper_classes) }}>
  <input
    class="{{ radio_classes|join(' ') }}"
    id="{{ id }}"
    name="{{ name }}"
    value="{{ value }}"
    type="radio"
    {% if checked %}checked{% endif %}
    {% if disabled %}disabled{% endif %}
  />
  {% if label %}
    <label class="kern-label" for="{{ id }}">
      {{ label }}
    </label>
  {% endif %}
</div>

