Files
nodarium/packages/ui/src/lib/inputs/InputSelect.svelte
T
max d4910aba8c
📊 Benchmark the Runtime / benchmark (pull_request) Successful in 1m2s
🚀 Lint & Test & Deploy / quality (pull_request) Successful in 2m30s
🚀 Lint & Test & Deploy / test-unit (pull_request) Successful in 32s
🚀 Lint & Test & Deploy / test-e2e (pull_request) Failing after 33s
🚀 Lint & Test & Deploy / deploy (pull_request) Has been skipped
chore: pnpm format
2026-05-04 15:00:40 +02:00

32 lines
732 B
Svelte

<script lang="ts">
type SelectOption = string | { value: number; label: string };
interface Props {
options?: SelectOption[];
value?: number;
id?: string;
}
let { options = [], value = $bindable(0), id = '' }: Props = $props();
const normalized = $derived(
options.map((opt, i) => typeof opt === 'string' ? { value: i, label: opt } : opt)
);
</script>
<select {id} bind:value class="bg-layer-2 text-text">
{#each normalized as opt (opt.value)}
<option value={opt.value}>{opt.label}</option>
{/each}
</select>
<style>
select {
font-family: var(--font-family);
outline: solid 1px var(--color-outline);
padding: 0.5em 0.8em;
border-radius: 5px;
border: none;
}
</style>