To add the Inline
component to your app:
1 2import { Inline } from '@forge/react';
An inline manages the horizontal layout of direct children using flexbox.
Name | Type | Required | Description |
---|---|---|---|
alignBlock | "start" | "center" | "end" | "baseline" | "stretch" | No | Used to align children along the main axis. |
alignInline | "start" | "center" | "end" | "stretch" | No | Used to align children along the cross axis. |
spread | "space-between" | No | Used to distribute the children along the main axis. |
space | "space.0" | "space.025" | "space.050" | "space.075" | "space.100" | "space.150" | "space.200" | "space.300" | "space.400" | "space.500" | "space.600" | "space.800" | "space.1000" | No | Represents the space between each child. |
shouldWrap | boolean | No | Used to set whether children are forced onto one line or will wrap onto multiple lines. |
separator | string | No | Renders a separator string between each child. |
rowSpace | "space.0" | "space.025" | "space.050" | "space.075" | "space.100" | "space.150" | "space.200" | "space.300" | "space.400" | "space.500" | "space.600" | "space.800" | "space.1000" | No | Represents the space between rows when content wraps. Used to override the space value in between rows. |
The following example uses this ExampleBox
component in their code blocks.
1 2const ExampleBox = () => { return ( <Box xcss={{ backgroundColor: 'color.background.discovery', borderRadius: 'border.radius', borderStyle: 'solid', borderWidth: 'border.width', borderColor: 'color.border.discovery', padding: 'space.200' }} /> ) }
Use an inline component to configure the layout of a group of elements horizontally. Use the given props to configure display behavior using design tokens, as shown in the more complex examples below.
1 2const InlineExample = () => { return ( <Inline> <ExampleBox /> <ExampleBox /> <ExampleBox /> </Inline> ); }
Control the spacing between items with the space
prop.
1 2const InlineSpaceExample = () => { return ( <Inline space="space.200"> <ExampleBox /> <ExampleBox /> <ExampleBox /> </Inline> ); }
When content is set to wrap, the space
prop applies equal spacing between rows. For a different space value between rows use the rowSpace
prop.
1 2const InlineRowSpaceExample = () => { return ( <Box xcss={{ width: "200px" }}> <Inline space="space.100" rowSpace="space.300" shouldWrap> <ExampleBox /> <ExampleBox /> <ExampleBox /> <ExampleBox /> <ExampleBox /> <ExampleBox /> </Inline> </Box> ) }
To control the alignment of items you can use the alignBlock
props which control alignment in the vertical axis respectively.
1 2const LongBox= () => { return ( <Box xcss={{ backgroundColor: 'color.background.discovery', borderRadius: 'border.radius', borderStyle: 'solid', borderWidth: 'border.width', borderColor: 'color.border.discovery', padding: 'space.200', height: '80px' }} /> )} const InlineStartBlock = () => { return ( <Inline space="space.050" alignBlock="start"> <ExampleBox /> <ExampleBox /> <LongBox/> </Inline> ); } const InlineCenterBlock = () => { return ( <Inline space="space.050" alignBlock="center"> <LongBox/> <ExampleBox /> <ExampleBox /> </Inline> ); } const InlineEndBlock = () => { return ( <Inline space="space.050" alignBlock="end"> <LongBox/> <ExampleBox /> <ExampleBox /> </Inline> ); } const InlineBaselineBlock = () => { return ( <Box xcss={{height: '100px'}}> <Inline space="space.050" alignBlock="baseline"> <LongBox/> <ExampleBox /> <ExampleBox /> </Inline> </Box> ); } const InlineStretchBlock = () => { return ( <Inline space="space.050" alignBlock="stretch"> <LongBox/> <ExampleBox /> <ExampleBox /> </Inline> ); }
To control the alignment of items you can use the alignInline
props which control alignment in the horizontal axis.
1 2const InlineStartInline = () => { return ( <Inline space="space.050" alignInline="start"> <ExampleBox /> <ExampleBox /> <ExampleBox /> </Inline> ); } const InlineCenterInline = () => { return ( <Inline space="space.050" alignInline="center"> <ExampleBox /> <ExampleBox /> <ExampleBox /> </Inline> ); } const InlineEndInline = () => { return ( <Inline space="space.050" alignInline="end"> <ExampleBox /> <ExampleBox /> <ExampleBox /> </Inline> ); }
Elements can be set to stay together, spaced at the given value (default behavior) or spread equally in the space available.
1 2const InlineSpreadExample = () => { return ( <Inline spread='space-between'> <ExampleBox /> <ExampleBox /> <ExampleBox /> </Inline> ); }
When the number of items goes beyond the available space, use shouldWrap
to create new rows of content.
1 2const InlineWrapExample = () => { return ( <Box xcss={{ width: "200px" }}> <Inline space="space.100" shouldWrap> <ExampleBox /> <ExampleBox /> <ExampleBox /> <ExampleBox /> <ExampleBox /> <ExampleBox /> </Inline> </Box> ); }
For logically related elements it's possible to specify a separator
character value.
1 2const InlineSeparatorExample = () => { return ( <Inline space="space.100" separator="•"> <ExampleBox /> <ExampleBox /> <ExampleBox /> <ExampleBox /> <ExampleBox /> </Inline> ); }
Rate this page: