Skip to content

Latest commit

 

History

History
45 lines (32 loc) · 1.48 KB

File metadata and controls

45 lines (32 loc) · 1.48 KB

PostTitleControl

The PostTitleControl component allows for editing the current post's title, anywhere in the block editor. This can be for something like a Hero block that features the post title, or a block for managing title and metadata.

Usage

For a minimum working setup, all you need to do is use the PostTitleControl component.

import { PostTitleControl } from '@humanmade/block-editor-components';

function BlockEdit() {
	return (
		<PostTitleControl />
	);
}

Additionally, you can pass anything as props that the nested RichText component accepts, except for value and onChange, which will be taken care of by PostTitleControl, as well as allowedFormats, which is hard-coded to not allow any formatting.

import { PostTitleControl } from '@humanmade/block-editor-components';

function BlockEdit() {
	return (
		<PostTitleControl
			className="my-component__title"
			placeholder="Title..."
			tagName="h1"
		/>
	);
}

Props

The PostTitleControl component does not have any custom props, but you can pass anything that is supported by the nested RichText component.

Dependencies

The PostTitleControl component requires the following dependencies, which are expected to be available:

  • @wordpress/block-editor
  • @wordpress/data