Group
Compose elements and components in flex container
Import
Source
Docs
Package
Usage
Group allows you to compose any elements and components in flex container. Use these props to change elements position inside Group:
- position controls
justify-content
property - grow
flex-grow
property, items will never wrap to next line if set totrue
- spacing controls space between elements – predefined values from
theme.spacing
or number for spacing in px - noWrap controls
flex-wrap
property and if set to true prevents elements from wrapping on next line once space on current line was exceeded - direction controls
flex-direction
: row (default) for horizontal orientation, column for vertical - withGutter when true, adds padding (equal to
spacing
prop) to the root component, defaults tofalse
Direction
Spacing
<Group><Button variant="outline">1</Button><Button variant="outline">2</Button><Button variant="outline">3</Button></Group>
Group children
Group component uses className
prop to add styles,
child components must accept it otherwise unexpected negative margins will be applied the element:
// Will not work with Group – component does not handle classNameconst MyButton => ({ label }) => <button>{label}</button>// Will work with Group – handle classNameconst MyButton => ({ label, className }) => <button className={className}>{label}</button>// Will work with Group – handle classNameconst MyButton => ({ label, ...others }) => <button {...others}>{label}</button>
With divider
You can use Divider component to add additional visual separation and spacing:
Badge
Badge
Badge
<Group position="center"><Badge>Badge</Badge><Divider orientation="vertical" margins="sm" /><Badge>Badge</Badge><Divider orientation="vertical" margins="sm" /><Badge>Badge</Badge></Group>
Built by Vitaly Rtishchev and these awesome people