Skip to content

feat(CheckboxGroup): new component #3862

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

Open
wants to merge 21 commits into
base: v3
Choose a base branch
from
Open

Conversation

TribeWeb
Copy link

@TribeWeb TribeWeb commented Apr 11, 2025

πŸ”— Linked issue

Resolves #3050

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

The UCheckbox component currently handles single instances of a checkbox only, returning a string. Being able to put several checkboxes together and returning an array is a common user requirement that has already been implemented in reka-ui but not yet in Nuxt UI. The new component builds on the reka example and adheres to the same patterns found in the existing URadioGroup component.

#3178 has added some beautiful and very useful styling for the URadioGroup component via the new table & card variants and so these same variants have been implemented in the new UCheckboxGroup component too.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@sandros94
Copy link
Member

sandros94 commented Apr 11, 2025

@benjamincanac you know I'm a super fan of this 😬 (#895)

EDIT: oh man, fall 2023, time flies...

@sandros94 sandros94 added v3 #1289 enhancement New feature or request labels Apr 11, 2025
Copy link

pkg-pr-new bot commented Apr 11, 2025

npm i https://pkg.pr.new/@nuxt/ui@3862

commit: 4980a65

{{ legend }}
</slot>
</legend>
<component :is="variant === 'list' ? 'div' : Label" v-for="item in normalizedItems" :key="item.value" :class="ui.item({ class: props.ui?.item })">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to not use the UCheckbox component here instead of re-implementing everything? πŸ€”

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question! I started off with the intention of using the UCheckbox component. I felt that making the component as close to URadioGroup in structure was important to ensure consistency in behaviour in the new variants and how they applied to each component. As I proceeded, I became more confident I could achieve that aim by re-implementing instead. I'm willing to defer to your experience and refactor as suggested - this is my first pull request in any codebase so I'm more than happy to be guided.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can left it like that I guess but I would share the theme between checkbox and checkbox-group though. The new variants should also be available on Checkbox.

You can check how textarea imports input theme for example.

@benjamincanac benjamincanac changed the title feat: New component - UCheckboxGroup feat(CheckboxGroup): new component Apr 12, 2025
@benjamincanac benjamincanac requested a review from romhml April 12, 2025 09:57
@benjamincanac benjamincanac requested a review from sandros94 April 13, 2025 09:16

Use the `items` prop as an array of strings or numbers:

::component-code
Copy link
Member

@romhml romhml Apr 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's something wrong when you change the value by interacting with the example in the documentation:
image

Copy link
Author

@TribeWeb TribeWeb Apr 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @romhml. I have not been able to get pnpm run docs to work at any stage of working on this (JS heap out of memory). Is there another way I can review the page so I can see the behaviour you've seen?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was caused by an invalid modelValue in the docs, I fixed it here: 7a7180c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request v3 #1289
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UCheckbox array support
4 participants