rob-balfre / svelte-select

Svelte Select. A select component for Svelte
https://svelte-select-examples.vercel.app
Other
1.26k stars 175 forks source link

Help how to bind:value as a simple value and how to style select #483

Closed kane81 closed 1 year ago

kane81 commented 1 year ago

Hi

I need help - I have a object array of items and I would like svelte-select to bind:value to bind the value selected and not the object selected.... I have a workaround, but it is extra boiler plate code and wondering if there is a better way?

Also I cannot seem to style svelte-select background color to say red on an error.

Please see example in repl https://svelte.dev/repl/16a4db40caf24df6befff466dcceb9e8?version=3.52.0

Thank you

kl3sk commented 1 year ago

Hello,

May this REPL help you

You have to bind:value and refer to it.

rob-balfre commented 1 year ago

beta version...

https://svelte.dev/repl/3183f841f0084706b85f63b33d4ee425?version=3.52.0

kane81 commented 1 year ago

Thank you for your reply and REPL-

re bind:value - yeah I had worked that out - was hoping there was a more elgant way that uses less boiler plate lol :P guess I need to upgrade to beta version :P

thanks for the beta preview. FYI for example code - probably adjust sample from class={styleAsError ? "invalid" : ""} to class:invalid={styleAsError}