Hoppa till innehåll

CustomSelector

Wrapper component for Sitevision Custom selector.

CustomSelector CustomSelectorMultiple

PropTypeDescription
idstringID, generates automatically if nothing is passed.
Default: generateId()
labelstringLabel for the selector. Required.
Default: undefined
descriptionstringDescription for the selector, displayed below the label.
Default: undefined
namestringName attribute for the selector.
Default: undefined
placeholderstringPlaceholder text for the selector.
Default: undefined
optionsArray<{label, value}>Array of options for the selector.
Default: []
searchablebooleanWhether the selector is searchable.
Default: false
removablebooleanWhether selected options can be removed.
Default: true
requiredbooleanWhether the selector is required.
Default: false
disabledbooleanDisable the selector.
Default: false
multiplebooleanWhether multiple options can be selected.
Default: false
showbooleanShow and hide the component without re-rendering.
Default: true
valuestring | Array<any>Value associated with the selector.
Default: ''
<script>
import { Panel, CustomSelector } from '@soleil-se/config-svelte';
const options = [
{ label: 'Värde 1', value: 'value1' },
{ label: 'Värde 2', value: 'value2' },
{ label: 'Värde 3', value: 'value3' },
];
</script>
<Panel heading="Inställningar">
<CustomSelector name="custom" label="Custom selector" {options} />
</Panel>
Advanced
<script>
import { Panel, CustomSelector } from '@soleil-se/config-svelte';
import { onSave } from '@soleil-se/config-svelte/utils';
let { values } = $props();
values = {
custom: '',
...values
}
onSave(() => values);
</script>
<Panel heading="Inställningar">
<CustomSelector label="Custom selector" {options} bind:value={values.custom} />
</Panel>

Default slot after selector.

<CustomSelector name="custom" label="Custom selector" {options} >
<p>Some text.</p>
</CustomSelector>

Slot for content in the label element.

<CustomSelector name="custom" {options}>
{#snippet label()}
Custom <strong>label</strong>
{/snippet}
</CustomSelector>

Slot for content in the description element to be used instead of the prop when HTML formatting is needed.

<CustomSelector name="custom" {options}>
{#snippet description()}
Custom <strong>description</strong>
{/snippet}
</CustomSelector>

Option slot for custom templating.
The option is available as slot prop.

<CustomSelector name="custom" {options}>
{#snippet option(o)}
{o.label} ({o.type})
{/snippet}
</CustomSelector>