Files
react/docs/tips/06-style-props-value-px.md
T
Ben Alpert 52494f9d72 Update docs to align with 0.12 better
- Rename React.renderComponent -> React.render
- Remove most references to transferPropsTo
2014-10-22 14:01:54 -07:00

886 B

id, title, layout, permalink, prev, next
id title layout permalink prev next
style-props-value-px Shorthand for Specifying Pixel Values in style props tips style-props-value-px.html maximum-number-of-jsx-root-nodes.html children-props-type.html

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:

var divStyle = {height: 10}; // rendered as "height:10px"
React.render(<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