Comments (13)
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 primary
and secondary
as available colors. These are common conventions in naming colors while theming. It will allow anyone to use their own color by adding configuration in the tailwind.config.js file.
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.
from react-tailwindcss-datepicker.
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.
from react-tailwindcss-datepicker.
The quick and temporary solution is we can override the existing color names with our brand color in tailwind.config.js
like below:
from react-tailwindcss-datepicker.
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.
When you use the following code.
import React from 'react';
const App = ({color}) => {
return (
<div className='App'>
<h1 className={`text-3xl font-bold text-${color}-500`}>Hello React.</h1>
</div>
);
}
export default App;
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 . text-blue-500
in the CSS file generated by tailwind. But, we don't find it.
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.
PRs are welcome.
from react-tailwindcss-datepicker.
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. 🥳
from react-tailwindcss-datepicker.
Thank you for this suggestion.
PRs are welcome. You can test your implementation using the playground.
from react-tailwindcss-datepicker.
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.
from react-tailwindcss-datepicker.
Thanks for the PR, I'll take a quick look at it.
I'm glad the component is helping you.
from react-tailwindcss-datepicker.
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.
from react-tailwindcss-datepicker.
https://github.com/OMikkel/tailwind-datepicker-react implements my suggested solution above.
from react-tailwindcss-datepicker.
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?
from react-tailwindcss-datepicker.
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
import { ClassNameValue, twMerge } from "tailwind-merge";
export function classFilter(...classes: ClassNameValue[]) {
return twMerge(classes.filter(Boolean).join(" "));
}
Implement in component
import React from 'react';
import { classFilter } from 'util';
const App = ({ className }) => {
return (
<div className='App'>
<h1 className={classFilter('text-3xl font-bold text-indigo-500', className)}>Hello React.</h1>
</div>
);
}
export default App;
Override class in consumer files
<App className={"font-light text-xl"} />
from react-tailwindcss-datepicker.
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:
export declare const COLORS: readonly ["blue", "orange", "yellow", "red", "purple", "amber", "lime", "green", "emerald", "teal", "cyan", "sky", "indigo", "violet", "purple", "fuchsia", "pink", "rose"];
we can use
require('tailwindcss/colors')
or
import resolveConfig from 'tailwindcss/resolveConfig'
import tailwindConfig from 'path/to/your/tailwind.config.js'
const fullConfig = resolveConfig(tailwindConfig)
to get all the user defined colors from the tailwind.config.js
.
One other thing is simply taking any string (even if its a gradient) and apply to the calendar.
from react-tailwindcss-datepicker.
Related Issues (20)
- Value not displaying HOT 2
- Editing value manually doesn't update widget if done at the start
- Missing comma in demo code
- Calendar not showing previous month when using different dayjs.locale()
- id attribute not passed on to underlying input
- custom classnames
- Feature Request: Can you add a time range, e.q. 08:00 - 14:00
- Masks
- Read-only mode not working
- State of the project HOT 1
- Modal is not adjusting according to height HOT 2
- Pop up is displayed below another component despite a higher z Index container
- Weird date selection behaviour in react tailwindcss datepicker
- Add shortcutClassName property HOT 1
- Hide/show year feature
- Selected date background is not showing. HOT 1
- fix for inside of accordion
- DatePicker won't reset on reset button press within an html form
- Support typical input field aspects such as tabIndex
- Add support for date localization
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-tailwindcss-datepicker.