Box
The fundamental primitive component that includes styling utility properties, and corresponding design variables as values.
By default, it renders a div element.
Usage
Code
import { createSystem } from 'frog/ui'
const { Box } = createSystem()
function Example() {
return (
<Box
backgroundColor="rred100red200red300red400red500red600redred700red800red900red1000ed"
borderRadius="8"
height="48"
width="48"
/>
)
}
Style Properties
The Box component accepts Style Properties (ie. properties of a div style).
Below are some examples of the most common style properties that can be used with the Box component.
Layout
Box accepts the following layout style properties:
alignContentalignItemsalignSelfdisplayflexflexBasisflexDirectionflexShrinkflexWrapgapgrowjustifyContentoverflow
Code
import { createSystem } from 'frog/ui'
const { Box } = createSystem()
function Example() {
return (
<Box grow flexDirection="row" gap="8">
<Box backgroundColor="red" flex="1" />
<Box backgroundColor="red" flex="1" />
</Box>
)
}Alignment
Box accepts the following alignment style properties:
alignHorizontalalignVertical
Code
import { createSystem } from 'frog/ui'
const { Box } = createSystem()
function Example() {
return (
<Box
grow
alignHorizontal="center"
alignVertical="bottomtopcenterspace-betweencenter"
>
<Box backgroundColor="red" height="20" width="20" />
</Box>
)
}Borders
Box accepts the following border style properties:
borderBottomborderBottom{Color|LeftRadius|RightRadius|Style|Width}borderColorborderLeftborderLeft{Color|Style|Width}borderStyleborderRadiusborderRightborderRight{Color|Style|Width}borderTopborderTop{Color|LeftRadius|RightRadius|Style|Width}
Code
import { createSystem } from 'frog/ui'
const { Box } = createSystem()
function Example() {
return (
<Box
borderStyle="solid"
borderRadius="8"
borderWidth="2"
borderColor="rred100red200red300red400red500red600redred700red800red900red1000ed"
height="48"
width="48"
/>
)
}
Colors
Box accepts the following color style properties:
backgroundColorborderColorcolor
Code
import { createSystem } from 'frog/ui'
const { Box } = createSystem()
function Example() {
return (
<Box
backgroundColor="bbackgroundbackground100background200blue100blue200blue300blue400blue500blue600blueblue700blue800blue900blue1000lue"
height="48"
width="48"
/>
)
}
Font & Text
Box accepts the following font & text style properties:
fontFamilyfontSizefontStylefontWeighttextAligntextDecorationtextOverflowtextTransformtextShadowtextWrap
Code
import { createSystem } from 'frog/ui'
const { Box } = createSystem()
function Example() {
return (
<Box fontSize="48" textAlign="leftrightcenterendstartjustifycenter">
Hello world
</Box>
)
}Height & Width
Box accepts the following font & text style properties:
heightmaxHeightmaxWidthminHeightminWidthwidth
Code
import { createSystem } from 'frog/ui'
const { Box } = createSystem()
function Example() {
return (
<Box backgroundColor="red" height="48" width="48" />
)
}Paddings
Box accepts the following font & text style properties:
paddingpaddingBottompaddingLeftpaddingRightpaddingTop
Code
import { createSystem } from 'frog/ui'
const { Box } = createSystem()
function Example() {
return (
<Box padding="48">
<Box backgroundColor="red" height="48" width="48" />
</Box>
)
}