Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isChecked property in Checkbox prop choices is not working #1495

Open
spassvogel opened this issue Nov 28, 2024 · 0 comments
Open

isChecked property in Checkbox prop choices is not working #1495

spassvogel opened this issue Nov 28, 2024 · 0 comments

Comments

@spassvogel
Copy link

spassvogel commented Nov 28, 2024

Describe the bug

The choices prop of Checkbox accepts an array of the following type:

export type CheckboxItem = {
    value: string;
    label?: string;
    isChecked?: boolean;
};

This leads me to believe that isChecked can be used for the initial checked value. This does not work, however.

Reproduction

<script>
  import {Checkbox} from 'flowbite-svelte'
  
  const choices = [{
    value: 'd',
    label: 'Donatello',
    isChecked: true
  }, {
    value: 'l',
    label: 'Leonardo',
    isChecked: true
  }, {
    value: 'm',
    label: 'Michelangelo'
  },{
    value: 'r',
    label: 'Raphael'
  }];
</script>

<Checkbox 
  choices={choices} 
/>

I expect Donatello and Leonardo to be checked ,but they are not.

image

I know it's possible to databind to the group property, but because in my case the checked state is derived from another state, this is not an option. It would be great if isChecked worked, and I could handle the group state myself.

Flowbite version and System Info

"svelte": "^4.2.7",
    "flowbite": "^2.5.2",
    "flowbite-svelte": "^0.47.1",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant