-
Notifications
You must be signed in to change notification settings - Fork 199
[Feature Request] Use custom colors instead of being limited to predefined ones #29
New issue
Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “No 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? No Sign in to your account
Comments
Thank you for this suggestion. PRs are welcome. You can test your implementation using the playground. |
Hi @dimitribarbot 👋 Thank you very much for your feedback and for this proposal. Initially, I did not want to offer a set of predefined styles to limit our users. I wanted to allow people to create their own custom styles. But, I quickly ran into a problem.
We notice that Tailwindcss does not generate CSS styles for utility classes that have portions as parameters. If the color of the props was blue, we should have the class It is thus in spite of me that I provided predefined styles while waiting to propose something else. If you have a solution you can propose it to us. |
Hi @JefteCaro and @onesine 👋 Thank you for your quick answers ! Indeed, you're totally right, I did not see this part of the Tailwind documentation: Dynamic Class Names. This seems to be a Tailwind limitation. Then, I propose to add What do you think ? If you agree, I can push a PR, I tested it in the playground and it's working like a charm. |
On the contrary, we thank you for it. And thank you for the ideas you have to improve the datepicker. I think this is a great idea. Offering a primary and secondary color adds more customization possibilities. I agree with you and PRs are always welcome. |
I've pushed a PR here. Also, I'd like to really thank you for your work on this component, this will help me a lot. And I will look at your select component as well, it may fits my needs. 🥳 |
Thanks for the PR, I'll take a quick look at it. I'm glad the component is helping you. |
Not being able to use custom colors is currently a large downside for us - potentially enough for us to choose another lib. We're using DaisyUI with custom colors and cannot style the component. Regarding dynamic class names: I think it would be better to expose something like <Datepicker
theme={{
text: "text-custom-color1",
header: "bg-custom-color2",
outline: "bg-custom-color3",
}} than not at all. |
https://github.com/OMikkel/tailwind-datepicker-react implements my suggested solution above. |
Hi @FelixZY 👋 Thanks for your feedback. We are still looking for a solution to this issue. Thanks for the suggestion. We will take it into account. |
I see that PR #40 seems to have added support for custom colors, but I see no explanation of how to use this in the documentation. Can someone please explain? |
Would it be possible to use a classFilter to allow the user to override any of the default styling? I use a classFilter for all my components to allow customizations for specific use cases. Create the util class with twMerge
Implement in component
Override class in consumer files
|
Although as this is a tailwind component it makes sense to have support only tailwind supported colors and as users need more customization. My idea would be instead of defining colors like this:
we can use
or
to get all the user defined colors from the One other thing is simply taking any string (even if its a gradient) and apply to the calendar. |
Using Tailwind CSS, I can customize my colors as described in the documentation.
I'd like to be able to create custom colors and apply them to the datepicker instead of being limited to the predefined ones. It seems to me that every color in the component is computed based on the
primaryColor
prop.If I'm correct, this feature could be achieved by doing a few changes:
In
/src/helpers/index.ts
,getTextColorByPrimaryColor
can be replaced with:In
/src/components/utils.tsx
, in theRoundedButton
, instead of the switch onprimaryColor
, it can be:In
/src/constants/index.ts
, instead of theBG_COLOR
,TEXT_COLOR
,BORDER_COLOR
andRING_COLOR
constants, we can write helpersgetBgColor
,getTextColor
,getBorderColor
andgetRingColor
respectively:This should do the trick without breaking compatibility with existing predefined colors. One must create custom colors for every shade though (it seems at least 100, 200, 400, 500, 600 and 700 are mandatory for the moment).
The text was updated successfully, but these errors were encountered: