Skip to main content
Documentation/Developers/APIs/Hooks Reference/Rendering

Rendering

Filters modify output while preserving these contracts.

Elements

Hook Callback arguments Return
breakdance_before_render_node $node Updated node array.
breakdance_render_show_node $show, $node Boolean controlling this node's HTML.
breakdance_render_element_html $html, $node Element HTML string.
breakdance_element_classnames_for_html_class_attribute $classNames, $element, $props Class-name array.
breakdance_render_element_class_list $classList, $element Final class-name array.
breakdance_frontend_element_attributes $atts, $node, $element Attribute name/value array.

Element type is $node['data']['type']:

PHP
add_filter('breakdance_frontend_element_attributes', function ($atts, $node, $element) {
    if (($node['data']['type'] ?? '') === 'AcmeElements\NoticeCard') {
        $atts['data-acme-notice'] = '1';
    }
    return $atts;
}, 10, 3);

breakdance_render_show_node controls HTML, not authorization; children/render work may already be processed and CSS remains.

Documents and SSR

  • breakdance_render_rendered_html($html, $postId, $repeaterItemNodeId) — Return document HTML string.
  • breakdance_render_wrap_in_main_tag($wrap, $postId, $repeaterItemNodeId) — Return boolean, initially true, for automatic main wrapping.
  • breakdance_append_dependencies($dependencies) — Return scripts/styles/inline-code dependency structure.
  • breakdance_builder_ssr_rendered_html($html, $properties, $elementSlug, $parentProperties) — Return builder SSR output. Front-end filters do not automatically affect canvas previews.

Template selection uses the template override filter.

Add a Wrapper Class

PHP
add_filter('breakdance_element_classnames_for_html_class_attribute', function ($classes) {
    $classes[] = 'my-extension-element';
    return $classes;
});

Filter Singular Content

breakdance_singular_content receives and returns a content string in the simulate_the_content() path. It is not the general filter for every rendered element or document; use the rendering filters above for those cases.

PHP
add_filter('breakdance_singular_content', function ($content) {
    return $content . '<p class="content-credit">Content by our editorial team.</p>';
});

Inspect Appended Dependencies

breakdance_append_dependencies receives the dependency structure being appended. It can contain scripts, styles, inlineScripts, and inlineStyles. Return the array after inspecting or modifying it:

PHP
add_filter('breakdance_append_dependencies', function ($dependencies) {
    // Inspect $dependencies in your debugger, or adjust the relevant entries.
    return $dependencies;
});

See the canonical hooks examples and Dependencies API for named library URLs.