<!-- wp:shortcode -->
[hello]
<!-- /wp:shortcode -->
Block Editor
ToggleControl – Block Editor
import { useState } from 'react'; import { ToggleControl } from '@wordpress/components';
const [isHeroImageRight, setHeroImageRight] = useState(false);
<InspectorControls> <PanelBody> <ToggleControl label="Image Position" help={isHeroImageRight ? "Image Right." : "Image Left."} checked={isHeroImageRight} onChange={(newValue) => { setHeroImageRight(newValue); if (newValue) { console.log("ImageRight"); } else { console.log("ImageLeft"); } }} /> </PanelBody> </InspectorControls>
<div className={isHeroImageRight ? "hero-img-right" : "hero-img-left"}>