-
Notifications
You must be signed in to change notification settings - Fork 226
Add coloured check marks #27
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
Comments
Did you ever find an elegant solution? |
Just ran into this one. I expected |
The best quick solution I came up with was adding this to my base styles (the only thing being changed is the fill value):
So all I have to do is add a checkmark-gray class to the checkbox and it looks the way I want. Ideally there would be a way to generate Let me know if you find anything even more elegant. |
Now we can control the background with the text color like To me the ideal solution would be:
Else we are stuck with just the text color. |
I just made a heck of a hack. It's similar to agusterodin solution. It includes both checkboxes and radio buttons. @layer components {
[type="checkbox"]:checked {
background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='%23262626' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3e%3c/svg%3e");
}
[type="radio"]:checked {
background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='%23262626' xmlns='http://www.w3.org/2000/svg'%3e%3ccircle cx='8' cy='8' r='3'/%3e%3c/svg%3e");
}
[type="checkbox"],
[type="radio"] {
@apply focus:ring-0 focus:ring-offset-0;
}
[type="checkbox"],
[type="checkbox"]:checked,
[type="checkbox"]:checked:hover,
[type="checkbox"]:checked:focus,
[type="checkbox"]:indeterminate:hover,
[type="radio"],
[type="radio"]:checked,
[type="radio"]:checked:hover,
[type="radio"]:checked:focus {
@apply border-gray-300;
}
} As you may notice I also removed the focus styles because I found it distracting and it's not default on checkboxes anyway. The input without the label looks like this: <input type="checkbox" class="w-5 h-5 text-white rounded-sm" /> <input type="radio" class="w-5 h-5 text-white" /> The result of the checkboxes in the below image: See my previous comment for a solid suggestion to a solution. |
This would be my ideal as well. The tricky part is that the checkbox uses a background image for the check/dash, and even though it's an encoded SVG, stuff like |
are there any plans to add this? |
Would love to see this! |
I could be mistaken, but is this what you are looking for? https://tailwindcss.com/docs/accent-color |
@nonameolsson afaik you still can't style the color of the checkmark itself |
Since this plugin essentially shows checkmarks as a custom svg (to normalize aesthetic across browsers/platforms), I don't think the SVG image will go off of the accent color property but instead goes off of the inlined background color in that checkmark svg. |
I'm using a checkbox on a coloured background, and so I want the checkbox box to be white, and the tick inside to be the same colour as the background. Here's one made from an SVG I stole from here before Tailwind 2:
I'm trying to replicate this using just classes with Tailwind 2, but have been unable to so far:
(I have a custom colour called 'raisin' which is
#27262c
)The text was updated successfully, but these errors were encountered: