Comments (8)
Since @mightym is OK with the workaround and @mui/explore does not plan to add a className
I will close this now. Feel free to reopen if you have objections.
from mui-x.
Hey, @mightym đ
Thanks for bringing this up! We currently do not differentiate the past or future dates with css classes. I think it might be a good idea to add that in, and I will make sure to bring this up!
In the meantime, I think there might be a a somewhat hacky solution for styling the day slot conditionally with styled components. One of the props the DateRangePickerDay
receives is day
which is basically the value that it represent. You can use that to figure out whether the day you are styling is before or after the current date, and style it accordingly.
const StyledDay = styled(DateRangePickerDay)(({ day }) => {
// use the day to apply conditional styling
return {
// styles
};
});
And use it like this:
<DateRangePicker
slots={{ day: StyledDay }}
/>
Let me know if this helps đŠī¸
from mui-x.
@noraleonte thanks a lot for your reply. Yeah I'm basically using such a workaround for now.
from mui-x.
@mightym Could you provide a reproduction case for this? I would like to understand exactly what you are trying to achieve and provide more suitable solution for your problem đ
from mui-x.
@noraleonte Our Calendar Component basically needs to indicate visually between 3 Date Types -> Today (this is what the current MUI calendar already does), Days before Today, Days after Today. The last 2 can be achieved if you know either which is a past day or a future day. So that you can do something like this:
![Bildschirmfoto 2023-08-22 um 11 19 52](https://private-user-images.githubusercontent.com/11863/262302745-4dd405cc-b884-4980-acdc-d1b079aa708d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTQwNTAxNDUsIm5iZiI6MTcxNDA0OTg0NSwicGF0aCI6Ii8xMTg2My8yNjIzMDI3NDUtNGRkNDA1Y2MtYjg4NC00OTgwLWFjZGMtZDFiMDc5YWE3MDhkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA0MjUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNDI1VDEyNTcyNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWU5MWE1M2M1N2QzMzQ5ZGVlZWUyZTAwNDIxN2Y0ODU4YWU4Njc3M2QyMzQwZWQ5ODlhM2FhYmJiMDE1Y2ZiYjEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.4qQ3fZbCpzzw_BMCSsvLVsdcKEFPu8E_uHCUSoExeAo)
Which I'm currently doing like you proposed: If a day is older than today give the element a different styling. Which is fine.
I just wanted to point out that it might be helpful for other people if the past days or future days have by default a class which could be used for styling.
from mui-x.
Are your paste dates selectable?
My main concern here is that visually, what you are trying to achieve look a lot like a disabled date (which could be done using the disablePast
prop).
But if it's selectable, then the UX can be misleading.
from mui-x.
They are selectable. But maybe my usecase is too special. The purpose in my case is basically giving the user a quick overview what is in the past (not that important) and what is in the future. Don't bother yourself too much with it guys. The workaround works great in my case.
from mui-x.
We discussed it on Monday.
We will not add a className because it's too specific to be in everybody's bundle.
With the current API, the best solution for you is probably to use the theme style overrides if it's pure CSS (see https://codesandbox.io/s/date-and-time-pickers-forked-zp2j6l?file=/src/App.tsx) or the day
slot if you need deeper changes.
from mui-x.
Related Issues (20)
- [question] Am I able to provide multiple rules to the initialState sortModel for DataGridPro HOT 3
- DataGridPremium edit mode aggregate total not working
- [TimeClock] The value does not update when ending the drag outside of the clock container HOT 1
- [DataGrid] row's popup appears even when the row itself doesn't HOT 1
- [TreeView] If not all nodeId`s are different opening an item crashes the browser HOT 1
- [question] Deep Filtering in Master-Detail Data Grid using Main Toolbar HOT 8
- DatePicker and DateRangePicker don't always display value passed HOT 1
- [datagrid] Row grouping object field values HOT 7
- Datagrid Pro Y-axis dimension keeps changing when apply 'styled' HOT 2
- [pickers] "@mui/x-date-pickers" leads to build break on Node.js v21.0.0 HOT 10
- Replacement of the disableMaskedInput prop in DatePicker v6 HOT 17
- [DataGridPro] How to enable filtering up to seconds for datetime columns? HOT 3
- Datagrid filter deletion does not always delete the filter value
- Datagrid toolbar inconsistent default icon size HOT 1
- [datagrid] v7 API: update `GridColDef` methods signatures HOT 8
- [question] Is there a more well-supported way to modify the tree data grouping column cell content? HOT 2
- [datagrid] Average aggregation treats `undefined`/`null` values as zeros
- [datagrid] Size aggregation counts `undefined` values
- [DataGrid] graphic glitch when we change to next page with getRowHeight 'auto' HOT 1
- [pickers] referenceDate not working as expected HOT 12
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 mui-x.