Is it possible to type Select's value not as string?
#2043
Unanswered
frederikhors
asked this question in
Q&A
Replies: 1 comment
|
Bits UI types the value as <script lang="ts" generics="T extends string">
import { Select, type WithoutChildren } from 'bits-ui';
type Props = Omit<WithoutChildren<Select.RootProps>, 'value' | 'onValueChange' | 'type'> & {
value?: T[];
onValueChange?: (value: T[]) => void;
items: { value: T; label: string; disabled?: boolean }[];
};
let { value = $bindable(), items, onValueChange, ...restProps }: Props = $props();
</script>
<Select.Root
type="multiple"
bind:value={value as never}
onValueChange={onValueChange as never}
{...restProps}
>
<!-- trigger and content as in the reusable example -->
</Select.Root>
|
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Thanks for this amazing project! I just discovered it and it's amazing!
I'm using the
Selectcomponent.It works amazingly well, but I have an issue with typings.
I created a small reproduction: https://svelte.dev/playground/dbc5da74256945beab6defbe6ed53548?version=latest.
Here the code:
Is there a way to correctly type the
valavaluewithout manually cast them?All reactions