My React application consists of two components: Open
and Save
. The Save
component has a button labeled as saveButton
. On the other hand, the Open
component contains an openButton
, as well as a stopButton
and executeButton
that are conditionally displayed based on the component's state. I would like to display the Open
and Save
components side by side in one row:
<div style={{display:'flex', flexDirection:'row'}}>
<Save></Save>
<Open></Open>
</div>
Initially, the state appears as follows:
When all four buttons are visible, the state is as shown below:
It is worth mentioning that the Execute and Stop buttons are part of the same Open
component which also includes the Open button. How can I ensure that the Save/Open buttons are aligned to the left, while the Execute/Stop buttons are aligned to the right?
To provide further clarity, my desired button alignment is depicted below:
Save Open ------------all whitespace here--------------- Execute Stop
Update: Provided below is a simplified version of the code for these components:
// Save
<Button>Save</Button>
//Open
this.state = { executeFlag: false, stopFlag: false}
render(){
let stop;
let execute;
if(this.state.stopFlag) stopButton = <Button>Stop</Button>;
if(this.state.executeFlag) executeButton = <Button>Execute</Button>;
return(
<div>
<Button>Open</Button>{execute}{stop}
</div>
);
}