<?php
$unique_id = wp_unique_id( 'p-' );
?>
 
<div
    <?php echo get_block_wrapper_attributes(); ?>
    data-wp-interactive="create-block"
    <?php echo wp_interactivity_data_wp_context( array( 'isOpen' => false ) ); ?>
    data-wp-watch="callbacks.logIsOpen"
>
    <button
        data-wp-on--click="actions.toggle"
        data-wp-bind--aria-expanded="context.isOpen"
        aria-controls="<?php echo esc_attr( $unique_id ); ?>"
    >
        <?php esc_html_e( 'Toggle', 'example-block-interactive' ); ?>
    </button>
 
    <p
        id="<?php echo esc_attr( $unique_id ); ?>"
        data-wp-bind--hidden="!context.isOpen"
    >
        <?php
            esc_html_e( 'Example Block Interactive - hello from an interactive block!', 'example-block-interactive' );
        ?>
    </p>
</div>