Concepts
OverviewCompositionTestingLayout
Aspect RatioBleedBoxCenterContainerDividerFlexFloatGridLink OverlayScrollableStackWrapComponents
AccordionAdmonitionAvatarButtonCheckboxComboboxConfirm ModalCTAModalDate PickerDialogFieldFieldsetFile UploaderIcon ButtonInputLoading StatesMenuNotificationsProgressPrompt ModalRadioRatingSelectSwitchTableTabsTagTextTextareaToggleTooltipUtilities
Feature FlagsForLocal StoragePortalShowsplitPropsThemeBox
The most abstract styling component in Cerberus on top of which all other Cerberus components are built.
1import { Box } from "styled-system/jsx";2
3const Demo = () => {4 return (5 <Box bgColor="page.surface.100" color="white" padding="4" width="full" >6 This is the Box7 </Box>8 )9}
Usage
The Box
component provides an easy way to write styles with ease. It provides
access to design tokens and an unmatched DX when writing responsive styles.
1import { Box } from "styled-system/jsx";
1<Box />
Examples
Shorthand
Use shorthand like bgColor
instead of backgroundColor
, m
instead of margin
, etc.
1import { Box } from "styled-system/jsx";2
3const Demo = () => {4 return (5 <Box6 bgColor="page.surface.100"7 color="page.text.100"8 m="md"9 p="md"10 w="full"11 >12 This is the Box13 </Box>14 )15}
Pseudo Props
Use pseudo props like _hover
to apply styles on hover, _focus
to apply
styles on focus, etc.
1import { Box } from "styled-system/jsx";2
3const Demo = () => {4 return (5 <Box bg="tomato" w="100%" p="4" color="white" _hover={{ bg: "green" }}>6 This is the Box7 </Box>8 )9}
Border
Use the border
and borderColor
prop to apply border styles.
1import { Box } from "styled-system/jsx";2
3const Demo = () => {4 return (5 <Box6 border="1px solid"7 borderColor="page.border.initial"8 color="page.text.100"9 p="4"10 >11 Box with a border12 </Box>13 )14}
As Prop
Use the asChild
prop to render a different component.
1import { Box } from "styled-system/jsx";2
3const Demo = () => {4 return (5 <Box asChild bgColor="page.surface.100" p="4">6 <section>This is a section rendered as a Box</section>7 </Box>8 )9}
Shadow
Use the boxShadow
or shadow
prop to apply shadow styles.
1import { Box } from "styled-system/jsx";2
3const Demo = () => {4 return (5 <Box6 bgColor="page.surface.100"7 color="page.text.100"8 p="4"9 rounded="md"10 shadow="md"11 >12 This is the Box with shadow13 </Box>14 )15}
Props
The Box
component supports all CSS properties as props, making it easy to
style elements.
On this page