Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

dynamic style react

// 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: #dynamic #style #react
ADD COMMENT
Topic
Name
7+8 =