Center

Centers content vertically and horizontally
Import

Usage

All elements inside Center are centered
import { Center } from '@mantine/core';
function Demo() {
return (
<Center maw={400} h={100} mx="auto">
<div>All elements inside Center are centered</div>
</Center>
);
}

Inline

To use center with inline elements set inline prop. For example, you can center link icon and label:

import { Center, Anchor, Box, rem } from '@mantine/core';
import { IconArrowLeft } from '@tabler/icons-react';
function Demo() {
return (
<Anchor href="https://mantine.dev" target="_blank">
<Center inline>
<IconArrowLeft size={rem(14)} />
<Box ml={5}>Back to Mantine website</Box>
</Center>
</Anchor>
);
}

Center component props

NameTypeDescription
children *
ReactNode
Content that should be centered vertically and horizontally
inline
boolean
Set to true to use inline-flex instead of flex