Box

Use a box to simplify the process of applying one-off styles to an element

Ready to use
import {Box} from '@primer/react-brand'

Examples

Box requires the dir attribute to be set on the <html /> element to ensure that directional padding and margin values are applied correctly.

Default

The Box component, by default, represents an empty <div> element with no predefined styles applied to it.

Loading

Uniform padding

Use padding to apply equal inner spacing to all sides of an element.

Loading

Directional padding

Apply internal spacing to a specific side. Directional padding is implemented with CSS logical properties and accepts functional spacing names, or values from the base scale.

Loading

Uniform margin

Use margin to apply equal outer spacing to all sides of an element.

Loading

Directional margin

Apply external spacing to a specific side. Directional margins are implemented with CSS logical properties and accepts functional spacing names, or values from the base scale.

Loading

Responsive spacing

All padding and margin options can be configured for indivisual viewports: Each viewport entry is applied using a min-width media query.

Loading

Border radius

Loading

Borders

Loading

Background colors

Loading

Component props

Box

NameTypeDefaultDescription
padding'none', 'condensed', 'normal', 'spacious', 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 64, 80, 96, 112, 128undefinedAdds padding to all internal sides of the Box.
paddingBlockStart'none', 'condensed', 'normal', 'spacious', 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 64, 80, 96, 112, 128undefinedAdds padding to the internal block start (top) side of the Box.
paddingRight'none', 'condensed', 'normal', 'spacious', 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 64, 80, 96, 112, 128undefinedAdds padding to the internal inline end (right) of the Box.
paddingBlockEnd'none', 'condensed', 'normal', 'spacious', 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 64, 80, 96, 112, 128undefinedAdds padding to the internal block end (bottom) side of the Box.
paddingLeft'none', 'condensed', 'normal', 'spacious', 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 64, 80, 96, 112, 128undefinedAdds padding to the internal inline start (left) side of the Box.
margin'none', 'condensed', 'normal', 'spacious', 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 64, 80, 96, 112, 128undefinedAdds margin to all external sides of the Box.
marginBlockStart'none', 'condensed', 'normal', 'spacious', 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 64, 80, 96, 112, 128undefinedAdds margin to the external block start (top) side of the Box.
marginInlineEnd'none', 'condensed', 'normal', 'spacious', 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 64, 80, 96, 112, 128undefinedAdds margin to the external inline end (right) side of the Box.
marginBlockEnd'none', 'condensed', 'normal', 'spacious', 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 64, 80, 96, 112, 128undefinedAdds margin to the external block end (bottom) side of the Box.
marginInlineStart'none', 'condensed', 'normal', 'spacious', 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 64, 80, 96, 112, 128undefinedAdds margin to the external inline start (left) side of the Box.
backgroundColor'default', 'inset', 'subtle', 'overlay' or stringundefinedApplies a system-level background color to the Box.
borderRadius'small', 'medium', 'large', 'xlarge', 'full'undefinedApplies a system-level border radius value to the Box.
borderWidth'none', 'thin', 'thick', 'thicker'undefinedApplies a system-level border width value to the Box.
borderBlockStartWidth'none', 'thin', 'thick', 'thicker'undefinedApplies a system-level border width value to block-start side of the Box.
borderInlineEndWidth'none', 'thin', 'thick', 'thicker'undefinedApplies a system-level border width value to inline-end side of the Box.
borderBlockEndWidth'none', 'thin', 'thick', 'thicker'undefinedApplies a system-level border width value to block-end side of the Box.
borderInlineStartWidth'none', 'thin', 'thick', 'thicker'undefinedApplies a system-level border width value to inline-start side of the Box.
borderColor'default', 'muted', 'subtle'undefinedApplies a system-level border color value to the Box.
borderStyle'solid', 'none'undefinedApplies border style. Values correspond to the CSS border-style property.