i'm learning material-ui by making the right navigation menu like this one: http://demo.geekslabs.com/materialize/v3.1/ or least like this: http://www.material-ui.com/#/components/app-bar
I'm using Drawer to make my sidebar, the problem is when the sidebar is toggled, it hides the content on the right. I want when my sidebar is toggled, it took place and push the content to the right and both sidebar and content got their own scrollbar. Here is my current code:
Sidebar.js:
import React from 'react';
import lightBaseTheme from 'material-ui/styles/baseThemes/lightBaseTheme';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import getMuiTheme from 'material-ui/styles/getMuiTheme';
import Drawer from 'material-ui/Drawer';
import MenuItem from 'material-ui/MenuItem';
import RaisedButton from 'material-ui/RaisedButton';
import AppBar from 'material-ui/AppBar';
export default class Sidebar extends React.Component {
constructor(props) {
super(props);
this.state = {open: false};
}
handleToggle = () => this.setState({open: !this.state.open});
handleClose = () => this.setState({open: false});
render() {
return (
<MuiThemeProvider muiTheme={getMuiTheme(lightBaseTheme)}>
<div>
<RaisedButton
label="Open Drawer"
onTouchTap={this.handleToggle}
/>
<Drawer
containerStyle={{height: 'calc(100% - 64px)', top: 64}}
docked={true}
width={200}
open={this.state.open}
onRequestChange={(open) => this.setState({open})
}
>
<AppBar title="AppBar" />
<MenuItem onTouchTap={this.handleClose}>Menu Item</MenuItem>
<MenuItem onTouchTap={this.handleClose}>Menu Item 2</MenuItem>
</Drawer>
</div>
</MuiThemeProvider>
);
}
}
My Layout.js:
import React, { PropTypes } from 'react';
import withStyles from 'isomorphic-style-loader/lib/withStyles';
import s from './Layout.css';
import Header from '../Header';
import Feedback from '../Feedback';
import Footer from '../Footer';
import Sidebar from '../Sidebar';
import lightBaseTheme from 'material-ui/styles/baseThemes/lightBaseTheme';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import getMuiTheme from 'material-ui/styles/getMuiTheme';
import AppBar from 'material-ui/AppBar';
import injectTapEventPlugin from 'react-tap-event-plugin';
injectTapEventPlugin();
function Layout({ children }) {
return (
<div>
<MuiThemeProvider muiTheme={getMuiTheme(lightBaseTheme)}>
<AppBar title="My web" />
</MuiThemeProvider>
<Sidebar/>
{React.Children.only(children)}
<Feedback />
<Footer />
</div>
);
}
Layout.propTypes = {
children: PropTypes.element.isRequired,
};
export default withStyles(s)(Layout);
The official Twitter app is receiving a Material Design makeover. The update is a server-side switch, so keep an eye out for the new UI. A member of XDA Developers has uploaded a video showcasing a new build of the official Twitter app, complete with a Material Design makeover.
This can be accomplished with the new version of Material-UI.
Check this demos out.
The behavior is described in the Material specification under the "Persistent" heading.
The mentioned version of Material-UI is v1.0.0-beta.38
. So far I noticed it very stable.
This is by design. "Material Design", that is :)
https://material.io/archive/guidelines/patterns/navigation-drawer.html
What you're asking for would no longer be a drawer, as described by the Material Design spec. Material-ui attempts to follow that spec faithfully.
You will probably have to create your own component, because I don't think you'll be able to sufficiently manipulate the markup and inline CSS rendered by the Drawer component to accomplish what you're looking for.
I'm not sure if Material Design has changed since this was posted but I think OP is describing "Persistent" Drawer which is defined in the spec. Look under "Behavior". However, material-ui doesn't provide a persistent drawer.
Here's a decent work around using the current material-ui drawer by pushing the content to the right the same width as the drawer.
How to get Material-UI Drawer to 'squeeze' other content when open
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With