Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to order inputs horizontally within ArrayImput and SimpleFormIterator

Tags:

react-admin

Is it possible to order inputs horizontally within ArrayImput and SimpleFormIterator? I know that the default is vertical. Thanks

See image of vertical inputs inside ArrayInputs here. Can the inputs be arranged horizontally? Thanks

enter image description here

like image 673
Olumide Omolayo Avatar asked Dec 19 '25 12:12

Olumide Omolayo


2 Answers

Yes you can, the ArrayInput is made using material-ui which comes with its style way. For instance, you can play with elements root, form etc...

const useIteratorStyle = makeStyles(() => ({
  root: {
    display: 'flex',
    flexDirection: 'row',
  },
  form: {
    width: '100%',
  },
  line: {
    border: 0,
  },
}));

const iteratorClasses = useIteratorStyle();

<ArrayInput {...props}>
  <SimpleFormIterator classes={iteratorWithIndexClasses}>
  ...
  </SimpleFormIterator>
</ArrayInput>

Gives me something like

enter image description here

You can override each property of the useStyles object defined in the SimpleFormIterator: https://github.com/marmelab/react-admin/blob/master/packages/ra-ui-materialui/src/form/SimpleFormIterator.tsx

like image 118
Striped Avatar answered Dec 22 '25 12:12

Striped


Inline prop has been introduced in version 4.3. It should work like that

<ArrayInput {...props}>
 <SimpleFormIterator inline>
 ...
 </SimpleFormIterator>
</ArrayInput>
like image 32
Mohamed Sayed Avatar answered Dec 22 '25 11:12

Mohamed Sayed



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!