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.

Allow granular styling of checkbox, label, and icon in Checkbox and Radio components

See original GitHub issue

Thank you for the incredible work! Chakra UI is awesome. 😃

Is your feature request related to a problem? Please describe. Thus far, our implementation of Chakra UI has been seamless, with a high degree of freedom in customizing the appearance of components to our designs. However, the implementation of Checkbox and Radio components exposed far less freedom to customize the look and feel…

Describe the solution you’d like Ideally, I would like to be able to be able to inject arbitrary property overrides into the <Radio> and the <Checkbox> components that will be applied to the <ControlBox>, the <Box as="span">, and the <Icon> child components in both Chakra components.

One API that I could imagine could be something like:

<Checkbox propOverrides={'checkbox': {}, 'label': {}, 'icon': {}} />

Alternatively, the overrides could be exposed as top-level properties:

<Checkbox checkboxProps={} labelProps={} iconProps={} />

Describe alternatives you’ve considered Presently, the workaround I am implementing is to follow the recommendations outlined in https://chakra-ui.com/controlbox however this involves duplicating much of the existing source code in Chakra UI for only a few aesthetic changes in the sub-components of <Radio> and <Checkbox>.

It would be very helpful to implement the Chakra Checkbox and Radio components, out-of-the-box. However, we need a high degree of style customization.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:13
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

13reactions
nelsieborjacommented, Aug 6, 2021

Checkbox iconSize prop seems broken. Tried setting its value but it is not affecting the size of the check icon.

6reactions
mattstobbscommented, Mar 1, 2022

In case anyone still has this problem, we were able to update the stylings by updating our theme to extend the base styles found in https://github.com/chakra-ui/chakra-ui/blob/main/packages/theme/src/components/checkbox.ts

const theme = {
  components: {
    Checkbox: {
      baseStyle: {
        icon: {
          color: 'white',
        },
        control: {
          border: '1px',
          borderColor: 'gray.300',
          borderRadius: 'base',
          _disabled: {
            borderColor: 'gray.300',
            bg: 'gray.200',
          },
        },
        label: {
          fontWeight: 'medium',
          color: 'gray.900',
        },
      },
    },
  },
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Create a Custom Checkbox - W3Schools
Learn how to create custom checkboxes and radio buttons with CSS. ... </label> <label class="container">Two <input type="checkbox">
Read more >
Inclusively Hiding & Styling Checkboxes and Radio Buttons
I like to wrap my checkboxes inside their labels. Placing the checkbox inside the label increases the overall clickable area, which makes it ......
Read more >
Input - dbc docs - Dash Bootstrap Components - Faculty AI
Create Bootstrap styled input components to capture data. ... If you need more granular control over checkboxes and radio buttons, you can also...
Read more >
Checkbox - Chakra UI
Chakra exports a CheckboxGroup component to help manage the checked state of its children Checkbox components and conveniently pass a few shared style...
Read more >
Controls - Storybook - JS.ORG
Let's replace it with Storybook's radio component. ... you can specify control.labels to configure custom labels for your checkbox, radio, or select input....
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