Radio Group
lt-radio-group coordinates a set of lt-radio children into a single-select
control. It manages the shared name, tracks the selected value, and fires a
change event when the selection changes. Set orientation to horizontal
for an inline layout.
See the Radio page for the individual radio button API.
Playground
Usage
<lt-radio-group label="Payment method" name="payment" value="card">
<lt-radio value="card" label="Credit card"></lt-radio>
<lt-radio value="paypal" label="PayPal"></lt-radio>
<lt-radio value="bank" label="Bank transfer"></lt-radio>
</lt-radio-group>
<script type="module">
document.querySelector('lt-radio-group').addEventListener('change', (e) => {
console.log('selected:', e.detail.value);
});
</script>
import { RadioGroup, Radio } from '@latty-ds/react';
<RadioGroup label="Payment method" name="payment" value="card"
onChange={(e) => console.log(e.detail.value)}>
<Radio value="card" label="Credit card" />
<Radio value="paypal" label="PayPal" />
<Radio value="bank" label="Bank transfer" />
</RadioGroup>
<template>
<lt-radio-group label="Payment method" name="payment" value="card" @change="onSelect">
<lt-radio value="card" label="Credit card"></lt-radio>
<lt-radio value="paypal" label="PayPal"></lt-radio>
<lt-radio value="bank" label="Bank transfer"></lt-radio>
</lt-radio-group>
</template>
Horizontal layout
Set orientation="horizontal" to arrange the radios in a row.
<lt-radio-group label="Size" orientation="horizontal" value="md">
<lt-radio value="sm" label="Small"></lt-radio>
<lt-radio value="md" label="Medium"></lt-radio>
<lt-radio value="lg" label="Large"></lt-radio>
</lt-radio-group>