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 Center
component is designed to center and clamp its width at a predefined value.
You can also center the children and text alignment as well.
Some examples of where you might use a component:
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/center.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/center ## 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 { Center } from '@bedrock-layout/center' // or import { Center } from '@bedrock-layout/primitives' // For Solid.js import { Center } from '@bedrock-layout/solid'
Name | Description | Default | Control |
---|---|---|---|
centerChildren | boolean | - | |
centerText | boolean | - | |
as | unknown | "div" | |
style | unknown | {} | |
maxWidth | - | - |
The Center component will clamp the width at a defined maxWidth
and center itself in its context. Please note that the maxWidth
prop represents the max-width
of the children and not the
Center component itself.
// CSS // Using the predefined size constants <div data-br-center="maxWidth:sizeContent3"> <Component /> </div> // Or you can use a custom value directly <div data-br-center style={{ "--max-width": "60ch"}}> <Component /> </div> // React.js and Solid.js <Center maxWidth="60ch"> <Component /> </Center>
In the example shown below, the maxWidth
is set to 75%
of the parent component's width.
You can also center the children by adding a centerChildren
prop.
Note, This is deprecated and should be used with the stack component set to
align="center"
instead.
// CSS <div data-br-center='centerChildren'> <Component /> </div> // React.js and Solid.js <Center centerChildren> <Component /> </Center>
In the example shown below, the max width of the children is set to 75%.
You can also center the text by adding a centerText
prop.
// CSS <div data-br-center='centerText'> <Component /> </div> // React.js and Solid.js <Center centerText> <Component /> </Center>
In the example shown below, the max width of the children is set to 75% and the centerChildren prop is set to true.