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.

Problems styling new Checkbox component

See original GitHub issue

First of all, thank you for putting together a set of form primitives, this is going to be very helpful 😃

I’ve been testing them out and so far I’ve had problems to style the Checkbox component. According to the form docs, it should be possible to style them with theme.forms.checkbox, but I’ve tried with all kind of properties (color, background borderColor) and none seems to work.

The only way I’ve found to change the color is to use the sx property:

import { Checkbox } from "@rebass/forms";

<Checkbox sx={{ color: "#00f"}}/>

However for some reason that’s only accepting raw values, and not colors defined in theme.colors (such as primary).

Not sure if there is something broken in the implementation of the Checkbox component, or it’s just lack of better documentation for it, in any case any guidance would be more than appreciated 😃

Thank you!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
jxnblkcommented, Aug 21, 2019

4.05 should have the styled-components version now, you can import components from @rebass/forms/styled-components

1reaction
javiercrcommented, Aug 28, 2019

Great! Now it works 😃 Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Building a Checkbox Component with React and ... - Medium
A (mostly) hack-free approach​​ Native checkboxes are notoriously difficult to style. Customization is tough because you cannot apply styles ...
Read more >
Styling HTML checkboxes is hard - here's why - Arek Nawo
Why styling HTML checkboxes can be hard and how to do this in CSS and JS! HTML form elements. Raw HTML and JS...
Read more >
Building a custom checkbox in React - LogRocket Blog
In this guide, we will cover how to build a custom checkbox in React without sacrificing accessibility for assistive technology.
Read more >
Custom Checkbox in React (Animated and Accessible)
Let's first have a look at some possible (but wrong) approaches to creating custom checkboxes and explore their drawbacks.
Read more >
Reactjs Styled-components not working properly
But the problem is background color is always staying green and i dont know why. The react component in which I'm using this...
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