Skip to main content

RichTextEditor

Component for generating rich text.

Submit feedback
github

Migration Information

For teams migrating from the V1 to V2 component, please refer to the migration guide for changes to the component.
Component Guide
import { RichTextEditor } from '@uhg-abyss/web/ui/RichTextEditor';

Overview

RichTextEditor is a rich text editor component built using Tiptap. It provides a user-friendly interface for creating and editing rich text content with various formatting options.

Usage

Use sub-components of RichTextEditor to build a toolbar of options for editing text. Controls should be placed within the <RichTextEditor.Toolbar> component and grouped by the <RichTextEditor.ControlsGroup> component.

  • Undo or Redo actions with

    • <RichTextEditor.Undo />
    • <RichTextEditor.Redo />
  • Format text styles with

    • <RichTextEditor.Bold />
    • <RichTextEditor.Italic />
    • <RichTextEditor.Underline />
    • <RichTextEditor.Strike />
    • <RichTextEditor.Color />
    • <RichTextEditor.BackgroundColor />
    • <RichTextEditor.Highlight />
  • Edit text with

    • <RichTextEditor.Headings />
    • <RichTextEditor.FontSize />
    • <RichTextEditor.Alignments />
    • <RichTextEditor.Lists />
  • Add/Copy elements with

    • <RichTextEditor.Link />
    • <RichTextEditor.Code />
    • <RichTextEditor.Image />
    • <RichTextEditor.Copy />
  • Add tables with

    • <RichTextEditor.Table />
    • <RichTextEditor.TableRows />
    • <RichTextEditor.TableColumns />
  • Separate groups with

    • <RichTextEditor.Separator />

Customization

You can customize the toolbar by adding or removing controls as needed. Some controls have additional props for further customization:

  • <RichTextEditor.FontSize /> - Customize available font sizes using the fontSizes prop.
  • <RichTextEditor.Color /> - Customize available colors using the colors prop.
  • RichTextEditor.BackgroundColor - Customize available background colors using the backgroundColors prop.
  • RichTextEditor.Table - Customize the default table configuration using the tableConfig prop.

Using useForm and FormProvider simplifies form management by providing out-of-the-box validation, form state handling, and performance optimizations, leveraging the power of react-hook-form.

useState

Disabling options

Manually disable certain options by using the isDisabled prop.

Format - HTML/JSON

Change the output format to JSON by passing the string 'json' to the format prop.

Ref

Use the ref prop to pass in a ref to the component. RichTextEditor will then attach the updateContent function to this ref, which can be called to programmatically update the content of the editor.

Note that the updateContent function will not make changes if the new content is identical to the previous content.

RichTextEditor.Alignments Props

NameTypeDefaultRequiredDescription
className
string
--
CSS class name to apply to each element within the component
css
Abyss.CSSProperties | Partial<Record<`abyss-${T}`, Abyss.CSSProperties>>
--
Object containing CSS styling to apply; uses the classes listed in the "Integration" tab of the component's documentation

See CSS Prop Styling for more information
data-testid
string
--
Suffix used to create a unique ID used for automated testing

See Component Testing for more information
isDisabled
boolean
false
-
Disables the Alignment button

RichTextEditor.BackgroundColor Props

NameTypeDefaultRequiredDescription
backgroundColors
{ code: string; label: string; }[]
'[ { code: '#958DF1', label: 'Lilac' }, { code: '#F98181', label: 'Light Red' }, { code: '#FBBC88', label: 'Light Orange' }, { code: '#70CFF8', label: 'Sky Blue' }, { code: '#94FADB', label: 'Light Teal' }, { code: '#B9F18D', label: 'Light Green' }, ]'
-
Array of background colors to display in the dropdown menu.
(A separate "remove background" option is rendered by the component.)
className
string
--
CSS class name to apply to each element within the component
css
Abyss.CSSProperties | Partial<Record<`abyss-${T}`, Abyss.CSSProperties>>
--
Object containing CSS styling to apply; uses the classes listed in the "Integration" tab of the component's documentation

See CSS Prop Styling for more information
data-testid
string
--
Suffix used to create a unique ID used for automated testing

See Component Testing for more information
isDisabled
boolean
false
-
Disables the BackgroundColor button.

RichTextEditor.Bold Props

NameTypeDefaultRequiredDescription
className
string
--
CSS class name to apply to each element within the component
css
Abyss.CSSProperties | Partial<Record<`abyss-${T}`, Abyss.CSSProperties>>
--
Object containing CSS styling to apply; uses the classes listed in the "Integration" tab of the component's documentation

See CSS Prop Styling for more information
data-testid
string
--
Suffix used to create a unique ID used for automated testing

See Component Testing for more information
isDisabled
boolean
false
-
Disables the Bold button

RichTextEditor.Color Props

NameTypeDefaultRequiredDescription
className
string
--
CSS class name to apply to each element within the component
colors
{ code: string; label: string; }[]
'[ { code: '#002677', label: 'Blue' }, { code: '#0B6623', label: 'Green' }, { code: '#FF5733', label: 'Orange' }, { code: '#FFC300', label: 'Yellow' }, { code: '#C70039', label: 'Red' }, { code: '#900C3F', label: 'Magenta' }, { code: '#581845', label: 'Purple' }, ]'
-
Array of colors to display in the dropdown menu.
css
Abyss.CSSProperties | Partial<Record<`abyss-${T}`, Abyss.CSSProperties>>
--
Object containing CSS styling to apply; uses the classes listed in the "Integration" tab of the component's documentation

See CSS Prop Styling for more information
data-testid
string
--
Suffix used to create a unique ID used for automated testing

See Component Testing for more information
isDisabled
boolean
false
-
Disables the Color button.

RichTextEditor.Copy Props

NameTypeDefaultRequiredDescription
className
string
--
CSS class name to apply to each element within the component
css
Abyss.CSSProperties | Partial<Record<`abyss-${T}`, Abyss.CSSProperties>>
--
Object containing CSS styling to apply; uses the classes listed in the "Integration" tab of the component's documentation

See CSS Prop Styling for more information
data-testid
string
--
Suffix used to create a unique ID used for automated testing

See Component Testing for more information
isDisabled
boolean
false
-
Disables the Copy button

RichTextEditor.FontSize Props

NameTypeDefaultRequiredDescription
className
string
--
CSS class name to apply to each element within the component
css
Abyss.CSSProperties | Partial<Record<`abyss-${T}`, Abyss.CSSProperties>>
--
Object containing CSS styling to apply; uses the classes listed in the "Integration" tab of the component's documentation

See CSS Prop Styling for more information
data-testid
string
--
Suffix used to create a unique ID used for automated testing

See Component Testing for more information
fontSizes
string[]
'['14px', '16px', '18px', '24px', '30px']'
-
Array of font sizes to display in the dropdown menu
isDisabled
boolean
false
-
Disables the FontSize button

RichTextEditor.Headings Props

NameTypeDefaultRequiredDescription
className
string
--
CSS class name to apply to each element within the component
css
Abyss.CSSProperties | Partial<Record<`abyss-${T}`, Abyss.CSSProperties>>
--
Object containing CSS styling to apply; uses the classes listed in the "Integration" tab of the component's documentation

See CSS Prop Styling for more information
data-testid
string
--
Suffix used to create a unique ID used for automated testing

See Component Testing for more information
isDisabled
boolean
false
-
Disables the Headings button

RichTextEditor.Highlight Props

NameTypeDefaultRequiredDescription
className
string
--
CSS class name to apply to each element within the component
css
Abyss.CSSProperties | Partial<Record<`abyss-${T}`, Abyss.CSSProperties>>
--
Object containing CSS styling to apply; uses the classes listed in the "Integration" tab of the component's documentation

See CSS Prop Styling for more information
data-testid
string
--
Suffix used to create a unique ID used for automated testing

See Component Testing for more information
isDisabled
boolean
false
-
Disables Highlight button

RichTextEditor.Image Props

NameTypeDefaultRequiredDescription
className
string
--
CSS class name to apply to each element within the component
css
Abyss.CSSProperties | Partial<Record<`abyss-${T}`, Abyss.CSSProperties>>
--
Object containing CSS styling to apply; uses the classes listed in the "Integration" tab of the component's documentation

See CSS Prop Styling for more information
data-testid
string
--
Suffix used to create a unique ID used for automated testing

See Component Testing for more information
isDisabled
boolean
false
-
Disables the Image button

RichTextEditor.Italic Props

NameTypeDefaultRequiredDescription
className
string
--
CSS class name to apply to each element within the component
css
Abyss.CSSProperties | Partial<Record<`abyss-${T}`, Abyss.CSSProperties>>
--
Object containing CSS styling to apply; uses the classes listed in the "Integration" tab of the component's documentation

See CSS Prop Styling for more information
data-testid
string
--
Suffix used to create a unique ID used for automated testing

See Component Testing for more information
isDisabled
boolean
false
-
Disables Italics button

RichTextEditor.Link Props

NameTypeDefaultRequiredDescription
className
string
--
CSS class name to apply to each element within the component
css
Abyss.CSSProperties | Partial<Record<`abyss-${T}`, Abyss.CSSProperties>>
--
Object containing CSS styling to apply; uses the classes listed in the "Integration" tab of the component's documentation

See CSS Prop Styling for more information
data-testid
string
--
Suffix used to create a unique ID used for automated testing

See Component Testing for more information
isDisabled
boolean
false
-
Disables Link button

RichTextEditor.Lists Props

NameTypeDefaultRequiredDescription
className
string
--
CSS class name to apply to each element within the component
css
Abyss.CSSProperties | Partial<Record<`abyss-${T}`, Abyss.CSSProperties>>
--
Object containing CSS styling to apply; uses the classes listed in the "Integration" tab of the component's documentation

See CSS Prop Styling for more information
data-testid
string
--
Suffix used to create a unique ID used for automated testing

See Component Testing for more information
isDisabled
boolean
false
-
Disabled Lists button

RichTextEditor.Redo Props

NameTypeDefaultRequiredDescription
className
string
--
CSS class name to apply to each element within the component
css
Abyss.CSSProperties | Partial<Record<`abyss-${T}`, Abyss.CSSProperties>>
--
Object containing CSS styling to apply; uses the classes listed in the "Integration" tab of the component's documentation

See CSS Prop Styling for more information
data-testid
string
--
Suffix used to create a unique ID used for automated testing

See Component Testing for more information
isDisabled
boolean
false
-
Disables Redo button

RichTextEditor.Strike Props

NameTypeDefaultRequiredDescription
className
string
--
CSS class name to apply to each element within the component
css
Abyss.CSSProperties | Partial<Record<`abyss-${T}`, Abyss.CSSProperties>>
--
Object containing CSS styling to apply; uses the classes listed in the "Integration" tab of the component's documentation

See CSS Prop Styling for more information
data-testid
string
--
Suffix used to create a unique ID used for automated testing

See Component Testing for more information
isDisabled
boolean
false
-
Disables Strike button

RichTextEditor.Table Props

NameTypeDefaultRequiredDescription
className
string
--
CSS class name to apply to each element within the component
css
Abyss.CSSProperties | Partial<Record<`abyss-${T}`, Abyss.CSSProperties>>
--
Object containing CSS styling to apply; uses the classes listed in the "Integration" tab of the component's documentation

See CSS Prop Styling for more information
data-testid
string
--
Suffix used to create a unique ID used for automated testing

See Component Testing for more information
isDisabled
boolean
false
-
Disables the Table button
tableConfig
{ rows: number; cols: number; withHeaderRow: boolean; }
'{ rows: 3, cols: 3, withHeaderRow: true }'
-
Configuration for the table to be inserted

RichTextEditor.TableColumns Props

NameTypeDefaultRequiredDescription
className
string
--
CSS class name to apply to each element within the component
css
Abyss.CSSProperties | Partial<Record<`abyss-${T}`, Abyss.CSSProperties>>
--
Object containing CSS styling to apply; uses the classes listed in the "Integration" tab of the component's documentation

See CSS Prop Styling for more information
data-testid
string
--
Suffix used to create a unique ID used for automated testing

See Component Testing for more information
isDisabled
boolean
false
-
Disables the TableColumns button

RichTextEditor.TableRows Props

NameTypeDefaultRequiredDescription
className
string
--
CSS class name to apply to each element within the component
css
Abyss.CSSProperties | Partial<Record<`abyss-${T}`, Abyss.CSSProperties>>
--
Object containing CSS styling to apply; uses the classes listed in the "Integration" tab of the component's documentation

See CSS Prop Styling for more information
data-testid
string
--
Suffix used to create a unique ID used for automated testing

See Component Testing for more information
isDisabled
boolean
false
-
Disables the TableRows button

RichTextEditor.Toolbar Props

NameTypeDefaultRequiredDescription
children
React.ReactNode
--
Toolbar children
className
string
--
CSS class name to apply to each element within the component
css
Abyss.CSSProperties | Partial<Record<`abyss-${T}`, Abyss.CSSProperties>>
--
Object containing CSS styling to apply; uses the classes listed in the "Integration" tab of the component's documentation

See CSS Prop Styling for more information
data-testid
string
--
Suffix used to create a unique ID used for automated testing

See Component Testing for more information

RichTextEditor.Underline Props

NameTypeDefaultRequiredDescription
className
string
--
CSS class name to apply to each element within the component
css
Abyss.CSSProperties | Partial<Record<`abyss-${T}`, Abyss.CSSProperties>>
--
Object containing CSS styling to apply; uses the classes listed in the "Integration" tab of the component's documentation

See CSS Prop Styling for more information
data-testid
string
--
Suffix used to create a unique ID used for automated testing

See Component Testing for more information
isDisabled
boolean
false
-
Disables Underline button

RichTextEditor.Undo Props

NameTypeDefaultRequiredDescription
className
string
--
CSS class name to apply to each element within the component
css
Abyss.CSSProperties | Partial<Record<`abyss-${T}`, Abyss.CSSProperties>>
--
Object containing CSS styling to apply; uses the classes listed in the "Integration" tab of the component's documentation

See CSS Prop Styling for more information
data-testid
string
--
Suffix used to create a unique ID used for automated testing

See Component Testing for more information
isDisabled
boolean
false
-
Disables Undo button

RichTextEditor Props

NameTypeDefaultRequiredDescription
children
React.ReactNode
--
Rich Text Editor children
className
string
--
CSS class name to apply to each element within the component
css
Abyss.CSSProperties | Partial<Record<`abyss-${T}`, Abyss.CSSProperties>>
--
Object containing CSS styling to apply; uses the classes listed in the "Integration" tab of the component's documentation

See CSS Prop Styling for more information
data-testid
string
--
Suffix used to create a unique ID used for automated testing

See Component Testing for more information
disableDefaultProviderProps
boolean
false
-
If set to true, the component will not use the DefaultPropsProvider values.

If you aren’t using the DefaultPropsProvider, this prop can be ignored.
format
"html" | "json"
'html'
-
Return html or json data
height
string | number
'200px'
-
Rich Text Editor height
label
string
'Rich Text Editor'
-
Label for the Rich Text Editor
model
string
--
Form model to be used with FormProvider
onChange
(value: string) => void
--
Callback fired every time the value changes
value
string
--
Value of the Rich Text Editor.

RichTextEditor Classes

Class NameDescription
.abyss-

RichTextEditor.ControlsButton Classes

Class NameDescription
.abyss-rich-text-editor-controls-buttonClass applied to the control button

RichTextEditor.ControlsGroup Classes

Class NameDescription
.abyss-rich-text-editor-controls-groupClass applied to the ControlsGroup component

RichTextEditor.ControlsDropdown Classes

Class NameDescription
.abyss-rich-text-editor-controls-dropdownClass applied to the ControlsDropdown component

RichTextEditor.Alignments Classes

Class NameDescription
.abyss-

RichTextEditor.BackgroundColor Classes

Class NameDescription
.abyss-rich-text-editor-controls-dropdown-background-colorClass applied to the BackgroundColor control popover trigger (dropdown)

RichTextEditor.Bold Classes

Class NameDescription
.abyss-rich-text-editor-controls-button-boldClass applied to the Bold control button

RichTextEditor.Color Classes

Class NameDescription
.abyss-rich-text-editor-controls-dropdown-colorClass applied to the Color control popover trigger (dropdown)

RichTextEditor.Copy Classes

Class NameDescription
.abyss-rich-text-editor-controls-button-copyClass applied to the Copy control button

RichTextEditor.FontSize Classes

Class NameDescription
.abyss-rich-text-editor-controls-dropdown-font-sizeClass applied to the FontSize control dropdown

RichTextEditor.Headings Classes

Class NameDescription
.abyss-rich-text-editor-controls-dropdown-headingsClass applied to the Headings control dropdown

RichTextEditor.Highlight Classes

Class NameDescription
.abyss-rich-text-editor-controls-button-highlightClass applied to the Highlight control button

RichTextEditor.Image Classes

Class NameDescription
.abyss-rich-text-editor-controls-button-imageClass applied to the Image control button

RichTextEditor.Italic Classes

Class NameDescription
.abyss-rich-text-editor-controls-button-italicClass applied to the Italic control button

RichTextEditor.Link Classes

Class NameDescription
.abyss-rich-text-editor-controls-button-link-dropdown-text-input-containerContainer for the text inputs inside the link dropdown
.abyss-rich-text-editor-controls-button-link-dropdown-display-text-inputDisplay text input inside the link dropdown
.abyss-rich-text-editor-controls-button-link-dropdown-text-inputURL text input inside the link dropdown
.abyss-rich-text-editor-controls-button-link-dropdown-button-containerContainer for the buttons inside the link dropdown
.abyss-rich-text-editor-controls-button-link-dropdown-set-buttonSet button inside the link dropdown
.abyss-rich-text-editor-controls-button-link-dropdown-unset-buttonUnset button inside the link dropdown
.abyss-rich-text-editor-controls-button-link-tooltipTooltip for the link control button
.abyss-rich-text-editor-controls-dropdown-linkClass applied to the link control dropdown when active

RichTextEditor.Lists Classes

Class NameDescription
.abyss-rich-text-editor-controls-dropdown-listsClass applied to the Lists control dropdown

RichTextEditor.Redo Classes

Class NameDescription
.abyss-rich-text-editor-controls-button-redoClass applied to the Redo control button

RichTextEditor.Separator Classes

Class NameDescription
.abyss-rich-text-editor-separator-containerClass applied to the Separator container
.abyss-rich-text-editor-separator-lineClass applied to the Separator line

RichTextEditor.Strike Classes

Class NameDescription
.abyss-rich-text-editor-controls-button-strikeClass applied to the Strike control button

RichTextEditor.Table Classes

Class NameDescription
.abyss-rich-text-editor-controls-dropdown-tableClass applied to the Table control dropdown

RichTextEditor.TableColumns Classes

Class NameDescription
.abyss-rich-text-editor-controls-dropdown-table-columnsClass applied to the TableColumns control dropdown

RichTextEditor.TableRows Classes

Class NameDescription
.abyss-rich-text-editor-controls-dropdown-table-rowsClass applied to the TableRows control dropdown

RichTextEditor.Toolbar Classes

Class NameDescription
.abyss-rich-text-editor-toolbarClass applied to the Toolbar component

RichTextEditor.Underline Classes

Class NameDescription
.abyss-rich-text-editor-controls-button-underlineClass applied to the Underline control button

RichTextEditor.Undo Classes

Class NameDescription
.abyss-rich-text-editor-controls-button-undoClass applied to the Undo control button

Rich Text Editor Keyboard Interactions

KeyDescription
Control + ZUndo
Control + Shift + ZRedo
Control + BBold
Control + IItalic
Control + UUnderline
Control + Shift + SStrikethrough
Control + Shift + HHighlight
Control + ECode
Control + Shift + 7Ordered list
Control + Shift + 8Bullet list
Control + Shift + LLeft Align
Control + Shift + ECenter Align
Control + Shift + RRight Align
Control + Shift + JJustify
Control + Alt + 0Normal Text
Control + Alt + 1Heading 1
Control + Alt + 2Heading 2
Control + Alt + 3Heading 3
Control + Alt + 4Heading 4
Control + Alt + 5Heading 5
Control + Alt + 6Heading 6

Navigating Inside Toolbar Keyboard Interactions

KeyDescription
Right ArrowMoves focus one cell to the right.
Left ArrowMoves focus one cell to the left.
EnterSelect Item

Component Tokens

Note: Click on the token row to copy the token to your clipboard.

RichTextEditor Tokens

Token NameValue
rich-text-editor.color.border.container
#CBCCCD
rich-text-editor.color.border.control.active
#323334
rich-text-editor.color.border.toolbar
#CBCCCD
rich-text-editor.color.surface.container
#FFFFFF
rich-text-editor.color.surface.control.rest
#FFFFFF
rich-text-editor.color.surface.control.active
#F3F3F3
rich-text-editor.color.surface.control.hover
#E5E5E6
rich-text-editor.color.surface.control.disabled
#F3F3F3
rich-text-editor.color.surface.line
#CBCCCD
rich-text-editor.color.text.control.rest
#323334
rich-text-editor.color.text.control.active
#323334
rich-text-editor.color.text.control.hover
#323334
rich-text-editor.color.text.control.disabled
#7D7F81
rich-text-editor.color.icon.control.rest
#323334
rich-text-editor.color.icon.control.active
#323334
rich-text-editor.color.icon.control.hover
#323334
rich-text-editor.color.icon.control.disabled
#7D7F81
rich-text-editor.border-radius.all.container
8px
rich-text-editor.border-width.all.container
1px
rich-text-editor.border-width.all.control
1px
rich-text-editor.border-width.bottom.toolbar
1px
rich-text-editor.spacing.gap.horizontal.control
4px
rich-text-editor.spacing.gap.horizontal.toolbar
8px
rich-text-editor.spacing.gap.vertical.container
16px
rich-text-editor.spacing.padding.all.control
8px
rich-text-editor.spacing.padding.bottom.container
16px
rich-text-editor.spacing.padding.horizontal.editor
24px
rich-text-editor.spacing.padding.horizontal.toolbar
16px
rich-text-editor.spacing.padding.vertical.toolbar
12px

ActionMenu Tokens

Token NameValue
action-menu.color.border.container
#CBCCCD
action-menu.color.surface.container
#FFFFFF
action-menu.color.surface.menu-item.rest
#FFFFFF
action-menu.color.surface.menu-item.hover
#F3F3F3
action-menu.color.surface.menu-item.active
#E5E5E6
action-menu.color.surface.separator
#CBCCCD
action-menu.color.text.menu-item.default
#4B4D4F
action-menu.color.text.menu-item.disabled
#7D7F81
action-menu.color.icon.menu-item.default
#323334
action-menu.color.icon.menu-item.disabled
#7D7F81
action-menu.border-radius.all.container
4px
action-menu.border-width.all.container
1px
action-menu.spacing.gap.horizontal.menu-item
8px
action-menu.spacing.margin.all.separator
8px
action-menu.spacing.padding.horizontal.menu-item
16px
action-menu.spacing.padding.vertical.loading
24px
action-menu.spacing.padding.vertical.menu-item
8px
Table of Contents