Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

react conditional styling

// If you need to conditionally apply inline styles (apply all or nothing) then this notation also works:

<div style={ someCondition ? { textAlign:'center', paddingTop: '50%'} : {}} >
  {content}
</div>

// Or to apply it to particular property

<div
    style={{ 
      display: isExpanded ? 'block' : 'none', 
      marginBottom: '1rem'
    }}
  >
  {content}
</div>
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #react #conditional #styling
ADD COMMENT
Topic
Name
4+8 =