How to open and close material navigation drawer in react - reactjs

I followed this tutorial (Full code on github) and implemented the material drawer. Now I can't close the drawer or open it with something like a function. How can I do it?
also the drawer is not swapping.
How I can access to Drawer object inside my webpage (DOM)? And change it's state such open = false.
Sorry for my questions I'm very new to react.
<Drawer
variant="temporary"
anchor="right"
open={true}
>
<List>
<ListItem>
first text
</ListItem>
<ListItem>
b
</ListItem>
</List>
</Drawer>
I want to have a menu icon on top right of my page and when the user clicks on it a modal navigation drawer will display.

there are many examples here in material-ui docs of how to use Drawers. check this out

Related

How to make Drawer to overlap on everything and not shrink everything beside?

Using Material UI, I'm using a Drawer menu, which right now is pushing everything beside when opened, and pulling them back when closed, but I want to make it to overlap onto everything and not to move any other thing in the screen, this is my current Drawer;
<Drawer
variant={isSmallScreen ? 'persistent' : 'permanent'}>
<div>
<IconButton />
</div>
<List>
<ListItem>
something
</ListItem>
<ListItem>
something 2
</ListItem>
</List>
</Drawer>

Hoe to load different pages in area of Dashboard in React.js using MUI?

I have created a React app and just put the component as they said in the link https://mui.com/material-ui/getting-started/templates/.
From this link, I got a beautiful redeemed UI of Dashboard. Now I want to add my custom menu in the sidebar but I'm not getting that, how could I manage it.
Question is: When I click from side menu, How could I either load my content in middle area of page? or How could I negigate user to that page?
<ListItemButton>
<ListItemIcon>
<FilterListIcon />
</ListItemIcon>
<ListItemText primary="Category" />
</ListItemButton>

React Material Ui responsive drawer

I created a responsive navigation bar using the React material UI Appbar component.
If the screen size is large, it shows tabs in the navigation bar. If the screen size is medium or smaller, it uses material UI responsive drawer to show the navigation bar (home, about, etc) on the left side right below the navigation bar. How can I move the responsive material UI drawer to the right?
https://material-ui.com/components/drawers/#responsive-drawer
You can use the available anchor prop (read more here).
anchor='right'
<Drawer
container={container}
variant="temporary"
anchor='right'
open={mobileOpen}
onClose={handleDrawerToggle}
classes={{
paper: classes.drawerPaper,
}}
ModalProps={{
keepMounted: true, // Better open performance on mobile.
}}
>
{drawer}
</Drawer>
You can view the codesandbox here

Why ant design Drawer not showing close icon?

This piece of code not showing any close icon in the ant design Drawer.
<Drawer
title="Job ID: 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"
placement="right"
closable={false}
onClose={onJobDetailsDrawerClose}
visible={jobDetailsDrawervisible}
width="75%"
closeIcon={<CloseOutlined />}
>
But the drawer API showed this:
Any idea why the Drawer not showing up any close icon?
Appears the close icon is hidden when you specify
closable={false}
Drawer API - closable
Whether a close (x) button is visible on top right of the Drawer
dialog or not.
With this prop set to false the drawer is toggleable externally.

React / Material UI complex styling

I have an issue related with styling in React / Material UI. I think is an issue related with TouchRipple from Material-UI
<div key={indexP}>
<Link className={classes.link} to={parent.link}>
<ListItem button selected={this.state.treeParentOpen[indexP] === true} onClick={this.handleClick(indexP)}>
<ListItemIcon>
<ParentIcon />
</ListItemIcon>
<ListItemText primary={parent.title} />
</ListItem>
</Link>
<Divider />
</div>
I have the above code inside a Drawer component (this is a small extract just to exemplify), for a Sidebar menu.
The issue i am having is related with the styling interaction of the ListItem and Link Components.
If i take the Link out of the code i have a normal ListItemripple behaviour (onclick and offclick), everything is pretty and in grey shades.
When i had the Link to the code (as is), the ripple behaviour of the ListItem changes and onClick is Blue and offClick purple. How should i address the styling of the ripple effect associated with buttonBase used in ListItem.
Thanks!

Categories

Resources