Skip to main content

Flex

Flex is a layout component that allows you to create a FlexBox layout.

import { Flex } from "rizzui";

Default

The style of Flex component. The Flex gets the default style of the css flex property.

1

2

3

import { Flex, Box } from "rizzui";

export default function App() {
return (
<Flex justify="center" align="center">
<Box className="...">1</Box>
<Box className="...">2</Box>
<Box className="...">3</Box>
</Flex>
);
}

With Justify Content

The style of Flex component can be modified using the justify prop. The justify prop is used to change the position of flex items inside the flex box.

1

2

3

import { Flex, Box } from "rizzui";

export default function App() {
return (
<>
<Flex
justify="start" // "center" | "start" | "end" | "between" | "around" | "evenly" | "normal"
>
<Box className="...">
1
</Box>
<Box className="...">
2
</Box>
<Box className="ms-auto...">
3
</Box>
</Flex>
<>
);
}

With Align Items

The style of Flex component can be modified by using the align prop. The align prop is used to align the flex items inside the flex box.

1

2

3

import { Flex, Box } from "rizzui";

export default function App() {
return (
<>
<Flex
justify="center" // "center" | "start" | "end" | "between" | "around" | "evenly" | "normal"
align="center" // "center" | "start" | "end" | "baseline" | "stretch"
>
<Box className="...">
1
</Box>
<Box className="...">
2
</Box>
<Box className="...">
3
</Box>
</Flex>
<>
);
}

API Reference


Flex Props

Here is the API documentation of the Flex component. And the rest of the props are the same as the original html element. You can use props like id, title, onClick etc.

PropsTypeDescriptionDefault
asdiv or any html elementRender as"div"
childrenReact.ReactNodeAccepts everything React can render__
directionDirection TypeDefines the flex direction in a flex box"row"
justifyJustify TypeDefines the position of flex items inside flex box"start"
alignAlign TypeAligns the flex items"start"
gapGap TypeDefines the gap between columns in a grid"4"
classNamestringAdd custom classes to the component__

Direction Type

type DirectionType = "col" | "row" | "row-reverse" | "col-reverse";

Justify Type

type JustifyType =
| "center"
| "start"
| "end"
| "between"
| "around"
| "evenly"
| "normal";

Align Type

type AlignType = "center" | "start" | "end" | "baseline" | "stretch";

Gap Type

type GapType =
| "1"
| "2"
| "3"
| "4"
| "5"
| "6"
| "7"
| "8"
| "9"
| "10"
| "11"
| "12";