Box

Offers a universal building block for layouts.

To implement Box component into your project you’ll need to add the import:

import Box from "@kiwicom/orbit-components/lib/Box";

After adding import into your project you can use it simply like:

<Box>Hello World!</Box>

Table below contains all types of the props available in the Box component.

NameTypeDefaultDescription
asstring"div"Render as element.
classNamestringThe optional className of Box.
childrenReact.NodeThe children of the Box.
dataTeststringOptional prop for testing purposes.
displayenumThe display of the Box
paddingspacingObject | spacingTokenThe padding of the Box
marginspacingObject | spacingTokenThe margin of the Box
wrapenumThe flex-wrap of the Box
shrinkenumThe flex-shrink of the Box
growenumThe flex-grow of the Box
alignenumThe align-items of the Box
justifyenumThe justify-content of the Box
directionenumThe flex-direction of the Box
widthenumThe width of the Box
minWidthstringThe min-width of the Box
maxWidthstringThe max-width of the Box
heightenumThe height of the Box
maxHeightstringThe max-height of the Box
positionpositionThe position of the Box
leftstringThe left of the Box
topstringThe top of the Box
rightstringThe right of the Box
bottomstringThe bottom of the Box
textAligntextAlignThe text-align of the Box
elevationelevationThe box-shadow of the Box
colorstringThe color of the Box
backgroundstringThe background of the Box
borderRadiusborderRadiusThe border-radius of the Box
overflowoverflowThe overflow of the Box
largeDesktopMediaQueriesObject for setting up properties for the largeDesktop viewport.
desktopMediaQueriesObject for setting up properties for the desktop viewport.
tabletMediaQueriesObject for setting up properties for the tablet viewport.
largeMobileMediaQueriesObject for setting up properties for the largeMobile viewport.
mediumMobileMediaQueriesObject for setting up properties for the mediumMobile viewport.

When you need to specify some different behavior of the Box component on different viewport, you can use properties for it. There are mediumMobile, largeMobile, tablet, desktop and largeDesktop available and it behaves the same as mediaQueries functions. All this properties - objects have the some own properties and none is required.

NameTypeDefaultDescription
paddingspacingObject | spacingTokenThe padding of the Box
marginspacingObject | spacingTokenThe margin of the Box
wrapenumThe flex-wrap of the Box
shrinkenumThe flex-shrink of the Box
growenumThe flex-grow of the Box
alignenumThe align-items of the Box
justifyenumThe justify-content of the Box
directionenumThe flex-direction of the Box
widthenumThe width of the Box
maxWidthstringThe max-width of the Box
heightenumThe height of the Box
maxHeightstringThe max-height of the Box
positionpositionThe position of the Box
leftstringThe left of the Box
topstringThe top of the Box
rightstringThe right of the Box
bottomstringThe bottom of the Box
textAligntextAlignThe text-align of the Box
elevationelevationThe box-shadow of the Box
colorstringThe color of the Box
backgroundstringThe background of the Box
borderRadiusborderRadiusThe border-radius of the Box
overflowoverflowThe overflow of the Box
displayjustifydirectionalignwrapshrinkwidthheight
"none""start""row""start""nowrap"0"full""full"
"flex""end""column""end""wrap"1"auto""auto"
"inline-flex""center""row-reverse""center"
"block""between""column-reverse""stretch"
"inline""around"
"inline-block"
position
"relative"
"absolute"
"fixed"
textAlign
"left"
"center"
"right"
borderRadius
"small"
"normal"
"large"
"circle"
overflow
"auto"
"hidden"
"scroll"
"visible"
elevation
"action"
"fixed"
"overlay"
"raised"
keyvalue
"top"spacingToken
"right"spacingToken
"left"spacingToken
"bottom"spacingToken

If you want to define spacingObject, you can define specific directions like this: <Box margin={{ top: "XXSmall", bottom: "XXSmall" }} />

spacingToken
"none"
"XXXSmall"
"XXSmall"
"XSmall"
"small"
"medium"
"large"
"XLarge"
"XXLarge"
"XXXLarge"