Concepts
OverviewCompositionTestingLayout
Aspect RatioBleedBoxCenterContainerDividerFlexFloatGridLink OverlayScrollableStackWrapComponents
AccordionAdmonitionAvatarButtonCheckboxComboboxConfirm ModalCTAModalDate PickerDialogFieldFieldsetFile UploaderIcon ButtonInputLoading StatesMenuNotificationsProgressPrompt ModalRadioRatingSelectSwitchTableTabsTagTextTextareaToggleTooltipUtilities
Feature FlagsForLocal StoragePortalShowsplitPropsTheme1import { Box, Center } from "styled-system/jsx";2
3const Demo = () => {4 return (5 <Center bg="page.surface.100" h="100px" maxW="320px">6 <Box>This will be centered</Box>7 </Center>8 )9}
Usage
1import { Center } from "styled-system/jsx";
1<Center bg="tomato" h="100px" color="white">2 This is the Center3</Center>
Examples
Icon
Center can be used to create frames around icons or numbers.
1import { Center, HStack } from "styled-system/jsx"2import { Text } from "@cerberus/react"3import { LuPhone } from "react-icons/lu"4
5const Demo = () => {6 return (7 <HStack>8 <Center w="40px" h="40px" bg="tomato" color="white">9 <LuPhone />10 </Center>11
12 <Center w="40px" h="40px" bg="tomato" color="white">13 <Text as="span" fontWeight="bold" fontSize="lg">14 115 </Text>16 </Center>17 </HStack>18 )19}
Center with Inline
Use the inline
to change the display to inline-flex
.
1import { Center } from "styled-system/jsx"2import { Text } from "@cerberus/react"3
4const Demo = () => {5 return (6 <Center inline bg="page.surface.100" h="100px" maxW="320px">7 <Text>This will be centered</Text>8 </Center>9 )10}
Square
Square
centers its child given the size
(width and height).
1import { Square } from "styled-system/jsx"2import { LuPhoneForwarded } from "react-icons/lu"3
4const Demo = () => {5 return (6 <Square size="10" bg="purple.700" color="white">7 <LuPhoneForwarded />8 </Square>9 )10}
Circle
Circle
centers its child given the size
and creates a circle around it.
1import { Circle } from "styled-system/jsx"2import { LuPhoneForwarded } from "react-icons/lu"3
4const Demo = () => {5 return (6 <Circle size="10" bg="purple.700" color="white">7 <LuPhoneForwarded />8 </Circle>9 )10}
Props
Center accepts CSS properties and the following specific props:
Prop | Type | Description |
---|---|---|
inline | boolean | Changes the display to inline-flex . |
size | string | Sets the width and height of the element. |
On this page