Skip to main content
/
/
/
Inline

Inline

Place, stretch and separate inline elements

ReactCSS
import Inline from "@intility/bifrost-react/Inline";
Props

Inline layout

By default, child elements of <Inline> will be displayed top-aligned to the left, with a 12px gap.

Elements will wrap to next line if there's not enough room on one line.

TSX
<Inline>[Elements]</Inline>
Element
Element

Custom gap

Use the gap property to set custom spacing, accepts a number in px or a CSS length string.

TSX
<Inline gap={40}>
Element
Element

Vertical alignment

When you have elements with differing heights, the default behaviour is to align them to the top.

Element
with
multiple
lines
Top (default)

Use the align prop to align items to bottom, center, or top (default).

TSX
<Inline align="center" />
Element
with
multiple
lines
Center
TSX
<Inline align="bottom" />
Element
with
multiple
lines
Bottom

Inline.Separator

The <Inline.Separator /> component will push elements away from it.

TSX
<Inline>
  <div>...</div>
  <Inline.Separator />
  <div>Will be pushed to the right</div>
</Inline>

Split

Placed between elements will push them to each side.

Element
Element
Element
Element
Element
Element
Element
Element

Three-way split

Having multiple separators will create equal spaces.

Element
Element
Element

Right-aligned

A separator placed as first child will push siblings to the right.

Element
Element

Inline.Stretch

Wrapping an element in <Inline.Stretch> will stretch it to fill available space.

TSX
<Inline>
  <Inline.Stretch>
    <div>Element in Stretch</div>
  </Inline.Stretch>
  <div>Element</div>
</Inline>
Element in Stretch
Element
Element
Element in Stretch
Element
Element in Stretch
Element
Element in Stretch
Element in Stretch
Element in Stretch

Avoid extra DOM node

Using <Inline.Stretch> introduces an extra element in the document tree. If you want to avoid this you can use the .bfl-inline-stretch CSS class instead:

TSX
<Inline>
  <div className="bfl-inline-stretch">Element with .bfl-inline-stretch</div>
  <div>Element</div>
</Inline>
Element with .bfl-inline-stretch
Element

Responsive layout

The <Inline> component will attempt to wrap elements if there isn't enough width which is not ideal in most cases.

Instead, using our breakpoint CSS classes you can have different layouts displayed for certain screen widths.

Let's say you have three buttons, which should be stacked on top of eachother in a Grid for the smallest screens (up to small breakpoint, 600px screen width), but Inline for wider screens.

Resize your window (to below 600px width) to see it in action:

TSX
<Grid className='to-small'>
  <Button>Button in Grid</Button>
  <Button>Button in Grid</Button>
  <Button>Button in Grid</Button>
</Grid>
<Inline className='from-small'>
  <Button>Inline Button</Button>
  <Button>Inline Button</Button>
  <Button>Inline Button</Button>
</Inline>

More examples

Buttons

Input and button

Labelled inputs are taller than a button, so lets align='bottom' them.

Checkboxes