Skip to content

Post Select Control

Matthew Haines-Young edited this page Dec 7, 2021 · 3 revisions

This component is just a wrapper around the post select button component but styled to fit within a block or plugin sidebar.

image

All sidebar controls provided by hm-gutenberg-tools are also available globally, as window.hm.controls. Its probably worth creating a reference to keep your code simpler.

const { PostControl } = hm.controls;

<PostControl
    label={ __( 'Linked Page.' ) }
    value={ value }
    onChange={ value => setAttributes( value ) }
    btnText={ __( 'Select Page' ) }
    postSelectProps={ { postType: 'page' } }
/>

Notes

  • postSelectProps are just the props passed to the post select button. Refer to the component docs for more info on what is supported.
Clone this wiki locally