The content inside this block will act as the clickable "trigger" to display the dialog element.
| Property | Value |
|---|---|
| Namespace | prc-block/dialog-trigger |
| Category | media |
| Version | 1.1.0 |
| API Version | 3 |
| Example | Yes (inner core/paragraph — inserter preview when shown via parent Dialog) |
| Feature | Value |
|---|---|
| HTML editing | false |
| Align | false |
| Inserter | false (only via parent Dialog) |
| Spacing margin | top, bottom |
| Spacing padding | true (default controls enabled) |
| Font size | true (default controls enabled) |
| Font family | true (default controls enabled) |
| Interactivity | true |
None. This block has no custom attributes.
Uses Context:
| Context Key | Description |
|---|---|
dialog/id |
The dialog ID from the parent Dialog block. |
dialog/className |
Class name from the parent Dialog block. |
dialog/isOpen |
Editor open state from the parent Dialog block. |
Any blocks can be placed inside the trigger. The template lock is false, allowing full flexibility. The default template (set by the parent Dialog block) includes a single paragraph with placeholder text.
| Parent | Required |
|---|---|
prc-block/dialog |
Yes |
- This block is automatically inserted inside a Dialog block. It cannot be inserted independently.
- Type or add content that will serve as the clickable trigger (text, buttons, images, etc.).
- The entire trigger area is rendered as a
<button>element on the frontend. - In the editor, a toolbar button allows toggling between the trigger view and the dialog editing view.
<!-- wp:prc-block/dialog-trigger -->
<!-- wp:paragraph -->
<p>Click to open dialog</p>
<!-- /wp:paragraph -->
<!-- /wp:prc-block/dialog-trigger -->The Dialog_Trigger PHP class provides a server-side render callback:
- Reads the
dialog/idfrom parent block context. - Wraps inner content in a
<button>element with:- A unique ID via
wp_unique_id('dialog-trigger-'). aria-haspopup="dialog"for accessibility.aria-controlspointing to the dialog element's ID.data-wp-bind--aria-expanded="state.isOpen"for dynamic ARIA state.data-wp-interactive="prc-block/dialog"to connect to the dialog store.data-wp-on--click="actions.onClickOpen"to handle click events.
- A unique ID via
Rendered output:
<button
class="wp-block-prc-block-dialog-trigger"
id="dialog-trigger-1"
aria-haspopup="dialog"
aria-controls="my-dialog"
data-wp-bind--aria-expanded="state.isOpen"
data-wp-interactive="prc-block/dialog"
data-wp-on--click="actions.onClickOpen"
type="button"
>
<p>Click to open dialog</p>
</button>The trigger does not have its own view script. It uses the prc-block/dialog Interactivity API store (provided by dialog-element's view script):
- Click handler (
actions.onClickOpen): Prevents default click behavior and callsactions.open(id)to open the associated dialog. - ARIA binding (
state.isOpen): Dynamically updatesaria-expandedto reflect the dialog's open/closed state.
prc-block/dialog— Parent container block (required).prc-block/dialog-element— Sibling dialog content block that this trigger opens.