Git Product home page Git Product logo

Comments (5)

LukasTy avatar LukasTy commented on June 2, 2024 1

Looks like using selected might lead others down the same confusion lane when they're styling the selected day.

Thank you for paying attention to this point. I agree that putting all the available classes in the list of styleOverrides is not ideal, because some of them will not work and produce a console error. 🙈
We'll investigate how this can be improved. 😉

But here's the scoop: the style only pops up when users click the date picker, as mentioned in the issue. :/

The issue is that you are styling the selected day, but there are additional styles for the focus state that you'd need to change. 🤔

'&:focus': {
backgroundColor: theme.vars
? `rgba(${theme.vars.palette.primary.mainChannel} / ${theme.vars.palette.action.focusOpacity})`
: alpha(theme.palette.primary.main, theme.palette.action.focusOpacity),
[`&.${pickersDayClasses.selected}`]: {
willChange: 'background-color',
backgroundColor: (theme.vars || theme).palette.primary.dark,
},
},

from mui-x.

michelengelen avatar michelengelen commented on June 2, 2024 1

@LukasTy I will add this to the board toi investigate the class issue.

from mui-x.

LukasTy avatar LukasTy commented on June 2, 2024

Hello @bernbecht, if you check the console, there is an error message there regarding the specificity issue and how to resolve it:
Screenshot 2024-04-23 at 13 52 25

Could you please try applying the following diff and see if that helps? 🤔

-selected: {
-  backgroundColor: "green",
-},
+root: {
+  "&.Mui-selected": {
+    backgroundColor: "green",
+  },
+},

P.S. Have you had the chance to check the customization playground in the docs?

from mui-x.

bernbecht avatar bernbecht commented on June 2, 2024

Hey @LukasTy, thanks for getting back to me! 👋

I gave your diff a shot, and now I can tweak the selected day with createTheme() ✨ Your heads up about the console was great!

But here's the scoop: the style only pops up when users click the date picker, as mentioned in the issue. :/

I leaned towards using the selected property in createTheme() because TypeScript nudged me with it as an option for MuiPickersDay styleOverrides. Peeking at interface PickersDayClasses, here's what I found:

// Snippet from @mui/x-date-pickers/PickersDay/pickersDayClasses.d.ts
export interface PickersDayClasses {
    /** Styles applied to the root element. */
    root: string;
    ...
    /** State class applied to the root element if `selected=true`. */
    selected: string;
    ...
}

Looks like using selected might lead others down the same confusion lane when they're styling the selected day.

P.S. Did you get a chance to peek at the customization playground in the docs?

Yep, already scoped it out! 🕵️‍♂️ Got a good grip on how to tweak those pickers. Cheers! 😄

from mui-x.

bernbecht avatar bernbecht commented on June 2, 2024

A part from the class issue, the styling is clear now :) Thank you

from mui-x.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.