The heading component with optional editability and a copy-to-clipboard button. When editable is true, the heading becomes editable on focus, with accessibility and onChange support. Optionally, a hidden input can store the value for form submission, and a button can copy content to the clipboard inline.
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
props | object | Component props. Properties
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ref | object | | Ref to the component. |
- Since
- 1.1.15
- Source
The heading component.
- Type:
- JSX.
Element
// With copy button inline, non-editable
<Heading tagName="h2" content="Copy Me" showCopyButton />
// Controlled usage with copy button inline
const [heading, setHeading] = useState("Editable Heading");
<Heading tagName="h2" content={heading} editable onChange={setHeading} showCopyButton />
// Self-managed form usage with copy button inline
<form>
<Heading tagName="h2" content="Editable Heading" editable useHiddenInput name="heading" id="heading-1" showCopyButton />
<button type="submit">Submit</button>
</form>