trying to remove padding from the ul tag of the popup

时间:2018-11-16 21:45:41

标签: javascript html css reactjs material-ui

  • when I click chip chipName="button test IPA" a popup opens.
  • I am trying to remove padding from the ul tag of that popup.
  • but the problem is I am not able to find the ul tag in my html of jsx.
  • I gave className in the react code but still I am not able to target
  • can you please help me so that in future I will fix it myself.
  • providing code snippet below

https://codesandbox.io/s/qqqk23x3q

tab-demo.js

<td>
                    <ChipsButton
                      className={classes.chipContainer}
                      chipName="button test IPA"

                      // menuItems={IPAMenuItems}
                      //ChipsButton
                    />
                  </td>

              **chips-dialog.js**

                  <Menu
          className={classes.chipButtonContainer}
          id="simple-menu"
          // anchorEl={anchorEl}
          open={open}
          onClose={this.handleClose}
        >
          <MenuItem className={classes.chipButtonContainerHeader}>
            {this.state.menuText}
          </MenuItem>

          <Button
            className={classes.chipButtonContainerButton}
            key={1}
            style={{
              backgroundColor:
                this.state.menuText === "Active selected" ? "green" : ""
            }}
            // style={{ display: this.state.display ? "none" : "" }}
            // aria-owns={anchorEl ? 'simple-menu' : undefined}
            aria-haspopup="true"
            value={"Active"}
            onClick={this.handleSelect}
          >
            Active
          </Button>
          <Button
            key={2}
            style={{
              backgroundColor:
                this.state.menuText === "Inactive selected" ? "green" : ""
            }}
            value={"Inactive"}
            // style={{ display: this.state.display ? "none" : "" }}
            // aria-owns={anchorEl ? 'simple-menu' : undefined}
            aria-haspopup="true"
            onClick={this.handleSelect}
          >
            Inactive
          </Button>
        </Menu>


        const styles = theme => ({
  chipButtonContainer: {
    border: "1px solid brown",
    padding: "0"
  },
  chipButtonContainerHeader: {
    backgroundColor: "green",
    border: "1px solid pink"
  },
  chipButtonContainerButton: {
    border: "1px solid black"
  }
})

;

2 个答案:

答案 0 :(得分:1)

MenuListProps转发到基础List组件(由MenuList组成)以禁用应用于其的填充。

可以在chips-dialog.js

中进行此编辑
<Menu
   className={classes.chipButtonContainer}
   //...
   MenuListProps={{ disablePadding: true }}
   onClose={this.handleClose}
>
<!--...-->
</Menu>

答案 1 :(得分:0)

对于带有 <Select>MenuProps 组件的工作方式相同

<Select
    multiple
    input={<Input />}
    MenuProps={{
      MenuListProps: {
        disablePadding: true
    }}>
    {employees.map((employee) => (
    <MenuItem key={employee.id} value={employee.id}>
        {employee.name}
    </MenuItem>
    ))}
</Select>