vuetifyjs / vuetifyjs/vuetify

[Feature Request] A Checkbox Group component

Open
#22,351 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C: New Component C: VCheckbox T: feature
Dominant language
TypeScript
Stars
41k
Forks
7.1k
Avg merge
1d 21h
Merged PRs (30d)
11

Description

Problem to solve

I'm working on a very form heavy app that's trying to improve information density by making selects with only a few options Checkboxes and Radio Buttons. While implementing the designs the VRadioGroup works flawlessly, but when it comes to Checkboxes there's a lot of gotchas to contend with.

Up front the ones I've encountered are:

  • the VCheckbox label height is aligned with the general input height, so simply stacking them or flexing to inline them causes them not to visually match the radio buttons
  • VCheckboxBtn is the obvious next choice
    • It has the benefit of matching the VRadio heights (being that they're both VSelectionControl elements)
    • but they're a bit "non-standard" in that you wouldn't think to reach for them which isn't a deal breaker on it's own
  • Grouping them requires some degree of custom wiring that VRadioGroup handles for its children
    • Accessible label, messages, and grouping via role (this is important for my company)
    • VInput trappings (messages, etc.)
    • Style handling (e.g. inline, and all the VSelectionControlGroup props generally)

There's more than a few ways to wire things and they all have their own room for introducing errors and differences over time and any lower level solutions (cloning the VRadioGroup component or using internal APIs) risk needing interventions if there are breaking changes.

Note: I did see https://github.com/vuetifyjs/vuetify/issues/16858 but it's been closed for over a year and I felt I had a more compelling argument to make in terms of why it would be helpful vs. using a workaround.

I also saw https://github.com/vuetifyjs/vuetify/issues/16245#issuecomment-1909568669 and considered mentioning it there, but it feels like it's more deserving of its own discussion.

Proposed solution

I naively hope it would be as simple as cloning VRadioGroup, retaining the multiple prop, adding some conditional styling for VCheckbox, and updating defaultsTarget but in my time trying to reverse engineer the component a bit (was thinking of maybe recreating it in a SFC) I'm not super confident in that assessment

Though in writing this feature request I've learned a lot more about the various workarounds, so if it comes down to a documentation update along the lines of "Use VCheckboxBtn in VRadioGroup to group them" I'd be happy with that too, even if it doesn't feel like the pattern would be getting first-class treatment, I can appreciate the maintenance costs associated with that :)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the existing VRadioGroup, VCheckbox, VCheckboxBtn, and VSelectionControlGroup implementations first, comparing their grouping, accessibility, VInput, and style behavior. Determine whether the request needs a first-class checkbox group or documentation for an existing workaround; completion should address the listed label, messages, role, multiple-selection, and inline-style requirements.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
accessibility, frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.