Skip to content

Latest commit

 

History

History
47 lines (32 loc) · 907 Bytes

File metadata and controls

47 lines (32 loc) · 907 Bytes

PlainText

Render an auto-growing textarea allow users to fill any textual content.

Properties

value: string

Required. String value of the textarea.

onChange( value: string ): Function

Required. Function called when the text value changes.

You can also pass any extra prop to the textarea rendered by this component.

ref: Object

Optional. The component forwards the ref property to the TextareaAutosize component.

Example

import { registerBlockType } from '@wordpress/blocks';
import { PlainText } from '@wordpress/block-editor';

registerBlockType( /* ... */, {
	// ...

	attributes: {
		content: {
			type: 'string',
		},
	},

	edit( { className, attributes, setAttributes } ) {
		return (
			<PlainText
				className={ className }
				value={ attributes.content }
				onChange={ ( content ) => setAttributes( { content } ) }
			/>
		);
	},
} );