Hoppa till innehåll

RadioGroup

RadioGroup

PropTypeDescription
idstringUnique identifier for the component.
Default: generateId()
namestringName attribute for the radio group. Must be set if SiteVision default functions are used.
legendstringFieldset legend.
descriptionstringDescription text displayed below the input field.
legendVisuallyHiddenbooleanIf the legend should be hidden visually.
Default: false
optionsArray<string> Array<{ label, value }>Array of options for the radio group.
disabledboolean | Array<string>If the field is disabled. Can disable all options or specific ones.
Default: false
showbooleanShow or hide the component without re-rendering.
Default: true
valuestringBound value for the radio group.
Default: ''
<script>
import { Panel, RadioGroup } from '@soleil-se/config-svelte';
const options1 = ['Värde 1', 'Värde 2', 'Värde 3'];
const options2 = [
{ label: 'Värde 1', value: 'value1' },
{ label: 'Värde 2', value: 'value2' },
{ label: 'Värde 3', value: 'value3' },
];
</script>
<Panel heading="Inställningar">
<RadioGroup
name="radioGroup1"
legend="Radio group 1"
options={options1}
value="Värde 1"
/>
<RadioGroup
name="radioGroup2"
legend="Radio group 2"
options={options2}
value="value1"
/>
</Panel>
Advanced
<script>
import { Panel, RadioGroup } from '@soleil-se/config-svelte';
import { onSave } from '@soleil-se/config-svelte/utils';
const { values } = $props();
values = {
radioGroup: '',
...values,
};
const options = ['Värde 1', 'Värde 2', 'Värde 3'];
onSave(() => values);
</script>
<Panel heading="Inställningar">
<RadioGroup bind:value={values.radioGroup} legend="Radio group" {options} />
</Panel>

Default slot after radio group.

<RadioGroup name="radioGroup" legend="Radio group" {options} />
<p>Some text</p>
</RadioGroup>

Slot for content in the legend element.

<RadioGroup name="radioGroup" {options} />
{#snippet legend()}
Custom <em>legend</em>
{/snippet}
</RadioGroup>

Slot for content in each radio button’s label. The provided option parameter contains the full option object corresponding to the specific radio button as provided in the options array to the RadioGroup.

<RadioGroup name="radioGroup" {options} />
{#snippet option(o)}
<span>{o.label || o}</span>
<span>Custom <em>content</em></span>
{/snippet}
</RadioGroup>

Use the value attribute to set a default value:

<RadioGroup
name="radioGroup"
legend="Radio group"
options={['Värde 1', 'Värde 2', 'Värde 3']}
value="Värde 1"
/>