Box

Offers a universal building block for layouts.

Box

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>

Props

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.
idstringSet id for Box
displayenumThe display of the Box
paddingspacingObject | spacingTokenThe padding of the Box
marginspacingObject | spacingTokenThe margin of the Box
wrapenumThe flex-wrap of the Box
shrinknumberThe flex-shrink of the Box
grownumberThe 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
zIndexnumberThe z-index 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.

Media Queries

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
shrinknumberThe flex-shrink of the Box
grownumberThe 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

enum

displayjustifydirectionalignwrapwidthheight
"none""start""row""start""nowrap""full""full"
"flex""end""column""end""wrap""auto""auto"
"inline-flex""center""row-reverse""center"stringstring
"block""between""column-reverse""stretch"
"inline""around"
"inline-block"
"list-item"

position

position
"relative"
"absolute"
"fixed"

textAlign

textAlign
"start"
"end"
"left"
"center"
"right"

borderRadius

borderRadius
"small"
"normal"
"large"
"circle"

overflow

overflow
"auto"
"hidden"
"scroll"
"visible"

elevation

elevation
"action"
"fixed"
"overlay"
"raised"

spacingObject

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

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