Beta Preview

Style Macro Reference

Reference for the properties and values supported by React Spectrum style macro.

Colors

All Spectrum 2 color tokens are available across color properties (e.g., backgroundColor, color, borderColor).

PropertyValues
color'accent' | 'neutral' | 'neutral-subdued' | 'negative' | 'disabled' | 'heading' | 'title' | 'body' | 'detail' | 'code' | 'auto' | baseColors
backgroundColor'accent' | 'accent-subtle' | 'neutral' | 'neutral-subdued' | 'neutral-subtle' | 'negative' | 'negative-subtle' | 'informative' | 'informative-subtle' | 'positive' | 'positive-subtle' | 'notice' | 'notice-subtle' | 'gray' | 'gray-subtle' | 'red' | 'red-subtle' | 'orange' | 'orange-subtle' | 'yellow' | 'yellow-subtle' | 'chartreuse' | 'chartreuse-subtle' | 'celery' | 'celery-subtle' | 'green' | 'green-subtle' | 'seafoam' | 'seafoam-subtle' | 'cyan' | 'cyan-subtle' | 'blue' | 'blue-subtle' | 'indigo' | 'indigo-subtle' | 'purple' | 'purple-subtle' | 'fuchsia' | 'fuchsia-subtle' | 'magenta' | 'magenta-subtle' | 'pink' | 'pink-subtle' | 'turquoise' | 'turquoise-subtle' | 'cinnamon' | 'cinnamon-subtle' | 'brown' | 'brown-subtle' | 'silver' | 'silver-subtle' | 'disabled' | 'base' | 'layer-1' | 'layer-2' | 'pasteboard' | 'elevated' | baseColors
borderColor'negative' | 'disabled' | baseColors
outlineColor'focus-ring' | baseColors
fill'none' | 'currentColor' | 'accent' | 'neutral' | 'negative' | 'informative' | 'positive' | 'notice' | 'gray' | 'red' | 'orange' | 'yellow' | 'chartreuse' | 'celery' | 'green' | 'seafoam' | 'cyan' | 'blue' | 'indigo' | 'purple' | 'fuchsia' | 'magenta' | 'pink' | 'turquoise' | 'cinnamon' | 'brown' | 'silver' | baseColors
stroke'none' | 'currentColor' | baseColors

Dimensions

Spacing props like margin and padding accept values on a 4px grid. These are specified in px and get converted to rem. In addition to numbers, these named options are available:

  • edge-to-text – default spacing between the edge of a control and its text. Relative to control height.
  • pill – default spacing between the edge of a pill-shaped control and its text. Relative to control height.
  • text-to-control – default spacing between text and a control (e.g., label and input). Scales with font size.
  • text-to-visual – default spacing between text and a visual element (e.g., icon). Scales with font size.

Size props like width and height accept arbitrary pixel values. Values are converted to rem and multiplied by 1.25x on touch devices to increase hit targets.

PropertyValues
borderSpacing
flexBasis'auto' | 'full' | |
rowGaptext-to-control | text-to-visual | edge-to-text | pill |
columnGaptext-to-control | text-to-visual | edge-to-text | pill |
height'auto' | 'full' | 'min' | 'max' | 'fit' | 'screen' | |
width'auto' | 'full' | 'min' | 'max' | 'fit' | 'screen' | |
containIntrinsicWidth'auto' | 'full' | 'min' | 'max' | 'fit' | 'screen' | |
containIntrinsicHeight'auto' | 'full' | 'min' | 'max' | 'fit' | 'screen' | |
minHeight'auto' | 'full' | 'min' | 'max' | 'fit' | 'screen' | |
maxHeight'auto' | 'full' | 'min' | 'max' | 'fit' | 'screen' | 'none' | |
minWidth'auto' | 'full' | 'min' | 'max' | 'fit' | 'screen' | |
maxWidth'auto' | 'full' | 'min' | 'max' | 'fit' | 'screen' | 'none' | |
borderStartWidth'0' | '1' | '2' | '4'
borderEndWidth'0' | '1' | '2' | '4'
borderTopWidth'0' | '1' | '2' | '4'
borderBottomWidth'0' | '1' | '2' | '4'
borderStyle'solid' | 'dashed' | 'dotted' | 'double' | 'hidden' | 'none'
strokeWidth'0' | '1' | '2'
marginStart'auto' | | |
marginEnd'auto' | | |
marginTop'auto' | | |
marginBottom'auto' | | |
paddingStarttext-to-control | text-to-visual | edge-to-text | pill | |
paddingEndtext-to-control | text-to-visual | edge-to-text | pill | |
paddingToptext-to-control | text-to-visual | edge-to-text | pill | |
paddingBottomtext-to-control | text-to-visual | edge-to-text | pill | |
scrollMarginStart
scrollMarginEnd
scrollMarginTop
scrollMarginBottom
scrollPaddingStart
scrollPaddingEnd
scrollPaddingTop
scrollPaddingBottom
textIndent |
translateX'full' | | |
translateY'full' | | |
rotatenumber | '${number}deg' | '${number}rad' | '${number}grad' | '${number}turn'
Accepts a number (treated as degrees) or a string with units (deg, rad, grad, turn).
scaleXnumber | '${number}%'
Accepts a number or percentage string.
scaleYnumber | '${number}%'
Accepts a number or percentage string.
transformstring
position'absolute' | 'fixed' | 'relative' | 'sticky' | 'static'
insetStart'auto' | 'full' | | |
insetEnd'auto' | 'full' | | |
top'auto' | 'full' | | |
left'auto' | 'full' | | |
bottom'auto' | 'full' | | |
right'auto' | 'full' | | |
aspectRatio'auto' | 'square' | 'video' | 'number / number'
Also accepts a ratio in the format number/number (e.g., 16/9, 4/3).

Text

Spectrum 2 typography can be applied via the font shorthand, which sets fontFamily, fontSize, fontWeight, lineHeight, and color. You can override any of these individually.

<main>
  <h1 className={style({font: 'heading-xl'})}>Heading</h1>
  <p className={style({font: 'body'})}>Body</p>
  <ul className={style({font: 'body-sm', fontWeight: 'bold'})}>
    <li>List item</li>
  </ul>
</main>

Type scales include: UI, Body, Heading, Title, Detail, and Code. Each scale has a default and additional t-shirt sizes (e.g., ui-sm, heading-2xl, code-xl).

There are several different type scales.

  • UI – use within interactive UI components.
  • Body – use for the content of pages that are primarily text.
  • Heading – use for headings in content pages.
  • Title – use for titles within UI components such as cards or panels.
  • Detail – use for less important metadata.
  • Code – use for source code.

Each type scale has a default size, and several t-shirt size modifiers for additional sizes.

  • ui-xs
  • ui-sm
  • ui
  • ui-lg
  • ui-xl
  • ui-2xl
  • ui-3xl
  • body-2xs
  • body-xs
  • body-sm
  • body
  • body-lg
  • body-xl
  • body-2xl
  • body-3xl
  • heading-2xs
  • heading-xs
  • heading-sm
  • heading
  • heading-lg
  • heading-xl
  • heading-2xl
  • heading-3xl
  • title-xs
  • title-sm
  • title
  • title-lg
  • title-xl
  • title-2xl
  • title-3xl
  • detail-sm
  • detail
  • detail-lg
  • detail-xl
  • code-sm
  • code
  • code-lg
  • code-xl
PropertyValues
fontFamily'sans' | 'serif' | 'code'
fontSize'ui-xs' | 'ui-sm' | 'ui' | 'ui-lg' | 'ui-xl' | 'ui-2xl' | 'ui-3xl' | 'heading-2xs' | 'heading-xs' | 'heading-sm' | 'heading' | 'heading-lg' | 'heading-xl' | 'heading-2xl' | 'heading-3xl' | 'title-xs' | 'title-sm' | 'title' | 'title-lg' | 'title-xl' | 'title-2xl' | 'title-3xl' | 'body-2xs' | 'body-xs' | 'body-sm' | 'body' | 'body-lg' | 'body-xl' | 'body-2xl' | 'body-3xl' | 'detail-sm' | 'detail' | 'detail-lg' | 'detail-xl' | 'code-xs' | 'code-sm' | 'code' | 'code-lg' | 'code-xl'
fontWeight'normal' | 'medium' | 'bold' | 'extra-bold' | 'black' | 'heading' | 'title' | 'detail'
lineHeight'ui' | 'heading' | 'title' | 'body' | 'detail' | 'code'
listStyleType'none' | 'disc' | 'decimal'
listStylePosition'inside' | 'outside'
textTransform'uppercase' | 'lowercase' | 'capitalize' | 'none'
textAlign'start' | 'center' | 'end' | 'justify'
verticalAlign'baseline' | 'top' | 'middle' | 'bottom' | 'text-top' | 'text-bottom' | 'sub' | 'super'
textDecoration'none' | 'underline' | 'overline' | 'line-through'
textOverflow'ellipsis' | 'clip'
lineClampnumber
hyphens'none' | 'manual' | 'auto'
whiteSpace'normal' | 'nowrap' | 'pre' | 'pre-line' | 'pre-wrap' | 'break-spaces'
textWrap'wrap' | 'nowrap' | 'balance' | 'pretty'
wordBreak'normal' | 'break-all' | 'keep-all' | 'break-word'
overflowWrap'normal' | 'anywhere' | 'break-word'
boxDecorationBreak'slice' | 'clone'

Effects

PropertyValues
boxShadow'emphasized' | 'elevated' | 'dragged' | 'none'
filter'emphasized' | 'elevated' | 'dragged' | 'none'
borderTopStartRadius'none' | 'sm' | 'default' | 'lg' | 'xl' | 'full' | 'pill'
borderTopEndRadius'none' | 'sm' | 'default' | 'lg' | 'xl' | 'full' | 'pill'
borderBottomStartRadius'none' | 'sm' | 'default' | 'lg' | 'xl' | 'full' | 'pill'
borderBottomEndRadius'none' | 'sm' | 'default' | 'lg' | 'xl' | 'full' | 'pill'
forcedColorAdjust'auto' | 'none'
colorScheme'light' | 'dark' | 'light dark'
backgroundImagestring | 'LinearGradient'
backgroundPosition'bottom' | 'center' | 'left' | 'left bottom' | 'left top' | 'right' | 'right bottom' | 'right top' | 'top'
backgroundSize'auto' | 'cover' | 'contain'
backgroundAttachment'fixed' | 'local' | 'scroll'
backgroundClip'border-box' | 'padding-box' | 'content-box' | 'text'
backgroundRepeat'repeat' | 'no-repeat' | 'repeat-x' | 'repeat-y' | 'round' | 'space'
backgroundOrigin'border-box' | 'padding-box' | 'content-box'
backgroundBlendMode'normal' | 'multiply' | 'screen' | 'overlay' | 'darken' | 'lighten' | 'color-dodge' | 'color-burn' | 'hard-light' | 'soft-light' | 'difference' | 'exclusion' | 'hue' | 'saturation' | 'color' | 'luminosity'
mixBlendMode'normal' | 'multiply' | 'screen' | 'overlay' | 'darken' | 'lighten' | 'color-dodge' | 'color-burn' | 'hard-light' | 'soft-light' | 'difference' | 'exclusion' | 'hue' | 'saturation' | 'color' | 'luminosity' | 'plus-darker' | 'plus-lighter'
opacitynumber
outlineStyle'none' | 'solid' | 'dashed' | 'dotted' | 'double' | 'inset'
outlineOffsetnumber
outlineWidth'0' | '1' | '2' | '4'
transition'default' | 'colors' | 'opacity' | 'shadow' | 'transform' | 'all' | 'none'
transitionDelaystring | number
transitionDurationstring | number
transitionTimingFunction'default' | 'linear' | 'in' | 'out' | 'in-out'
animationstring
animationDurationstring | number
animationDelaystring | number
animationDirection'normal' | 'reverse' | 'alternate' | 'alternate-reverse'
animationFillMode'none' | 'forwards' | 'backwards' | 'both'
animationIterationCountstring | number
animationTimingFunction'default' | 'linear' | 'in' | 'out' | 'in-out'
animationPlayState'paused' | 'running'

Layout

PropertyValues
display'block' | 'inline-block' | 'inline' | 'flex' | 'inline-flex' | 'grid' | 'inline-grid' | 'contents' | 'list-item' | 'none'
alignContent'normal' | 'center' | 'start' | 'end' | 'space-between' | 'space-around' | 'space-evenly' | 'baseline' | 'stretch'
alignItems'start' | 'end' | 'center' | 'baseline' | 'stretch'
justifyContent'normal' | 'start' | 'end' | 'center' | 'space-between' | 'space-around' | 'space-evenly' | 'stretch'
justifyItems'start' | 'end' | 'center' | 'stretch'
alignSelf'auto' | 'start' | 'end' | 'center' | 'stretch' | 'baseline'
justifySelf'auto' | 'start' | 'end' | 'center' | 'stretch'
flexDirection'row' | 'column' | 'row-reverse' | 'column-reverse'
flexWrap'wrap' | 'wrap-reverse' | 'nowrap'
flexShrinknumber
flexGrownumber
gridColumnStartstring
gridColumnEndstring
gridRowStartstring
gridRowEndstring
gridAutoFlow'row' | 'column' | 'dense' | 'row dense' | 'column dense'
gridAutoRows'auto' | 'min-content' | 'max-content' | '${number}fr' | 'minmax(${string}, ${string})' | string |
gridAutoColumns'auto' | 'min-content' | 'max-content' | '${number}fr' | 'minmax(${string}, ${string})' | string |
gridTemplateColumns'auto' | 'min-content' | 'max-content' | '${number}fr' | 'minmax(${string}, ${string})' | 'none' | 'subgrid' | string |
gridTemplateRows'auto' | 'min-content' | 'max-content' | '${number}fr' | 'minmax(${string}, ${string})' | 'none' | 'subgrid' | string |
gridTemplateAreas'string[]'
float'inline-start' | 'inline-end' | 'right' | 'left' | 'none'
clear'inline-start' | 'inline-end' | 'left' | 'right' | 'both' | 'none'
contain'none' | 'strict' | 'content' | 'size' | 'inline-size' | 'layout' | 'style' | 'paint'
boxSizing'border-box' | 'content-box'
tableLayout'auto' | 'fixed'
captionSide'top' | 'bottom'
borderCollapse'collapse' | 'separate'
breakBefore'auto' | 'avoid' | 'all' | 'avoid-page' | 'page' | 'left' | 'right' | 'column'
breakInside'auto' | 'avoid' | 'avoid-page' | 'avoid-column'
breakAfter'auto' | 'avoid' | 'all' | 'avoid-page' | 'page' | 'left' | 'right' | 'column'
overflowX'auto' | 'hidden' | 'clip' | 'visible' | 'scroll'
overflowY'auto' | 'hidden' | 'clip' | 'visible' | 'scroll'
overscrollBehaviorX'auto' | 'contain' | 'none'
overscrollBehaviorY'auto' | 'contain' | 'none'
scrollBehavior'auto' | 'smooth'
ordernumber

Misc

PropertyValues
pointerEvents'none' | 'auto'
touchAction'auto' | 'none' | 'pan-x' | 'pan-y' | 'manipulation' | 'pinch-zoom'
userSelect'none' | 'text' | 'all' | 'auto'
visibility'visible' | 'hidden' | 'collapse'
isolation'isolate' | 'auto'
transformOrigin'center' | 'top' | 'top right' | 'right' | 'bottom right' | 'bottom' | 'bottom left' | 'left' | 'top right'
cursor'auto' | 'default' | 'pointer' | 'wait' | 'text' | 'move' | 'help' | 'not-allowed' | 'none' | 'context-menu' | 'progress' | 'cell' | 'crosshair' | 'vertical-text' | 'alias' | 'copy' | 'no-drop' | 'grab' | 'grabbing' | 'all-scroll' | 'col-resize' | 'row-resize' | 'n-resize' | 'e-resize' | 's-resize' | 'w-resize' | 'ne-resize' | 'nw-resize' | 'se-resize' | 'ew-resize' | 'ns-resize' | 'nesw-resize' | 'nwse-resize' | 'zoom-in' | 'zoom-out'
resize'none' | 'vertical' | 'horizontal' | 'both'
scrollSnapType'x' | 'y' | 'both' | 'x mandatory' | 'y mandatory' | 'both mandatory'
scrollSnapAlign'start' | 'end' | 'center' | 'none'
scrollSnapStop'normal' | 'always'
appearance'none' | 'auto'
objectFit'contain' | 'cover' | 'fill' | 'none' | 'scale-down'
objectPosition'bottom' | 'center' | 'left' | 'left bottom' | 'left top' | 'right' | 'right bottom' | 'right top' | 'top'
willChange'auto' | 'scroll-position' | 'contents' | 'transform'
zIndexnumber
disableTapHighlight'true'
unicodeBidi'normal' | 'embed' | 'bidi-override' | 'isolate' | 'isolate-override' | 'plaintext'
caretColor'auto' | 'transparent'

Shorthands

Shorthands apply their provided value to commonly grouped properties.

PropertyValuesMapping
paddingtext-to-control | text-to-visual | edge-to-text | pill | | paddingTop, paddingBottom, paddingStart, paddingEnd
paddingXtext-to-control | text-to-visual | edge-to-text | pill | | paddingStart, paddingEnd
paddingYtext-to-control | text-to-visual | edge-to-text | pill | | paddingTop, paddingBottom
margin'auto' | | | marginTop, marginBottom, marginStart, marginEnd
marginX'auto' | | | marginStart, marginEnd
marginY'auto' | | | marginTop, marginBottom
scrollPaddingscrollPaddingTop, scrollPaddingBottom, scrollPaddingStart, scrollPaddingEnd
scrollPaddingXscrollPaddingStart, scrollPaddingEnd
scrollPaddingYscrollPaddingTop, scrollPaddingBottom
scrollMarginscrollMarginTop, scrollMarginBottom, scrollMarginStart, scrollMarginEnd
scrollMarginXscrollMarginStart, scrollMarginEnd
scrollMarginYscrollMarginTop, scrollMarginBottom
borderWidth'0' | '1' | '2' | '4'borderTopWidth, borderBottomWidth, borderStartWidth, borderEndWidth
borderXWidth'0' | '1' | '2' | '4'borderStartWidth, borderEndWidth
borderYWidth'0' | '1' | '2' | '4'borderTopWidth, borderBottomWidth
borderRadius'none' | 'sm' | 'default' | 'lg' | 'xl' | 'full' | 'pill'borderTopStartRadius, borderTopEndRadius, borderBottomStartRadius, borderBottomEndRadius
borderTopRadius'none' | 'sm' | 'default' | 'lg' | 'xl' | 'full' | 'pill'borderTopStartRadius, borderTopEndRadius
borderBottomRadius'none' | 'sm' | 'default' | 'lg' | 'xl' | 'full' | 'pill'borderBottomStartRadius, borderBottomEndRadius
borderStartRadius'none' | 'sm' | 'default' | 'lg' | 'xl' | 'full' | 'pill'borderTopStartRadius, borderBottomStartRadius
borderEndRadius'none' | 'sm' | 'default' | 'lg' | 'xl' | 'full' | 'pill'borderTopEndRadius, borderBottomEndRadius
translate'full' | | | translateX, translateY
scalenumber | '${number}%'scaleX, scaleY
Accepts a number or percentage string.
inset'auto' | 'full' | | | top, bottom, insetStart, insetEnd
insetX'auto' | 'full' | | | insetStart, insetEnd
insetY'auto' | 'full' | | | top, bottom
placeItems'start' | 'end' | 'center' | 'stretch'alignItems, justifyItems
placeContent'normal' | 'center' | 'start' | 'end' | 'space-between' | 'space-around' | 'space-evenly' | 'baseline' | 'stretch'alignContent, justifyContent
placeSelf'auto' | 'start' | 'end' | 'center' | 'stretch' | 'baseline'alignSelf, justifySelf
gaptext-to-control | text-to-visual | edge-to-text | pill | rowGap, columnGap
size'auto' | 'full' | 'min' | 'max' | 'fit' | 'screen' | | width, height
minSize'auto' | 'full' | 'min' | 'max' | 'fit' | 'screen' | | minWidth, minHeight
maxSize'auto' | 'full' | 'min' | 'max' | 'fit' | 'screen' | 'none' | | maxWidth, maxHeight
overflow'auto' | 'hidden' | 'clip' | 'visible' | 'scroll'overflowX, overflowY
overscrollBehavior'auto' | 'contain' | 'none'overscrollBehaviorX, overscrollBehaviorY
gridAreastringgridColumnStart, gridColumnEnd, gridRowStart, gridRowEnd
transition'default' | 'colors' | 'opacity' | 'shadow' | 'transform' | 'all' | 'none'transition, transitionDuration, transitionTimingFunction
animationstringanimation, animationDuration, animationTimingFunction
This shorthand explicitly defines duration as 150 and the timing function as "default".
truncate'true'overflowX, overflowY, textOverflow, whiteSpace
Applying this shorthand will enable text truncation.
fontfontSizefontFamily, fontSize, fontWeight, lineHeight, color
The "fontSize" provided defines the values this shorthand sets on the mapped values.

Conditions

PropertyValues
forcedColors'@media (forced-colors: active)'
touch'@media not ((hover: hover) and (pointer: fine))'
sm'@media (min-width: ${pxToRem(640)})'
md'@media (min-width: ${pxToRem(768)})'
lg'@media (min-width: ${pxToRem(1024)})'
xl'@media (min-width: ${pxToRem(1280)})'
2xl'@media (min-width: ${pxToRem(1536)})'