question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding support for _checked state selector to Checkbox container

See original GitHub issue

Description

It can be useful to be able to set the container style of a <Checkbox/> depending on whether or not it’s checked. For example, changing the background to make the checked state stand out.

Problem Statement/Justification

Some design systems may require being able to change the container styling depending on the checked state.

Also makes sense to add for a more consistent API as both the control and label parts seem to support a _checked state.

Proposed Solution or API

Something like

{
  baseStyle: {
    container: {
      _checked: {
        bg: 'red.200'
      }
    }
  }
}

Alternatives

Currently making a custom <Checkbox/> component.

Additional Information

Example:

Screen Shot 2021-08-25 at 2 12 19 PM

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
segunadebayocommented, Sep 16, 2021

@codetheweb Yes, it still stands and I think it’s a valid use-case.

I’ve just added support for this. It’ll be available in the next release.

1reaction
anubra266commented, Sep 2, 2021

Oh…but the Checkbox doesn’t have a container part

Read more comments on GitHub >

github_iconTop Results From Across the Web

checked - CSS: Cascading Style Sheets - MDN Web Docs
The :checked CSS pseudo-class selector represents any radio ( ), checkbox ( ), or option ( in a ) element that is checked...
Read more >
How To Select The Check Box In Selenium With Examples
#1) Checked: State in which the Checkbox is selected is the checked state. Here, we can see the box as tick marked. #2)...
Read more >
checked - CSS-Tricks
The :checked pseudo-class selector matches radio and checkbox input types when checked or toggled to an on state.
Read more >
Building a custom checkbox in React - LogRocket Blog
Later on this page, we will define logic that lets us pass the initial state into the Checkbox component, whether we want it...
Read more >
Tri-state Check box in HTML? - Stack Overflow
It will require some javascript and a CSS class. Here I put a particular example that handles a list with checkable items and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found