-
Notifications
You must be signed in to change notification settings - Fork 13.5k
feat: datetime, expose calendar grid buttons for styling #25340
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
I have the same problem... It's important for me to cutomize the component. |
Thanks for the issue. Can you help me understand the use case for each of the customizations you need as well as what you have tried already? Most of the customizations listed here can be achieved by modifying the Ionic theme. Here is an example: https://ionic-docs-okx99ne93-ionic1.vercel.app/docs/api/datetime#theming Datetime is a tricky component to open up for customization given how complex it is. As a result, we are trying to prioritize a consistent user experience. However, there are certainly areas that we should open up for more customization. |
@liamdebeasi try to change font size of the numbers or create day selector with custom color. Only can change the background-color but not the color of the number |
Thanks! It sounds like a majority of the styling needs here revolve around the buttons in the calendar grid. I think it makes sense to expose these buttons with potentially ways of styling based on state (selected, today, disabled, etc). One idea is to expose one or more CSS Shadow Parts. This will give developers the flexibility to apply any style to the individual buttons without disrupting the overall layout of the calendar grid. |
@liamdebeasi css shadow parts will be perfect solution. |
@liamdebeasi any updates on this feature request? |
I came here to request this exact feature! I need to display multiple date ranges each with it's own color and styling (for example, I style the first/last dates of the range differently from the dates in the middle). I currently use the Angular material datepicker for this feature (https://material.angular.io/components/datepicker/overview#datepicker-date-class). They utilize a "dateClass" method which runs for each individual date and applies a custom class based on whatever logic you want. The downside to their feature is that since it applies a class, I need to hard code the classes (unless there is a way to dynamically load css that I don't know about, which is very possible). It would be nicer if there were a way to apply either classes or styles to each date based on some logic. |
@liamdebeasi How do envision setting the CSS for a specific button's shadow parts? Adding a |
I'm having this issue, too. My specific use case is changing the border-radius of the circular highlight on the selected date(s) so that it's a rounded rectangle rather than a circle. Having shadow parts for this would work nicely. |
After working further with the datetime component, I too am needing to specify the font properties for the numbers in the grid (like font-size and font-weight). Again, shadow parts for the individual date buttons would work nicely for this. Also, could we have a shadow part or css property for changing the size of the chevrons we use to navigate to the next/previous month (in the upper-right corner)? Compared to the other buttons in my interface, these buttons are huge and I need a way to make them smaller. |
@liamdebeasi I think the simplest solution would be to add a |
Issue number: resolves #25340 --------- - Exposes the following parts for a calendar day: `calendar-day`, `today`, and `active` - Combines the `calendar-day-highlight` element with the `calendar-day` element so developers don't have to know to style two different elements & we don't have to expose them as separate parts - Improves height parity of the calendar day across browsers - Updates the `custom` e2e test to include an example of styling days using the newly exposed CSS parts - Adds tests for the focus states of the calendar day
Thank you for the issue! This has been resolved by 79b005d. It will be in the |
@brandyscarney Unless I'm missing something, this solution is global to the entire calendar, and does not allow us to style different days in different ways. |
The original request was to expose a way to style the days in the calendar grid. We also added a way to style the selected days as well as today's date. If you want to customize specific days (regardless of today/selected state) then the |
Unfortunately export type DatetimeHighlightStyle = {
textColor: string;
backgroundColor?: string;
} | {
textColor?: string;
backgroundColor: string;
}; No control over any other css properties! |
That's intentional. |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out. |
Prerequisites
Describe the Feature Request
This issue #24963 is closed but ion-datetime hasn't got properties to edit css #24963
In that issue there is one code pen -> https://codepen.io/liamdebeasi/pen/YzYWBgV but it's not possible to change all colors.
For example if i want this style with the text in one color (white) and background selected (green) it's not possible to customize
Font size, bold, or change disabled styles (for one days or more days) it's not possible
Describe the Use Case
Should allow to customize color, background color, font size, font weight, for all items (selected, unselected, disabled, selection arrows)
Describe Preferred Solution
No response
Describe Alternatives
No response
Related Code
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: