Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React material-ui responsive layout

I am trying to use material-ui in my React application. The components are great, but it doesn't seem like they were designed to be responsive. For example, I'm trying to implement the Drawer component in my home page like this:

        <div>
            <AppBar
                title="My App"
                iconClassNameRight="muidocs-icon-navigation-expand-more"
                onLeftIconButtonTouchTap={this.handleToggle}
            />
            <TextField
                hintText="Hint goes here"
                floatingLabelText="Enter your Note here..."
                multiLine={true}
                fullWidth={true}
                rows={2}
            />
            <Drawer
                docked={false}
                open={this.state.open}
                onRequestChange={(open) => this.setState({open})}
            >
                <MenuItem>One</MenuItem >
                <MenuItem>Two</MenuItem >
            </Drawer>
        </div>
    );

When I load this up on my phone, it doesn't adjust it's size as I had hoped. Is there any way to make this responsive using only material-ui? If not, is there any way I can use Bootstrap or some other package for responsiveness?

Thanks, -Jim

like image 571
jbambrough Avatar asked Jul 12 '17 21:07

jbambrough


People also ask

Is material UI grid responsive?

The responsive UI in Material-UI is based on a 12-column grid layout. To understand this better, imagine the website you are looking at is split into 12 even columns. The number you pass will set the Grid to take up that many columns in the breakpoint width.


1 Answers

I made a complete example for it and it is totally responsive here in codesandbox

you should put your main pages on a box like this :

   <Box
            component="main"
            sx={{ flexGrow: 1 }}
            className={classes.content}
            style={{ width: "calc(100% - 240px)" }}
          >
<TextField
                hintText="Hint goes here"
                floatingLabelText="Enter your Note here..."
                multiLine={true}
                fullWidth={true}
                rows={2}
            />
</Box>

this topic is bigger than I could write all code here.

enter image description here

enter image description here

like image 70
Samira Avatar answered Oct 22 '22 10:10

Samira