Creating a responsive card design with Material UI

Creating a responsive card layout for mobile applications is my current challenge

  const styles = {
  edit: {
    width: "40%",
    marginLeft: 270,
    background: "#76ff03"
  },
  add: {
    width: "100%",
    background: "#18ffff",
    size: "large"
  },
  root: {
    minHeight: 210,
    minWidth: 100
  }
};



 <Container maxWidth="md">
  {/*marginTop:15*/}
  <Typography component="div" style={{  borderColor:'#00c853' }}>
    {/*style={{  height: '30vh' }}*/}
    <Card style={styles.root}>
      <Typography variant="overline" color="secondary" style={{fontFamily:'Roboto',margin:10}}>
        All about your needs
      </Typography>
      <form onSubmit={this.validateItem} autoComplete='off'>
        <TextField id="outlined-full-width" label="Input" style={{  width:'90%',marginTop:30 ,marginLeft:40 }}
          placeholder="Add A Todo Item " margin="normal" InputLabelProps={{
                              shrink: true,
                          }} error={this.state.errorState} helperText={ this.state.errorState
          && "Item name can't be blank" } size="large" variant="outlined" value={newItem} onChange={handleInput} />
        <Grid container justify='center' alignContent='center'>
          <Grid item xs={12} md={6}>
            {buttonChange()}
          </Grid>
        </Grid>
      </form>
    </Card>
  </Typography>
</Container>
</div>

The code snippet represents the user interface design of the card component. My goal is to optimize it for mobile devices. However, the resulting interface does not behave as expected.

I need assistance in making the card and text field elements responsive across various screen sizes. Can you suggest a solution to achieve this?

Answer №1

Greetings and thank you for posing your inquiry,

If you wish to adjust the size of your card component, you can utilize the breakpoint [theme.breakpoints.down("(XS, sm,md, lg, xl,)")] with maxWidth set to 200.

Here is an example using the material UI Card component, including necessary imports like useTheme and useMediaQuery. I've also added a medium breakpoint within the useStyles function under classes.root. To learn more about "useMediaQuery," check out this link: https://material-ui.com/components/use-media-query/#usemediaquery

import { useTheme } from "@material-ui/styles";
import useMediaQuery from "@material-ui/core/useMediaQuery";

const useStyles = makeStyles(theme => ({
  root: {
    maxWidth: 345,
    [theme.breakpoints.down("md")] : {
    maxWidth: 200 
    }
  },
  media: {
    height: 140
  }
}));

const Card = () =>  {
  const classes = useStyles();
  const theme = useTheme();

  const matches = useMediaQuery(theme.breakpoints.up("sm"));
  return (
    <Card className={classes.root}>
      <CardActionArea>
        <CardMedia
          className={classes.media}
          title="Contemplative Reptile"
        />
        <CardContent>
          <Typography gutterBottom variant="h5" component="h2">
            Lizard
          </Typography>
          <Typography variant="body2" color="textSecondary" component="p">
            Lizards are a widespread group of squamate reptiles, with over 6,000 species, ranging across all continents except Antarctica
          </Typography>
        </CardContent>
      </CardActionArea>
      <CardActions>
        <Button size="small" color="primary">
          Share
        </Button>
        <Button size="small" color="primary">
          Learn More
        </Button>
      </CardActions>
    </Card>
  );
}

I hope this explanation proves beneficial.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Select multiple rows by checking the checkboxes and select a single row by clicking on it in the MUI DataGrid

I am currently utilizing the MUI DataGrid version 4 component. The desired functionalities are as follows: Allow multiple selections from the checkbox in the Data Grid (if the user selects multiple rows using the checkbox). Prevent multiple selections fr ...

What could be causing the bullet not to appear in Internet Explorer 6

It is visible in Firefox, but not in IE (specifically IE6). <style type="text/css"> li { list-style-type:disc; } </style> <div style="margin: 2px auto 15px; padding: 5px 0px; width: 480px; text-align: center;"> <ul style="margin: 0; ...

It appears that the size of the textlabel in the HTML is not responsive to

When working with my HTML code, I've encountered an issue where I am unable to modify the height and width of a label using CSS. However, I have found that I am able to adjust the top and left positioning. HTML: <div id="loginname"> <l ...

Create a stylish Bootstrap 3 modal featuring an image and convenient scroll bars

My dilemma is with a modal dialog containing an image of fixed width set at 1500px. I want the image to maintain this size and for scroll bars to appear on smaller screen sizes, allowing users to scroll through the entire image. Essentially, I need the mod ...

How to eliminate the arrow and cross icons that are displayed in a TextField with type=“time” in material-ui React

How can I remove the arrow and cross that appear on the right of material-ui react textField with type time when hovering or focusing? Link to Material-UI DatePickers.js demo https://i.stack.imgur.com/uyUyF.png ...

Vuetify's data table now displays the previous and next page buttons on the left side if the items-per-page option is hidden

I need help hiding the items-per-page choices in a table without affecting the next/previous functionality. To achieve this, I've set the following props: :footer-props="{ 'items-per-page-options':[10], &apo ...

To show the selected value in a radio button in a React JS Material UI design, simply click on the radio button to display the corresponding value

Exploring the world of React JS and Material UI design, I find myself in need of something similar to what's shown below. My goal is to have the value 1 displayed inside the selected radio button upon clicking it. So far, I've managed to implem ...

The div is not showing the image as expected

Having some trouble creating a slideshow within my angular application. Struggling to get the images to display in the html code. To tackle this, I decided to create a separate component specifically for the slideshow (carousel.component). In the main app ...

Customize Your Material UI Stepper with Unique Connector Colors for Each of the 4 Steps

Is it possible to use multiple connector colors with a different one at each step? For example, having the first connector be blue, the next green, then yellow, and finally red while maintaining the previous color. I've tried but all previous colors e ...

Update elements dynamically using JSX

I have an array called data.info that gets updated over time, and my goal is to replace placeholder rendered elements with another set of elements. The default state of app.js is as follows: return ( <Fragment> {data.info.map((index) =&g ...

Align text in a vertical manner within various containers

I'm encountering a puzzling issue with my side-by-side divs. I have different-size headers in each div, and I want the top header in each to be baseline aligned. Unfortunately, using vertical-align: baseline doesn't seem to work between the two d ...

Using CSS min-height: 100vh will ensure that the container has enough height to fill the entire viewport

Utilizing min-height: 100vh; in my inner call to action div placed on top of a background video has been mostly successful. However, I've encountered an issue where using 100vh with the absolutely positioned video seems to introduce an unwanted margin ...

Is there a way to gradually reveal an element as I scroll to a specific position?

If the window top position is about 100px from the bottom, I want to create a fading in/out effect for the element overlay. Check out this image Any ideas on how to achieve this? .section-card{ position: relative; height: 500px; line-heigh ...

CSS: The background color of the body is appearing correctly when viewed locally, but does not display on

I had been using the styles.css file with this body stanza: body { font: 18px Helvetica, sans-serif, Arial; color: #ffffff; background: url("../images/bg.jpg") center top repeat-x; background-size: cover; line-height: 20px ...

Differences in SVG rendering between Chrome and Firefox

I am eager to create a diagram on my website using SVG. To ensure the diagram is displayed in full screen, I am utilizing availHeight and availWidth to determine the client screen's height and width, then adjust the scaling accordingly. My current sc ...

Issue encountered while using Material-UI makeStyles: unable to access property 'down' due to being undefined

I'm currently in the process of developing my own website using Material-UI and I'm facing an issue with making it responsive. My goal is to hide an image on smaller screens by utilizing [theme.breakpoints.down('md')]. However, I keep e ...

Is there a specific HTML tag available to instruct the browser to cache my HTML and/or CSS files for future use?

Up to this point, my research has indicated that enabling JavaScript and CSS browser caching typically requires server side settings such as .htaccess. Is there any HTML tag or configuration within the HTML page or JavaScript that can instruct the browse ...

Adjusting image size within floating containers

I am working on a design with two floating divs, one on the left and one on the right, both nested within a main div. Each floating div contains an image that needs to be resized to the maximum size possible without differing sizes. This is what I curren ...

Opacity of background color only applies to the color

So, here's the scenario - I currently have a background that looks like this: background:url(../img/arrow_lch.png) right no-repeat #2e443a; The challenge I'm facing is how to decrease the opacity of only the background color (#2e443a). Any sugg ...

The graphic is displayed at a width of 50%

I am currently working on a FrontEnd project and implementing Bootstrap 3 for the grid system. Additionally, I am utilizing art direction with the picture element. However, I seem to be facing an issue with the images. Every time I include the following s ...