I'm currently working with Material UI v5 and facing a challenge in creating a responsive drawer. I want the drawer to occupy 100% of the screen width on smaller devices, while taking up only 1/3 of the screen width on larger devices. Unfortunately, I am struggling to figure out how to access the Paper property to adjust the width dynamically based on device size.
Here is my code snippet:
import { Drawer, styled } from "@mui/material";
const ResponsiveDrawer = styled(Drawer)(({ theme }) => ({
[theme.breakpoints.up("md")]: {
width: "33%", // THIS ONLY CHANGES DRAWER WIDTH NOT PAPER WIDTH INSIDE THE DRAWER
},
[theme.breakpoints.down("md")]: {
width: "100%",
},
}));
export { ResponsiveDrawer };
This is how I implement it:
import { ResponsiveDrawer } from "./Style";
<ResponsiveDrawer
anchor="right"
open={drawer.state}
onClose={() => drawer.onClick(false)}
>
...
</ResponsiveDrawer>