A group of radio form elements styled like a large selectable buttons.
<div x-data="radioGroup('page')" @keydown.down.stop.prevent="selectNext" @keydown.right.stop.prevent="selectNext" @keydown.up.stop.prevent="selectPrevious" @keydown.left.stop.prevent="selectPrevious" role="radiogroup" :aria-labelledby="$id('radio-group-label')" x-id="['radio-group-label']"><label :id="$id('radio-group-label')" role="none" class="hidden">Choose your favorite artist: <span x-text="value"></span></label>
<div x-ref="options" class="flex flex-col space-y-2 max-w-2xl">
<div x-data="{ option: 'page' }" @click="select(option)" @keydown.enter.stop.prevent="select(option)" @keydown.space.stop.prevent="select(option)" :aria-checked="isSelected(option)" :tabindex="hasRovingTabindex(option, $el) ? 0 : -1" :aria-labelledby="$id('radio-option-label')" :aria-describedby="$id('radio-option-description')" x-id="['radio-option-label', 'radio-option-description']" role="radio" class="flex cursor-pointer border border-black rounded-md shadow p-4" :class="{ 'bg-black text-white': isSelected(option) }"><span :class="isSelected(option) ? 'bg-black ring-white border-white' : 'border-white'" class="inline-flex items-center justify-center shrink-0 mt-1 w-4 h-4 rounded-full border-2 ring-1 ring-black" aria-hidden="true"></span>
<div class="ml-3">
<p :id="$id('radio-option-label')" class="font-semibold text-md">William Page</p><span :id="$id('radio-option-description')" class="mt-2 text-sm" :class="isSelected(option) ? 'text-white' : 'text-tertiary-600'">
Born Albany, NY 1811-died Staten Island, NY 1885
</span>
</div>
</div>
<div x-data="{ option: 'abad' }" @click="select(option)" @keydown.enter.stop.prevent="select(option)" @keydown.space.stop.prevent="select(option)" :aria-checked="isSelected(option)" :tabindex="hasRovingTabindex(option, $el) ? 0 : -1" :aria-labelledby="$id('radio-option-label')" :aria-describedby="$id('radio-option-description')" x-id="['radio-option-label', 'radio-option-description']" role="radio" class="flex cursor-pointer border border-black rounded-md shadow p-4" :class="{ 'bg-black text-white': isSelected(option) }"><span :class="isSelected(option) ? 'bg-black ring-white border-white' : 'border-white'" class="inline-flex items-center justify-center shrink-0 mt-1 w-4 h-4 rounded-full border-2 ring-1 ring-black" aria-hidden="true"></span>
<div class="ml-3">
<p :id="$id('radio-option-label')" class="font-semibold text-md">Edwin Austin Abbey</p><span :id="$id('radio-option-description')" class="mt-2 text-sm" :class="isSelected(option) ? 'text-white' : 'text-tertiary-600'">
Born Philadelphia, PA 1852-died London, England 1911
</span>
</div>
</div>
<div x-data="{ option: 'abraham' }" @click="select(option)" @keydown.enter.stop.prevent="select(option)" @keydown.space.stop.prevent="select(option)" :aria-checked="isSelected(option)" :tabindex="hasRovingTabindex(option, $el) ? 0 : -1" :aria-labelledby="$id('radio-option-label')" :aria-describedby="$id('radio-option-description')" x-id="['radio-option-label', 'radio-option-description']" role="radio" class="flex cursor-pointer border border-black rounded-md shadow p-4" :class="{ 'bg-black text-white': isSelected(option) }"><span :class="isSelected(option) ? 'bg-black ring-white border-white' : 'border-white'" class="inline-flex items-center justify-center shrink-0 mt-1 w-4 h-4 rounded-full border-2 ring-1 ring-black" aria-hidden="true"></span>
<div class="ml-3">
<p :id="$id('radio-option-label')" class="font-semibold text-md">Darryl Abraham</p><span :id="$id('radio-option-description')" class="mt-2 text-sm" :class="isSelected(option) ? 'text-white' : 'text-tertiary-600'">
Born Wayland, NY 1948
</span>
</div>
</div>
</div><input type="hidden" name="merchant_defined_data1" :value="value" />
</div>
{% apply spaceless %}
{# Radio Group #}
<div
x-data="radioGroup('{{ options[0].value }}')"
@keydown.down.stop.prevent="selectNext"
@keydown.right.stop.prevent="selectNext"
@keydown.up.stop.prevent="selectPrevious"
@keydown.left.stop.prevent="selectPrevious"
role="radiogroup"
:aria-labelledby="$id('radio-group-label')"
x-id="['radio-group-label']"
>
{# Radio Group Label #}
{% if label %}
<label :id="$id('radio-group-label')" role="none" class="hidden">{{ label }}: <span x-text="value"></span></label>
{% endif %}
{% if layout is same as('grid') %}
{% set classes = ['grid', 'grid-cols-1', 'gap-y-4', 'sm:grid-cols-3', 'sm:gap-x-4', 'md:grid-cols-6'] %}
{% else %}
{% set classes = ['flex', 'flex-col', 'space-y-2', 'max-w-2xl'] %}
{% endif %}
<div x-ref="options" class="{{ classes|join(' ') }}">
{# Options #}
{% for option in options %}
<div
x-data="{ option: '{{ option.value }}' }"
@click="select(option)"
@keydown.enter.stop.prevent="select(option)"
@keydown.space.stop.prevent="select(option)"
:aria-checked="isSelected(option)"
:tabindex="hasRovingTabindex(option, $el) ? 0 : -1"
:aria-labelledby="$id('radio-option-label')"
{%- if option.description %}
:aria-describedby="$id('radio-option-description')"
{% endif -%}
x-id="['radio-option-label', 'radio-option-description']"
role="radio"
class="flex cursor-pointer border border-black rounded-md shadow p-4"
:class="{ 'bg-black text-white': isSelected(option) }"
>
{# Checked Indicator #}
<span
:class="isSelected(option) ? 'bg-black ring-white border-white' : 'border-white'"
class="inline-flex items-center justify-center shrink-0 mt-1 w-4 h-4 rounded-full border-2 ring-1 ring-black"
aria-hidden="true"
></span>
{# Label and description #}
<div class="ml-3">
<p :id="$id('radio-option-label')" class="font-semibold text-md">{{ option.label }}</p>
{% if option.description %}
<span
:id="$id('radio-option-description')"
class="mt-2 text-sm"
:class="isSelected(option) ? 'text-white' : 'text-tertiary-600'"
>
{{ option.description }}
</span>
{% endif %}
</div>
</div>
{% endfor %}
{% block options %}{% endblock options %}
</div>
{% block footer %}{% endblock footer %}
{% if name %}
<input type="hidden" name="{{ name }}" :value="value" />
{% endif %}
</div>
{% endapply %}