Radio
Single selection from several visible options.
When to use
Radio selects one option from a small set: tariff, publication mode or delivery method. All options are visible at the same time, so it is convenient to compare them. For a long list with search use Select, for independent marks - Checkbox.
Name the options so that the choice is clear without additional action. Clicking the selected Radio again does not uncheck it. If the response “not selected” is acceptable, provide it in the options or a separate reset command.
Radio CSS Prefixes show global ConfigProvider.prefixCls and local prefixCls without resetting state. RadioButton gets the base prefix without -button. Group passes it options; arbitrary children choose their prefixCls independently, so here it is also set for the buttons.
How to select a group
It is easier to describe a regular group using options. Child Radios or RadioButtons come in handy when an option needs its own markup.
| Problem | Setting | Example |
|---|---|---|
| Select one value | RadioGroup, bind:value, options |
Group Radio |
| Show additional field for option | Subsidiary Radio and snippet | Vertical groups |
| Design options with buttons | optionType="button" or RadioButton |
Button design |
| Occupy available width | block |
Full width band |
Non-empty options takes precedence over children. The explicit optionType of the group determines the appearance of the child RadioButtons. buttonStyle selects the outline or fill, and size changes the size of the button design. A regular round Radio does not increase with the size of the group.
Meaning, events and form of
For RadioGroup, bind:value binds the selected value. string, number and boolean are supported: 0, '0' and false - different options. Don't check for choice through truthiness. Typed Example shows the original type, and form stores the numeric rate and publication boolean.
defaultValue sets the initial selection of the group, defaultChecked — a single Radio. For subsequent changes, use managed props or binding. Outside the group, bind:checked links the mark of one Radio; within a group, the state is determined by the common value.
Group onChange receives event with target.value and nativeEvent. Then onValueChange gets the selected value itself. For the normal state, bind:value; callbacks are needed, for example, to process selection by the application.
In Form, pass value from the model and update it via onValueChange. FormItem binds the signature and errors, but does not substitute the value into the child snippet. Native FormData sends the string value of the selected available input with name; the typed Form model retains the original type. These submission methods are shown separately.
Keyboard and design
The common name combines native input into a group. If not passed, RadioGroup will create its own name. Specify name explicitly if you are reading data via FormData. Example of a native form also shows reset and software focus.
Tab moves focus in and out of the group; arrows change the selection, skipping unavailable options. Space selects the option in focus. Give the group an accessible name using aria-label or aria-labelledby. Do not replace the native input with a decorative button when designing options.
orientation specifies horizontal or vertical orientation and takes precedence over vertical. block stretches the options across the width of the container. disabled of the entire group also blocks those options that have disabled=false specified locally.
Semantic DOM of a separate Radio provides root, icon and label: classNames specifies classes, styles – CSS strings. Semantic slots RadioGroup, introduced in Ant Design 6.7, are not yet available in the public Svelte API. The usual class and style are available for the container; don't pass it group classNames/styles from the React examples.
Radio uses design tokens from the current theme for its appearance.
Examples
Single Radio
bind:checked binds the state. Pressing again does not clear the selection; the button resets it from the outside.
<script lang="ts">
import { Button, Radio } from '@woodger/antd';
let checked = $state(false);
</script>
<style>
.example {
display: grid;
justify-items: start;
gap: 20px;
}
output { color: var(--ant-color-text-secondary); }
</style>
<div class="example">
<Radio bind:checked>{("Single Radio")}</Radio>
<output aria-label={("Single Radio Status")}>checked: {(String(checked))}</output>
<Button onclick={() => { checked = false; }}>{("Reset mark")}</Button>
</div>
Unavailable options
Selected and unselected Radios retain their state when disabled. The button changes accessibility.
<script lang="ts">
import { Button, Radio } from '@woodger/antd';
let disabled = $state(true);
</script>
<style>
.example {
display: grid;
justify-items: start;
gap: 20px;
}
</style>
<div class="example">
<Radio {disabled}>{("Not selected")}</Radio>
<Radio {disabled} defaultChecked>{("Selected")}</Radio>
<Button onclick={() => { disabled = !disabled; }}>{(disabled ? "Allow selection" : "Deny selection")}</Button>
</div>
Group Radio
The group chooses one number. bind:value updates the model, onChange receives an event with target.value.
<script lang="ts">
import { RadioGroup } from '@woodger/antd';
let value = $state(1);
let eventValue = $state<number>();
</script>
<style>
.example {
display: grid;
justify-items: start;
gap: 20px;
}
output { color: var(--ant-color-text-secondary); }
</style>
<div class="example">
<RadioGroup aria-label={("Basic group Radio")} options={([
1,
2,
3,
4
])} bind:value
onChange={event => { eventValue = event.target.value; }} />
<output
aria-label={("Basic group value")}
>value: {value}; onChange: {(eventValue ?? '—')}</output>
</div>
Vertical groups
orientation places regular and push-button options vertically. Svelte snippet adds a field for its variant.
<script lang="ts">
import { Input, RadioGroup } from '@woodger/antd';
let value = $state(1);
let other = $state('');
</script>
<style>
.example {
display: grid;
justify-items: start;
gap: 24px;
}
.other {
display: inline-flex;
flex-wrap: wrap;
align-items: center;
gap: 12px;
}
output {
color: var(--ant-color-text-secondary);
overflow-wrap: anywhere;
}
</style>
{#snippet otherLabel()}
<span
class="other"
>{("Other")}{#if value === 4}<Input
bind:value={other}
aria-label={("Another option")}
style="width:120px"
/>{/if}</span>
{/snippet}
<div class="example">
<RadioGroup
aria-label={("Vertical group")}
orientation="vertical"
bind:value
options={([
{ value: 1, label: "Option A" },
{ value: 2, label: "Option B" },
{ value: 3, label: "Option C" },
{ value: 4, label: otherLabel }
])}
/>
<RadioGroup
aria-label={("Vertical buttons")}
orientation="vertical"
optionType="button"
options={(["Apple", "Pear", "Orange"])}
/>
<output aria-label={("Vertical group result")}>{value === 4 ? (other
|| ("Specify your option")) : ("Option " + String((value)) + "")}</output>
</div>
Full width group
block stretches a regular group, outline and filled buttons across the width of the container.
<script lang="ts">
import { RadioGroup } from '@woodger/antd';
const options = ["Apple", "Pear", "Orange"];
</script>
<style>
.example {
display: grid;
gap: 20px;
}
</style>
<div class="example">
<RadioGroup aria-label={("Stretched group")} block options={(options)} defaultValue="Яблоко" />
<RadioGroup aria-label={("Stretched filled buttons")} block options={(options)} defaultValue="Яблоко"
optionType="button" buttonStyle="solid" />
<RadioGroup aria-label={("Stretched contour buttons")} block options={(options)} defaultValue="Груша"
optionType="button" />
</div>
Groups from options
Simple values and RadioOption objects, unavailable options, optionType and buttonStyle.
<script lang="ts">
import { RadioGroup, type RadioOption } from '@woodger/antd';
let selected = $state(["Apple", "Apple", "Apple", "Apple"]);
const plain = ["Apple", "Pear", "Orange"];
const options =
plain.map(value => ({ value, label: value, title: value })) satisfies RadioOption[];
const disabledOptions = options.map(option => ({
...option,
disabled: option.value === "Orange"
}));
</script>
<style>
.example {
display: grid;
gap: 20px;
}
output {
color: var(--ant-color-text-secondary);
overflow-wrap: anywhere;
}
</style>
<div class="example">
<RadioGroup
aria-label={("Simple options")}
options={(plain)}
bind:value={selected[0]}
/>
<RadioGroup aria-label={("Objects options")} options={(disabledOptions)} bind:value={selected[1]} />
<RadioGroup
aria-label={("Buttons from options")}
options={(options)}
optionType="button"
bind:value={selected[2]}
/>
<RadioGroup aria-label={("Filled buttons from options")} options={(disabledOptions)}
optionType="button" buttonStyle="solid" bind:value={selected[3]} />
<output aria-label={("Results options Radio")}>{JSON.stringify(selected)}</output>
</div>
Button design
RadioButton inside RadioGroup: regular options, separate inaccessible button and inaccessible group.
<script lang="ts">
import { RadioButton, RadioGroup } from '@woodger/antd';
const cities = ['Hangzhou', 'Shanghai', 'Beijing', 'Chengdu'];
let selected = $state('Hangzhou');
</script>
<style>
.example {
display: grid;
gap: 20px;
}
.scroll {
max-width: 100%;
overflow-x: auto;
}
output { color: var(--ant-color-text-secondary); }
</style>
<div class="example">
{#each [0, 1, 2] as row (row)}
<div class="scroll">
<RadioGroup aria-label={("Push Button Select " + String((row + 1)) + "")} disabled={row
=== 2}
defaultValue="Hangzhou" value={row === 0 ? selected : undefined}
onValueChange={value => { if (row === 0) selected = value; }}>
{#each cities as city (city)}
<RadioButton
value={city}
disabled={row === 1 && city === 'Shanghai'}
>{(city)}</RadioButton>
{/each}
</RadioGroup>
</div>
{/each}
<output aria-label={("Selected city Radio")}>{selected}</output>
</div>
Group name and native form
name combines native keyboard radio and FormData. The example also shows reset and focus().
<script lang="ts">
import { Button, Radio, RadioGroup } from '@woodger/antd';
let first = $state<Radio>();
let result = $state(("Form has not been submitted yet"));
</script>
<style>
form {
display: grid;
justify-items: start;
gap: 20px;
}
.actions {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
output { color: var(--ant-color-text-secondary); }
</style>
<form onsubmit={event => {
event.preventDefault();
result = ("letter: " + String((new FormData(event.currentTarget).get('letter') ?? '—')) + "");
}}>
<RadioGroup name="letter" aria-label={("Named group Radio")} defaultValue="A">
<Radio bind:this={first} value="A">A</Radio>
<Radio value="B">B</Radio>
<Radio value="C">C</Radio>
<Radio value="D">D</Radio>
</RadioGroup>
<div class="actions">
<Button htmlType="submit">{("Read FormData")}</Button>
<Button
htmlType="reset"
onclick={() => { result = ("Form has not been submitted yet"); }}
>{("Reset form")}</Button>
<Button onclick={() => first?.focus()}>{("Focus on A")}</Button>
</div>
<output aria-label={("FormData Radio")}>{result}</output>
</form>
Button sizes
large, medium and small change the size of the button design. Narrow containers allow horizontal scrolling.
<script lang="ts">
import { RadioGroup } from '@woodger/antd';
const options = ['Hangzhou', 'Shanghai', 'Beijing', 'Chengdu'];
const sizes = ['large', 'medium', 'small'] as const;
</script>
<style>
.example {
display: grid;
gap: 20px;
}
.scroll {
max-width: 100%;
overflow-x: auto;
}
</style>
<div class="example">
{#each sizes as size (size)}
<div class="scroll">
<RadioGroup
aria-label={("Size Radio " + String((size)) + "")}
{size}
options={(options)}
optionType="button"
defaultValue="Hangzhou"
/>
</div>
{/each}
</div>
Solid fill
buttonStyle="solid" highlights the selected button with a fill. The unavailable state is shown separately.
<script lang="ts">
import { RadioGroup } from '@woodger/antd';
const options = ['Hangzhou', 'Shanghai', 'Beijing', 'Chengdu'];
</script>
<style>
.example {
display: grid;
gap: 20px;
}
.scroll {
max-width: 100%;
overflow-x: auto;
}
</style>
<div class="example">
<div class="scroll">
<RadioGroup
aria-label={("Filled RadioButton")}
options={(options)}
optionType="button"
buttonStyle="solid"
defaultValue="Hangzhou"
/>
</div>
<div class="scroll">
<RadioGroup aria-label={("Inaccessible filled RadioButton")} options={(options)} optionType="button"
buttonStyle="solid" defaultValue="Hangzhou" disabled />
</div>
</div>
Semantic styles
The styles object and classNames function from { props } style root, icon and label.
<script lang="ts">
import { Radio, type RadioProps } from '@woodger/antd';
const styles = {
root: `
padding: 8px 12px;
border-radius: 6px;
background: var(--ant-color-fill-alter);
`,
icon: 'border-color:var(--ant-color-warning)',
label: 'font-weight:600'
} satisfies RadioProps['styles'];
const classNames: RadioProps['classNames'] = ({ props }) => ({
label: props.checked ? 'selected-label' : 'idle-label'
});
</script>
<style>
.example {
display: grid;
justify-items: start;
gap: 20px;
}
.example :global(.selected-label) {
color: var(--ant-color-success);
font-weight: 700;
}
.example :global(.idle-label) { color: var(--ant-color-text-secondary); }
</style>
<div class="example">
<Radio {styles}>{("Radio Styles Object")}</Radio>
<Radio {classNames} defaultChecked>{("Function classNames Radio")}</Radio>
</div>
Typed values
The model retains the original string, number or boolean type, including 0 and false.
<script lang="ts">
import { RadioGroup, type RadioOption, type RadioValue } from '@woodger/antd';
let value = $state<RadioValue>(0);
const options = [
{ value: 0, label: "Number 0" },
{ value: false, label: 'Boolean false' },
{ value: 'draft', label: "String draft" }
] satisfies RadioOption<RadioValue>[];
</script>
<style>
.example {
display: grid;
justify-items: start;
gap: 20px;
}
output { color: var(--ant-color-text-secondary); }
</style>
<div class="example">
<RadioGroup aria-label={("Typed Radio selection")} options={(options)} bind:value />
<output aria-label={("Value type Radio")}>{(typeof value)}: {JSON
.stringify(value)}</output>
</div>
Selecting and checking in Form
Tariff and publication are associated with Form. Validate, submit, and reset store the values 0, false, and undefined.
<script lang="ts">
import {
Button,
Form,
FormItem,
Radio,
RadioGroup,
createForm,
type RadioOption
} from '@woodger/antd';
const generatedId = $props.id();
const plans: RadioOption<number>[] = [
{ value: 0, label: "Basic" },
{ value: 1, label: "Command" },
{ value: 2, label: "Archive", disabled: true }
];
const form = createForm<{ plan: number | undefined; published: boolean | undefined }>({
initialValues: { plan: 0, published: undefined },
rules: ({
plan: [{ required: true, message: "Select tariff." }],
published: [{ required: true, message: "Select publishing mode." }]
})
});
let orientation = $state<'horizontal' | 'vertical'>('horizontal');
let result = $state('');
function finish(values: { plan: number | undefined; published: boolean | undefined }) {
const selectedPlan = plans.find(plan => plan.value === values.plan);
const planLabel = selectedPlan?.label;
const publication = values.published
? ("Published")
: ("Draft");
result = ("Tariff: " + String((planLabel)) + ". Publication: " + String((publication)) + ".");
}
</script>
<style>
.example { max-width: 640px; }
.orientation {
display: flex;
flex-wrap: wrap;
gap: 12px;
margin: 0 0 24px;
padding: 0;
border: 0;
}
.orientation legend {
margin-bottom: 8px;
color: var(--ant-color-text-secondary);
}
.actions {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
.result {
margin: 16px 0 0;
color: var(--ant-color-success);
}
</style>
<div class="example">
<fieldset class="orientation">
<legend>{("Location options")}</legend>
<Radio
name={`radio-orientation-${generatedId}`}
value="horizontal"
checked={orientation === 'horizontal'}
onCheckedChange={() => { orientation = 'horizontal'; }}
>{("Horizontal")}</Radio>
<Radio
name={`radio-orientation-${generatedId}`}
value="vertical"
checked={orientation === 'vertical'}
onCheckedChange={() => { orientation = 'vertical'; }}
>{("Vertical")}</Radio>
</fieldset>
<Form {form} onFinish={finish}>
<FormItem name="plan" label={("Participant tariff")}>
<RadioGroup
options={(plans)}
{orientation}
value={form.values.plan}
onValueChange={(value) => {
form.setFieldValue('plan', value);
result = '';
}}
/>
</FormItem>
<FormItem name="published" label={("Publishing mode")}>
<RadioGroup
options={([{ value: false, label: "Draft" }, {
value: true,
label: "Published"
}])}
{orientation}
value={form.values.published}
onValueChange={(value) => {
form.setFieldValue('published', value);
result = '';
}}
/>
</FormItem>
<div
class="actions"
><Button
type="primary"
htmlType="submit"
loading={form.isSubmitting}
>{("Save settings")}</Button><Button
htmlType="reset"
onclick={() => { result = ''; }}
>{("Reset settings")}</Button></div>
</Form>
{#if result}<p class="result" role="status">{result}</p>{/if}
</div>
RadioButton gets the base prefix without -button. Group passes it options; arbitrary children choose their prefixCls independently, so here it is also set for the buttons.
CSS prefixes Radio
Common namespace ConfigProvider and local prefixCls; the state of the component is preserved when the name is changed.
<script lang="ts">
import { Checkbox, ConfigProvider, RadioGroup, RadioButton } from '@woodger/antd';
let custom = $state(true);
let local = $state(true);
const prefix = $derived(custom ? 'suite' : 'ant');
const localPrefix = $derived(local ? 'project-radio' : '');
let value = $state('draft');
</script>
<style>
.example,
.prefix-stage {
display: grid;
grid-template-columns: minmax(0, 1fr);
gap: 16px;
min-width: 0;
}
.controls {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
p { margin: 0; }
output { overflow-wrap: anywhere; }
</style>
<div class="example">
<div class="controls">
<Checkbox bind:checked={custom}>{("General prefix Radio suite")}</Checkbox>
<Checkbox bind:checked={local}>{("Local prefix Radio")}</Checkbox>
</div>
<ConfigProvider prefixCls={prefix} theme={{ cssVar: { prefix: 'radio-theme' } }}>
<div class="prefix-stage">
<RadioGroup
prefixCls={localPrefix}
bind:value
aria-label={("Radio with prefix")}
options={([
{ label: "Draft", value: 'draft' }, { label: "Ready", value: 'ready' }
])}
/>
<RadioGroup bind:value aria-label={("Radio buttons with prefix")}>
<RadioButton prefixCls={localPrefix} value="draft">{("Draft")}</RadioButton>
<RadioButton prefixCls={localPrefix} value="ready">{("Ready")}</RadioButton>
</RadioGroup>
<output aria-label={("Radio selection with prefix")}>{value}</output>
</div>
</ConfigProvider>
<output
aria-label={("CSS prefix Radio")}
>{("General: ")}{prefix}{("; local: ")}{(localPrefix
|| ("from the provider"))}</output>
<p>
{("RadioButton gets the base prefix without -button. Group passes it options; arbitrary children choose their prefixCls independently, so here it is also set for the buttons.")}
</p>
</div>
API
The main parameters are checked against the public types RadioProps, RadioGroupProps and RadioOption of the package @woodger/antd. Radio and RadioButton use the same state and event contract.
| Property | Description | Type | Default |
|---|---|---|---|
prefixCls | Basic CSS prefix without the -group/-button suffix. The empty string and undefined inherit ConfigProvider. The group applies to options; children choose it independently. | string | ConfigProvider.prefixCls + "-radio" |
checked | Selected state; supports bind:checked outside of RadioGroup. | boolean | false |
defaultChecked | Initial state without binding. Native reset restores it without callbacks. | boolean | false |
value | Variant value for group or FormData; does not replace checked for a single Radio. | RadioValue | on |
disabled | Locks selection. Inherited from Group, Form or ConfigProvider. | boolean | From context |
onCheckedChange | Gets a boolean when user selects. | (checked: boolean) => void | — |
onChange | Gets target.checked, typed target.value and nativeEvent. Native onchange receives a DOM event. | (event: RadioChangeEvent) => void | — |
autoFocus | Focuses input when mount; native autofocus is also preserved. | boolean | false |
classNames | Classes root, icon and label; object or function from { props }. | RadioSemantic | — |
styles | CSS lines of the same semantic slots; object or function from { props }. | RadioSemantic | — |
inputElement | bind:inputElement returns the native input. | HTMLInputElement | — |
nativeElement | bind:nativeElement returns the inner span of the icon. | HTMLSpanElement | — |
ref | bind:ref returns input, nativeElement, focus() and blur(). Links are cleared when unmounted. | RadioRef | — |
| Property | Description | Type | Default |
|---|---|---|---|
prefixCls | Basic CSS prefix without the -group/-button suffix. The empty string and undefined inherit ConfigProvider. The group applies to options; children choose it independently. | string | ConfigProvider.prefixCls + "-radio" |
value | Selected value; supports bind:value. value — string, number or boolean. | Value | undefined |
defaultValue | Initial local value; native reset restores it. | Value | undefined |
options | Simple values or objects with value, label, disabled, id, title, className, style, required and onChange. | readonly (Value | RadioOption<Value>)[] | [] |
children | Child Radio or RadioButton. Non-empty options takes precedence. | Snippet | — |
name | Common name for native input. Involved in keyboard selection and FormData. | string | Generated name |
orientation | Location options. Takes precedence over vertical. | horizontal | vertical | horizontal |
vertical | Compatible way to enable vertical layout. | boolean | false |
block | Stretches the group and distributes the options evenly. | boolean | false |
optionType | Sets the appearance of options and overrides the type of child RadioButtons. | default | button | default |
size | Button design size; regular Radio retains its icon size. | ComponentSize | From ConfigProvider |
buttonStyle | Outline or filled design for the selected button. | outline | solid | outline |
disabled | Native fieldset blocks the entire group. disabled=false for the option does not remove this lock. | boolean | From context |
onChange | Receives event with target.value; called when the selected value changes. | (event: RadioChangeEvent<Value>) => void | — |
onValueChange | Gets the selected value itself after onChange. | (value: Value) => void | — |
nativeElement | bind:nativeElement returns the container of the group. | HTMLFieldSetElement | — |
ConfigProvider.radio
classstyleclassNamesstylesThe appearance is applied to the Radio, RadioButton and options options. Button accessibility and size are inherited from componentDisabled and componentSize.
onchange, onfocus, onblur and onkeydown preserve native Svelte events. Compatible names with a capital letter are also supported.
Methods
Via bind:this and bind:ref available focus(options?: FocusOptions) and blur(). bind:inputElement returns input, bind:nativeElement - internal span. For RadioGroup, nativeElement points to fieldset.
Named group shows soft focus, send and native reset.
Semantic DOM
Radio
Select an element to highlight. Names are used in classNames and styles; styles accepts CSS strings.
RadioGroup
The semantic classNames and styles groups added in Ant Design 6.7.0 are not yet supported by the package. Available for container class and style, for options - ConfigProvider.radio and options properties.
Registration tokens
Component tokens are specified in ConfigProvider.theme.components.Radio. Separate radioColor and radioBgColor - package compatibility parameters, the rest correspond to the main Radio tokens on ant.design.
<script lang="ts">
import { ConfigProvider, Radio, RadioGroup } from '@woodger/antd';
</script>
<style>
.example {
display: grid;
justify-items: start;
gap: 20px;
}
</style>
<ConfigProvider theme={{
cssVar: {},
token: { colorPrimary: '#389e0d' },
components: { Radio: { radioSize: 20, dotSize: 10, buttonPaddingInline: 20 } }
}}>
<div class="example">
<Radio defaultChecked>{("Own theme Radio")}</Radio>
<RadioGroup aria-label={("Custom RadioButton theme")} options={([
"Day",
"Week",
"Month"
])}
optionType="button" buttonStyle="solid" defaultValue="Неделя" />
</div>
</ConfigProvider>
| Token | Purpose |
|---|---|
buttonBg | Button background. |
buttonCheckedBg | Background of the selected outline button. |
buttonCheckedBgDisabled | Background of the selected inaccessible button. |
buttonCheckedColorDisabled | Text of the selected inaccessible button. |
buttonColor | Button text color. |
buttonPaddingInline | Horizontal padding of the button. |
buttonSolidCheckedActiveBg | Background of the pressed selected button with fill. |
buttonSolidCheckedBg | Background of the selected button with fill. |
buttonSolidCheckedColor | Text of the selected button with fill. |
buttonSolidCheckedHoverBg | Background of the selected button with fill on hover. |
dotColorDisabled | Color of the mark for unavailable Radio. |
dotSize | Mark size. |
radioSize | Radio icon size. |
wrapperMarginInlineEnd | Indentation between options. |
radioColor | Mark color taking into account wireframe; package compatibility parameter. |
radioBgColor | Icon background taking into account wireframe; package compatibility parameter. |
Common tokens of the current topic
Values are read through theme.useToken() and react to the settings in the header.
| Token | Purpose | Current value |
|---|---|---|
colorBgContainer | Container background. | #ffffff |
colorBgContainerDisabled | Background of an inaccessible element. | rgba(0,0,0,0.04) |
colorBorder | Frame color. | #d9d9d9 |
colorPrimary | Primary color. | #2f54eb |
colorPrimaryActive | Primary color when pressed. | #1d39c4 |
colorPrimaryBorder | Light outline of the main color. | #adc6ff |
colorPrimaryHover | Primary hover color. | #597ef7 |
colorText | Text color. | rgba(0,0,0,0.88) |
colorTextDisabled | Color of inaccessible text. | rgba(0,0,0,0.25) |
borderRadius | Normal rounding. | 6 |
borderRadiusLG | Large rounding. | 8 |
borderRadiusSM | Small rounding. | 4 |
controlHeight | Normal element height. | 32 |
controlHeightLG | Height of a large element. | 40 |
controlHeightSM | Height of the small element. | 24 |
controlOutline | Focus outline color. | rgba(5,88,255,0.06) |
controlOutlineWidth | Thickness of the element outline. | 2 |
fontFamily | Font family. | -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
'Noto Color Emoji' |
fontSize | Normal text size. | 14 |
fontSizeLG | Large text size. | 16 |
lineHeight | Row height. | 1.5714285714285714 |
lineType | Frame line type. | solid |
lineWidth | Frame thickness. | 1 |
lineWidthFocus | Focus stroke thickness. | 3 |
marginXS | Small external indent. | 8 |
motionDurationMid | Duration of main transitions. | 0.2s |
motionDurationSlow | Duration of slow transitions. | 0.3s |
motionEaseInOutCirc | Transition curve. | cubic-bezier(0.78, 0.14, 0.15, 0.86) |
paddingXS | Small internal indent. | 8 |
FAQ
Why doesn't pressing it again clear the selection?
Radio saves the selected option. To reset, change the model outside or add a separate answer. If you need to turn the mark on and off independently, use Checkbox.
What is the difference between onChange and onValueChange?
onChange receives a RadioChangeEvent with target.value and nativeEvent. onValueChange gets the selected value itself after onChange. For two-way state communication in Svelte, use bind:value.
How to save 0 and false in a form?
Leave the original types in options and the Form model. Don't use boolean conversion to check for selection. Example form retains both values; native FormData contains their string representation.
Why do you need a name?
It combines native input for keyboard and form submission. Without name, RadioGroup creates its own name. For a predictable key in FormData, set it explicitly, as in native form.
Why are children not shown along with options?
Non-empty options shows own options instead of children. Use options for the standard list, and the child Radio or RadioButton for your own markup.
Is it possible to design the Semantic DOM of the entire RadioGroup?
The new group classNames/styles from Ant Design 6.7 have not yet been carried over. A separate Radio has root, icon and label available; For the group container, use class and style. Example of semantic styles shows available settings.