Rendering the Boolean field

The Boolean field will add a switch for a true or false values for the content authors to pick from.


Use boolean value to determine CSS className

Here is an example of how to retrieve the value from a Boolean field which has the API ID switch.

Here we are using a boolean value to decide whether a className is one value or the other.

Copy
// Inside a React component 
render() {
  const position = document.data.switch ? 'right' : 'left';
  return (
    <div>
      <ol>
        <div className={ position }>
          <h2>Text positioned by Boolean value...!</h2>
        </div>
      </ol>
    </div>
  )
}