getSpaceClass()function

getSpaceClass({ space }: SpaceVariants): string | undefined
ParamType
variantsSpaceVariants
Variants to control block spacing on components, e.g. space="large". required
    .spaceSpaceValue
Block spacing for this component.
Return
string | undefined
The space class string, or undefined when no space is set.

Get the block spacing class for a component from its space="" variant prop.

The space variant prop sets a block-level element's margin-block (top + bottom) from the spacing scale — <Section space="large">, <Paragraph space="none">. It's an override for one-off spacing; for an app-wide change, retune the spacing variables below in a theme file.

getSpaceClass({ space }) maps the prop to a margin class (e.g. space="large"large). The same scale also backs getPaddingClass() and getGapClass(), so all three move together when you change --space-normal.

Alongside the named scale, space and padding also accept numeric multiples of --space-normal1x10x (e.g. padding="5x"calc(var(--space-normal) * 5)) — for larger one-off blocks like hero panels.

Theme variables

The following :root variables are defined by this module and can be overridden in a theme file to adjust default styling across the whole app.

Scale

VariableDefaultNotes
--space-xxsmallvar(--space-normal) * 0.254px
--space-xsmallvar(--space-normal) * 0.58px
--space-smallvar(--space-normal) * 0.7512px
--space-normal1rem16px - base spacing unit (the root of the scale).
--space-largevar(--space-normal) * 1.524px
--space-xlargevar(--space-normal) * 232px
--space-xxlargevar(--space-normal) * 348px

Semantic

VariableDefaultUsed for
--space-sectionvar(--space-normal) * 2Top margin for titles / headings / section blocks.
--space-paragraphvar(--space-normal)Default block-space for most prose elements.

Examples

getSpaceClass({ space: "large" }) // "large"