RichTextField
A rich text editor with a ready-made toolbar. Use it when users need to write formatted text with headings, lists, links and images, and the content is reported back as an HTML string.
Usage
<RichTextField defaultValue="<p>Beskriv omfanget av oppdraget...</p>" />
Props
Besides the props below, the component accepts style props and standard div attributes.
Mantine's RichTextEditor props are not exposed.
| Property | Type | Allowed values | Default | Description |
|---|---|---|---|---|
defaultValue | string | — | — | Initial content as an HTML string. Read once, when the editor is created — later changes are ignored. |
onChange | (html: string) => void | — | — | Called with the full HTML document on every edit. |
withToolbar | boolean | — | true | Renders the toolbar above the content area. |
toolbarGroups | Partial<Record<RichTextFieldToolbarGroup, boolean>> | formatting · blockType · textColor · alignment · lists · link · image | — | Switches individual toolbar groups on or off — toolbarGroups={{ blockType: true }}. Every group is on unless named here, except blockType and textColor, which are off. |
colors | RichTextFieldColor[] | — | 7 palette swatches | Swatches offered by the text-colour control. The default set is darkGrey[8], blue[6], green[7], red[7], orange[7], yellow[7], purple[6]. |
contentLabel | string | — | 'Tekstinnhold' | Accessible name of the editable area. |
labels | Partial<RichTextFieldLabels> | — | Norwegian texts | Overrides any of the editor's texts: Mantine's control labels (boldControlLabel, …) plus the custom controls' (blockTypeLabel, insertImageLabel, imageTooLargeError, …). Only the keys given are replaced. |
Three controls are built here and have no Mantine equivalent. The block type dropdown offers paragraph and heading levels 1–3. The text colour control opens a swatch popover. The image control opens the file browser and inserts the chosen file, up to 2 MB, as a data URI — there is no upload endpoint.
Accessibility
Toolbar controls are labelled through labels. The defaults are Norwegian; an
app in another language passes its own through labels, and the swatch names
through colors.
Inserting an image opens a modal with an alternative text field. The field may
be left empty for purely decorative images. Set contentLabel when a page has
more than one RichTextField, so each editable area has a distinct name.
Theme-wide requirements are covered in Accessibility.