This is a React library that will add margins in between child elements, without adding margins to the outer edges of the children.
yarn add react-margin-between
or
npm install react-margin-between --save
See the example
folder for a full example.
Import the package:
import MarginBetween from 'react-margin-between';
Horizontal example:
<div style={{ display: 'flex', flexDirection: 'row' }}>
<MarginBetween marginHorizontal="1em">
<div>Child 1</div>
<div>Child 2</div>
<div>Child 3</div>
</MarginBetween>
</div>
Vertical example:
<div style={{ display: 'flex', flexDirection: 'column' }}>
<MarginBetween marginVertical="1em">
<div>Child 1</div>
<div>Child 2</div>
<div>Child 3</div>
</MarginBetween>
</div>
Screenshot of the example
project:
- Clone the project
- Run
yarn start
in the root directory - Run
yarn start
in theexample
directory - Changes made to the code should be reflected in realtime in the browser
- Run
yarn test
to run all the tests once the code changes are made