docs/developer_docs/components/design-system/flex.mdx
import { StoryWithControls } from '../../../src/components/StorybookWrapper';
The Flex component from Superset's UI library.
<StoryWithControls component="Flex" props={{ vertical: false, wrap: "nowrap", justify: "normal", align: "normal", flex: "normal", gap: "small" }} controls={[ { name: "vertical", label: "Vertical", type: "boolean" }, { name: "wrap", label: "Wrap", type: "select", options: [ "nowrap", "wrap", "wrap-reverse" ] }, { name: "justify", label: "Justify", type: "select", options: [ "start", "center", "space-between", "space-around", "space-evenly" ] }, { name: "align", label: "Align", type: "select", options: [ "start", "center", "end", "stretch" ] }, { name: "flex", label: "Flex", type: "string" }, { name: "gap", label: "Gap", type: "select", options: [ "small", "medium", "large" ] } ]} sampleChildren={["Item 1","Item 2","Item 3","Item 4","Item 5"]} sampleChildrenStyle={{padding:"8px 16px",background:"#e6f4ff",border:"1px solid #91caff",borderRadius:"4px"}} />
Edit the code below to experiment with the component:
function Demo() {
return (
<Flex gap="small" wrap="wrap">
{['Item 1', 'Item 2', 'Item 3', 'Item 4', 'Item 5'].map(item => (
<div
key={item}
style={{
padding: '8px 16px',
background: '#e6f4ff',
border: '1px solid #91caff',
borderRadius: 4,
}}
>
{item}
</div>
))}
</Flex>
);
}
function VerticalFlex() {
return (
<Flex vertical gap="small">
<Button buttonStyle="primary">Primary</Button>
<Button buttonStyle="dashed">Dashed</Button>
<Button buttonStyle="link">Link</Button>
</Flex>
);
}
function JustifyAlign() {
const boxStyle = {
width: '100%',
height: 120,
borderRadius: 6,
border: '1px solid #40a9ff',
};
const itemStyle = {
width: 60,
height: 40,
backgroundColor: '#1677ff',
borderRadius: 4,
};
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
{['flex-start', 'center', 'flex-end', 'space-between', 'space-around'].map(justify => (
<div key={justify}>
<span style={{ marginBottom: 4, display: 'block', color: '#666' }}>{justify}</span>
<Flex style={boxStyle} justify={justify} align="center">
<div style={itemStyle} />
<div style={itemStyle} />
<div style={itemStyle} />
</Flex>
</div>
))}
</div>
);
}
| Prop | Type | Default | Description |
|---|---|---|---|
vertical | boolean | false | - |
wrap | string | "nowrap" | - |
justify | string | "normal" | - |
align | string | "normal" | - |
flex | string | "normal" | - |
gap | string | "small" | - |
import { Flex } from '@superset/components';
:::tip[Improve this page] This documentation is auto-generated from the component's Storybook story. Help improve it by editing the story file. :::