Sorry, but you either have no stories or none are selected somehow.
If the problem persists, check the browser console, or the terminal you've run Storybook from.
The component failed to render properly, likely due to a configuration issue in Storybook. Here are some common causes and how you can address them:
The Inline
component is designed to create consistent spacing between elements of variable width
in the inline direction. Unlike the InlineCluster
component, the items in the Inline
component
will not wrap.
The Inline
component also allows you to specify one of the children to stretch to fill the
excess space. This is done using the stretch
prop. The stretch
prop can be set to all
for all
children to stretch, or a number to stretch a specific child. The stretch
prop can also be set to
start
or end
to stretch the first or last child respectively.
First, you must install @bedrock-layout/css
.
yarn add @bedrock-layout/css
Then, you can import the entire CSS or just the component's CSS in your project:
import "@bedrock-layout/css/lib/bedrock-layout.min.css"; // or import "@bedrock-layout/css/lib/components/inline.min.css";
Optionally, you can install the package for your framework of choice (React.js, Solid.js) using your favorite package manager CLI:
## For React.js yarn add @bedrock-layout/inline ## or yarn add @bedrock-layout/primitives ## For Solid.js yarn add @bedrock-layout/solid
Then import the component in your project:
// For React.js import { Inline } from '@bedrock-layout/inline' // or import { Inline } from '@bedrock-layout/primitives' // For Solid.js import { Inline } from '@bedrock-layout/solid'
Name | Description | Default | Control |
---|---|---|---|
gap | string | - | |
as | unknown | "div" | |
style | unknown | {} | |
gutter | - | - | |
justify | - | - | |
align | - | - | |
stretch | - | - | |
switchAt | Sets the width threshold that the split will switch to a Stack layout - | - | |
minItemWidth | - | - |
The gap
prop defines the gap size between elements.
Ultimately, the space is controlled by setting the --gap
CSS variable.
Bedrock has implemented a default spacing scheme,
but it can be overridden using the ThemeProvider provided by @bedrock-layout/spacing-constants
.
You can also use any valid CSSLength or positive integer.
// CSS // Using the predefined spacing constants <div data-br-inline='gap:size3'> <Component /> <Component /> </div> // Or you can use a custom value directly <div data-br-inline style={{ "--gap": "3ch" }}> <Component /> <Component /> </div> // React.js and Solid.js <Inline gap="size3"> <Component /> <Component /> </Inline> // Or you can use a css value directly <Inline gap="3ch"> <Component /> <Component /> </Inline> // or you can use a custom property <Inline gap="--custom-size-4"> <Component /> <Component /> </Inline>
Here are the possible values for gap
by default:
The justify
prop defines the inline justification of the
elements within the cluster. It accepts the following
values: start
, end
, center
, space-around
, space-between
.
// CSS <div data-br-inline='justify:end'> <Component /> <Component /> </div> // React.js and Solid.js <Inline justify="end"> <Component /> <Component /> </Inline>
The align
prop defines the vertical alignment of the
elements within the cluster. It accepts the following
values: start
, end
, center
, stretch
.
// CSS <div data-br-inline='align:end'> <Component /> <Component /> </div> // React.js and Solid.js <Inline align="end"> <Component /> <Component /> </Inline>
The stretch
prop can be used to specify a child component that
will stretch to fill the excess space.
// CSS <div data-br-inline='stretch:end'> <Component /> <Component /> </div> // React.js and Solid.js <Inline stretch="end"> <Component /> <Component /> </Inline>
The minItemWidth
prop defines the width basis of each of the children.
Some times you want all the items to have a minimum width. By setting the
minItemWidth
prop, you will set the minimum width of each of the children.
This is especially useful with the switchAt
prop (see below).
// CSS // Using the predefined size constants <div data-br-inline="minItemWidth:sizeXs"> <Component /> <Component /> </div> // Use the `--min-item-width` custom property <div data-br-inline style="--min-item-width: 30ch"> <Component /> <Component /> </div> // React.js and Solid.js <Inline minItemWidth="30ch"> <Component /> <Component /> </Inline>
In the below example, each of the Components has an intrinsic
width of 50px. The minItemWidth
will make them 150px
each.
(Resize window to observe the changes)
The switchAt
prop defines the width at which the layout will switch to stack.
// CSS // Using the predefined size constants <div data-br-inline="switchAt:sizeContent2"> <Component /> <Component /> </div> // use the `--switch-at` custom property <div data-br-inline style="--switch-at: 30ch"> <Component /> <Component /> </div> // React.js and Solid.js <Inline switchAt="30ch"> <Component /> <Component /> </Inline>
In the below example, the layout will switch to stack when
its width becomes less than 45rem
.
(Resize your window to see this in action.)
(Resize window to observe the changes)