Flex

Compose elements in a flex container
Import

Usage

Gap
xs
sm
md
lg
xl
import { Flex, Button } from '@mantine/core';
function Demo() {
return (
<Flex
mih={50}
bg="rgba(0, 0, 0, .3)"
gap="md"
justify="flex-start"
align="flex-start"
direction="row"
wrap="wrap"
>
<Button>Button 1</Button>
<Button>Button 2</Button>
<Button>Button 3</Button>
</Flex>
);
}

Supported props

PropCSS PropertyTheme key
gap
gap
theme.spacing
rowGap
rowGap
theme.spacing
columnGap
columnGap
theme.spacing
align
alignItems
justify
justifyContent
wrap
flexWrap
direction
flexDirection

Responsive props

Flex component props can have responsive values the same way as other style props:

import { Flex, Button } from '@mantine/core';
function Demo() {
return (
<Flex
direction={{ base: 'column', sm: 'row' }}
gap={{ base: 'sm', sm: 'lg' }}
justify={{ sm: 'center' }}
>
<Button>Button 1</Button>
<Button>Button 2</Button>
<Button>Button 3</Button>
</Flex>
);
}

Flex component props

NameTypeDescription
align
SystemProp<AlignItems>
align-items CSS property
columnGap
SystemProp<SpacingValue>
column-gap CSS property
direction
SystemProp<FlexDirection>
flex-direction CSS property
gap
SystemProp<SpacingValue>
gap CSS property
justify
SystemProp<JustifyContent>
justify-content CSS property
rowGap
SystemProp<SpacingValue>
row-gap CSS property
wrap
SystemProp<FlexWrap>
flex-wrap CSS property