RadioGroup
Moleculefieldset + legend based radio group. WCAG-compliant keyboard navigation with an optional card-style variant.
<%- include('modules/ui/RadioGroup', {
name: 'notify',
legend: 'Notification preference',
options: [
{ value: 'email', label: 'Email', hint: 'Sent to your primary email' },
{ value: 'sms', label: 'SMS' },
{ value: 'none', label: 'None' },
]
}) %>
<%- include('modules/ui/RadioGroup', {
name: 'notify',
legend: 'Notification preference',
value: 'email',
options: NOTIFY_OPTS
}) %>
<%- include('modules/ui/RadioGroup', {
name: 'plan',
legend: 'Choose plan',
value: 'pro',
cardStyle: true,
options: [
{ value: 'free', label: 'Free', hint: '$0/mo · 3 projects' },
{ value: 'pro', label: 'Pro', hint: '$12/mo · Unlimited' },
{ value: 'team', label: 'Team', hint: '$49/mo · 10 seats' },
]
}) %>
<%- include('modules/ui/RadioGroup', { name: 'notify', legend: 'Notification preference', value: 'email', disabled: true, options: NOTIFY_OPTS }) %>
<%
var _name = locals.name || 'radio-' + Math.random().toString(36).substr(2, 9);
var _opts = locals.options || [];
var _val = (locals.value !== undefined && locals.value !== null) ? String(locals.value) : '';
var _dis = !!locals.disabled;
var _variant = locals.variant || (locals.cardStyle ? 'card' : 'default');
var _cols = locals.columns || 1;
var _gridClass = '';
if (_cols === 1) {
_gridClass = 'space-y-2';
} else if (_cols === 2) {
_gridClass = 'grid gap-2 grid-cols-1 sm:grid-cols-2';
} else if (_cols === 3) {
_gridClass = 'grid gap-2 grid-cols-1 sm:grid-cols-2 lg:grid-cols-3';
} else {
_gridClass = 'space-y-2';
}
%>