@elemental-ui-alpha/box
v0.0.2
Published
The box primitive allows consumers to implement aesthetic changes within the constraints of the theme.
Readme
Box
import { Box } from '@elemental-ui-alpha/box';Style Props
Background / Foreground
Target the background color and foreground color:
<Box background="shade" foreground="accent">
accent
</Box>Padding
The padding keys allow targeting each side as well as the x-axis and y-axis.
paddingpaddingToppaddingRightpaddingBottompaddingLeftpaddingXpadding-left and padding-rightpaddingYpadding-top and padding-bottom
<Box padding="medium" background="shade">
padding
</Box>Margin
The margin keys allow targeting each side as well as the x-axis and y-axis.
marginmarginTopmarginRightmarginBottommarginLeftmarginXmargin-left and margin-rightmarginYmargin-top and margin-bottom
<Box margin="medium" background="shade">
margin
</Box>Rounding
The rounding keys allow targeting each box side.
roundingborder-radiusroundingBottomborder-bottom-left-radius and border-bottom-right-radiusroundingLeftborder-bottom-left-radius and border-top-left-radiusroundingRightborder-bottom-right-radius and border-top-right-radiusroundingTopborder-bottom-left-radius and border-bottom-right-radius
The rounding values don't follow the traditional t-shirt sizes.
nonesmallmediumlarge
<Box rounding="small" background="shade">
rounding
</Box>Text Align
Align the text within a box:
textAligntext-align CSS property
The available values match the CSS property:
leftrightcenterjustifystartend
<Box textAlign="center" padding="small" background="shade">
centered text
</Box>Height
Set the height of a box:
heightheight CSS property
<Box height={100} background="shade">
100px tall
</Box>Width
Set the width of a box:
widthwidth CSS property
<Box width={200} background="shade">
200px wide
</Box>Combined
Mix and match style properties to achieve the desired aesthetic.
<Box
background="shade"
foreground="action"
paddingX="large"
paddingY="medium"
margin="small"
rounding="small"
width={200}
>
combined
</Box>Responsive Props
Instead of manually managing media queries and adding nested style objects throughout a code base, we offer a convenient shorthand syntax for adding responsive styles with a mobile-first approach.
Each of the above style props accepts a value or array of values. To skip
certain breakpoints, you can pass null to any position in the array to avoid
generating unnecessary CSS.
While this approach has been widely adopted with great success, much like any new idea, it can seem odd or off-putting at first. We recommend giving it a chance.
<Box background="shade" padding={['small', null, 'medium', 'none', 'large']}>
responsive props
</Box>