Home > front end >  How to prevent a group of buttons from wrapping in the mui?
How to prevent a group of buttons from wrapping in the mui?

Time:08-01

Excepted result: enter image description here

My code:

enter image description here enter image description here

<Box sx={{ display: "flex", justifyContent: "space-between", marginTop: 2, width: "100%", overflowX: "scroll" }}>
                <Button variant="outlined" size="small" endIcon={<KeyboardArrowDown />}>Departure at 21:37</Button>
                <Button variant="outlined" size="small" endIcon={<KeyboardArrowDown />}>The lowest cost</Button>
                <Button variant="outlined" size="small" endIcon={<KeyboardArrowDown />}>Options</Button>
</Box>

CodePudding user response:

You can use flex: none; on the buttons.

<Box
  sx={{
    display: "flex",
    justifyContent: "space-between",
    marginTop: 2,
    width: "100%",
    overflowX: "scroll",
    button: {
      flex: "none"
    }
  }}
>
  <Button variant="outlined" size="small" endIcon={<KeyboardArrowDown />}>
    Departure at 21:37
  </Button>
  <Button variant="outlined" size="small" endIcon={<KeyboardArrowDown />}>
    The lowest cost
  </Button>
  <Button variant="outlined" size="small" endIcon={<KeyboardArrowDown />}>
    Options
  </Button>
</Box>
  • Related