Shorthand for Specifying Pixel Values in style props

When specifying a pixel value for your inline style prop, React automatically appends the string "px" for you after your number value, so this works:

/** @jsx React.DOM */

var divStyle = {height: 10}; // rendered as "height:10px"
React.renderComponent(<div style={divStyle}>Hello World!</div>, mountNode);

See Inline Styles for more info.

Sometimes you do want to keep the CSS properties unitless. Here's a list of properties that won't get the automatic "px" suffix:

  • columnCount
  • fillOpacity
  • flex
  • flexGrow
  • flexShrink
  • fontWeight
  • lineClamp
  • lineHeight
  • opacity
  • order
  • orphans
  • widows
  • zIndex
  • zoom