Base component for all Pluma components. All components in Pluma are built using the Box component. This means Pluma components all accept the Box component's props.

Importing

The Box component can be imported via:

import { Box } from '@customerio/pluma-components/react';

Style utilities

The Box component accepts a number of style utility props, which can be used for layout and styling. Because all Pluma components use Box, those props are available throughout the library.

The utilities are generated using the sprinkles vanilla-extract package.

Spacing

Spacing prop values are based on the spacing tokens in the Pluma design system and follow the formula (token / 100) * 8px. This includes:

  • 0 (0px)
  • 025 (2px)
  • 050 (4px)
  • 075 (6px)
  • 100 (8px)
  • 125 (10px)
  • 150 (12px)
  • 175 (14px)
  • 200 (16px)
  • 225 (18px)
  • 250 (20px)
  • 275 (22px)
  • 300 (24px)
  • 350 (28px)
  • 400 (32px)
  • 450 (36px)
  • 500 (40px)
  • 600 (48px)
  • 800 (64px)
  • 900 (72px)
  • 1000 (80px)
  • 1200 (96px)
  • 1600 (128px)
  • 2000 (160px)
  • 2400 (192px)
  • 2800 (224px)
  • 3200 (256px)
  • icon-lg (var(--pluma-space-400))
  • icon-md (var(--pluma-space-300))
  • icon-sm (var(--pluma-space-200))
  • icon-v2-lg (var(--pluma-space-300))
  • icon-v2-md (var(--pluma-space-250))
  • icon-v2-sm (var(--pluma-space-200))
  • icon-v2-xl (var(--pluma-space-400))
  • icon-xl (var(--pluma-space-600))
  • icon-xs (var(--pluma-space-175))
  • icon-xxs (var(--pluma-space-150))
  • padding-button-medium (var(--pluma-space-150))
  • padding-button-small (var(--pluma-space-100))
  • padding-header (var(--pluma-space-250))
  • Padding

    Padding uses space tokens and can be applied using the following props:

    • pt (padding top)
    • pr (padding right)
    • pb (padding bottom)
    • pl (padding left)
    • px (padding horizontal)
    • py (padding vertical)
    • p (padding on all sides)

    Margin

    Margin uses space tokens and can be applied using the following props:

    • mt (margin top)
    • mr (margin right)
    • mb (margin bottom)
    • ml (margin left)
    • mx (margin horizontal)
    • my (margin vertical)
    • m (margin on all sides)

    In addition to the spacing properties, margin also supports the auto value.

    Layout

    display

    none
    block
    inline-block
    inline
    flex
    inline-flex
    grid
    inline-grid

    overflow

    hidden
    scroll
    visible
    auto
    clip

    overflowX

    hidden
    scroll
    visible
    auto
    clip

    overflowY

    hidden
    scroll
    visible
    auto
    clip

    position

    relative
    absolute
    fixed
    sticky

    zIndex

    0
    auto
    control-group-hover
    overlay
    scrollable
    control-group-focus
    embedded-items
    header
    menu
    dropdown
    input-embed
    module-fixed
    dropdown-expanded
    alert
    toast
    page-action-bar
    nav-menu
    navbar
    modal
    modal-content
    tooltip

    w

    0
    full
    inherit

    minW

    0
    full
    inherit

    maxW

    0
    full
    inherit

    h

    0
    full
    inherit

    minH

    0
    full
    inherit

    maxH

    0
    full
    inherit

    Flexbox

    flexDirection

    row
    column

    justifyContent

    flex-start
    flex-end
    center
    space-between
    space-around
    space-evenly
    stretch

    alignItems

    flex-start
    flex-end
    center
    baseline
    stretch

    flexWrap

    wrap
    nowrap

    flexBasis

    0
    auto
    full

    flex

    1
    auto
    initial
    none

    Typography

    textAlign

    left
    center
    right

    textDecoration

    none
    underline

    textTransform

    none
    uppercase
    lowercase
    capitalize

    textOverflow

    ellipsis

    whiteSpace

    normal
    nowrap
    pre
    pre-line
    pre-wrap
    break-spaces

    overflowWrap

    normal
    words
    anywhere

    verticalAlign

    baseline
    top
    middle
    bottom
    text-top
    text-bottom
    sub
    super

    Interactivity

    cursor

    auto
    default
    none
    context-menu
    help
    pointer
    progress
    wait
    cell
    crosshair
    text
    vertical-text
    alias
    copy
    move
    no-drop
    not-allowed
    grab
    grabbing
    all-scroll
    col-resize
    row-resize
    n-resize
    e-resize
    s-resize
    w-resize
    ne-resize
    nw-resize
    se-resize
    sw-resize
    ew-resize
    ns-resize
    nesw-resize
    nwse-resize
    zoom-in
    zoom-out

    Effects/styling

    centerBaseline

    true
    inline

    as prop

    The Box component accepts an as prop, which changes what HTML element or component the box should render as (by default, div).

    <Box as="button" backgroundColor="critical" p="200">
    	<Text>Button</Text>
    </Box>

    style prop

    The Box component accepts a style prop, which allows you to pass in custom styles. This prop should be used instead of the style HTML attribute, since it prevents the styles from being overridden.

    Red text
    <Box style={{ color: 'red' }}>
    	Red text
    </Box>

    API

    Default:'div'

    What element or component should be rendered.

    style object to be applied to the box