Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Left alignment of Material-UI dialog buttons

I have three buttons in a Dialog like so:

enter image description here

The JSX is

        <DialogActions classes={{ root: this.props.classes.dialogActionsRoot }} >
          <Button classes={{ root: this.props.classes.buttonRoot }} size="small" onClick={() => this.props.handleDialogClose()} >
            Clear
          </Button>
          <Button classes={{ root: this.props.classes.buttonRoot }} size="small" onClick={() => this.props.handleDialogClose()} >
            Cancel
          </Button>
          <Button classes={{ root: this.props.classes.buttonRoot }} size="small" onClick={() => this.props.handleDialogClose(this.state.selectedValue)} >
            Select
          </Button>
        </DialogActions>

The 'buttonRoot' style simply determines the button coloring. How to I left align the 'Clear' button so it sits on the left? It seems the buttons are each in a div with a MuiDialogActions-action class.

like image 971
timbo Avatar asked Dec 08 '22 15:12

timbo


1 Answers

Just use divider element with flex: 1 0 0 CSS style:

<DialogActions>
  <Button>
    Left
  </Button>
  <Button>
    Buttons
  </Button>
  <div style={{flex: '1 0 0'}} />
  <Button>
    Right
  </Button>
  <Button>
    Buttons
  </Button>
</DialogActions>
like image 171
Mikhail Vladimirov Avatar answered Dec 10 '22 12:12

Mikhail Vladimirov