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

Add indeterminate support to <Checkbox /> #479

Closed
schne324 opened this issue Dec 17, 2021 · 2 comments · Fixed by #1621
Closed

Add indeterminate support to <Checkbox /> #479

schne324 opened this issue Dec 17, 2021 · 2 comments · Fixed by #1621
Assignees
Labels
enhancement New feature or request rfc:accepted Flag an RFC as accepted rfc An issue proposing a new significant change
Milestone

Comments

@schne324
Copy link
Member

schne324 commented Dec 17, 2021

The indeterminate state is the state of a checkbox where the checked value of the checkbox cannot be determined.

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#attr-indeterminate

Design Specs

Note: The designs originated from UXPin and the links are no longer accessible but the concepts are still applicable. Please note the proposed design does not match the current size of checkboxes and this is intentional.

Dark mode

image

Light mode

image

No new icons are needed for this checkbox, the indeterminate state can be rendered purely with CSS, approximate styles below:

.Checkbox input[type='checkbox']:indeterminate ~ .Checkbox__overlay:before {
  content: "";
  display: block;
  position: absolute;
  height: calc(var(--icon-size) - 8px);
  width: calc(var(--icon-size) - 8px);
  background: currentColor;
  transform: translate(4px, 4px);
}

.Checkbox input[type='checkbox']:indeterminate ~ .Checkbox__overlay:after {
  content: "";
  display: block;
  position: absolute;
  height: 3px;
  width: calc(var(--icon-size) / 2);
  background-color: var(--workspace-background-color);
  transform: translate(6px, calc(var(--icon-size) / 2 * -1 - 1.5px));
}

Technical Details

For more context, this github comment thread for react provides specific details about implementation challenges with indeterminate checkboxes. The HTML spec does not allow for indeterminate properties to be set via an attribute, so it must be set via javascript.

The checked and indeterminate properties are incompatible, so we need to define the default behavior of what happens to the checkbox when it becomes indeterminate in either its checked or unchecked state.

@schne324
Copy link
Member Author

Grab the svg (and add it as a new <Icon /> type) from the uxpin

@scurker
Copy link
Member

scurker commented Feb 17, 2023

Closing, I'm not aware of anywhere that we currently need this and we can create a new issue if needed later.

@scurker scurker closed this as completed Feb 17, 2023
@scurker scurker reopened this Feb 23, 2023
@scurker scurker added the enhancement New feature or request label Feb 23, 2023
@longmatthewh longmatthewh self-assigned this Dec 13, 2023
@scurker scurker added the rfc An issue proposing a new significant change label Jul 30, 2024
@scurker scurker added this to the Q3 2024 milestone Jul 30, 2024
@scurker scurker added the rfc:accepted Flag an RFC as accepted label Aug 7, 2024
chornonoh-vova added a commit that referenced this issue Aug 8, 2024
chornonoh-vova added a commit that referenced this issue Aug 13, 2024
* feat(react): add indeterminate support to checkbox

Refs: #479

* fix: code review comments

Refs: #479

* fix: update icon type import

Co-authored-by: Jason <jason@scurker.com>

* fix(styles): colors for checkbox indeterminate state

* fix: update checkbox indeterminate screenshots

---------

Co-authored-by: Jason <jason@scurker.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request rfc:accepted Flag an RFC as accepted rfc An issue proposing a new significant change
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants