New to Telerik UI for .NET MAUIStart a free 30-day trial

RichTextEditor Toolbar

The .NET MAUI RichTextEditor control comes with various editing capabilities. With the help of the RadRichTextEditorToolbar, you can enable the users to effortlessly edit HTML content. The default toolbar includes items for all the available text formatting options. Alternatively, you can customize the shown editing options according to your needs.

By default, the RadRichTextEditorToolbar Items are auto-populated. You can change this by setting the RadRichTextEditorToolbar boolean AutoGenerateItems property to False. In this case, you will need to manually define the available editing options. For more details, check Custom Toolbar article.

To attach the RichTextEditor control to the RadRichTextEditorToolbar control, you need to set the RichTextEditor (from type RadRichTextEditor) property. All toolbar items execute their actions against the specified rich text editor.

XAML
<Grid RowDefinitions="Auto, *">
    <telerik:RadRichTextEditorToolbar RichTextEditor="{x:Reference richTextEditor}"/>
    <telerik:RadRichTextEditor x:Name="richTextEditor"
                               Grid.Row="1"/>
</Grid>

On Mobile, the RichTextEditorToolbar is horizontally scrollable, so that the toolbar items can be accessed:

.NET MAUI RichTextEditor Mobile Toolbar

On Desktop, the toolbar items are wrapped:

.NET MAUI RichTextEditor Desktop Toolbar

Predefined Toolbar Items

The table below shows all toolbar items available for both Desktop and Mobile:

RichTextEditor Toolbar ItemDescription
RichTextEditorFontFamilyToolbarItemChanges the font family of the text with the selected from predefiend font families.
RichTextEditorFontSizeToolbarItemChnages the font size of the text.
SeparatorToolbarItemSeparates the toolbar items.
RichTextEditorBoldToolbarItemBolds the text.
RichTextEditorItalicToolbarItemMakes the text italic.
RichTextEditorUnderlineToolbarItemunderlines the text.
RichTextEditorAlignLeftToolbarItemAlign the content to the left of the available space.
RichTextEditorAlignCenterToolbarItemAligns the content centered in the available space.
RichTextEditorAlignRightToolbarItemAlign the content to the right of the available space.
RichTextEditorAlignJustifyToolbarItemDistributes the content evenly in the available space.
RichTextEditorTextColorToolbarItemChanges the text color of the text with a selection from predefined colors.
RichTextEditorHighlightTextColorToolbarItemChanges the highlight color of the text with the selected from predefined colors.
RichTextEditorBulletingToolbarItemCreates a bulleted/unordered list.
RichTextEditorNumberingToolbarItemCreates a numbered/ordered list.
RichTextEditorOutdentToolbarItemMoves the content of the current or selected paragraphs closer the margin of the control.
RichTextEditorIndentToolbarItemMoves the content of the current or selected paragraphs farther away from the margin of the control.
RichTextEditorTextFormattingToolbarItem
RichTextEditorClearFormattingToolbarItemClears all formatting for the selection.
RichTextEditorStrikethroughToolbarItemCrosses out the text.
RichTextEditorSuperscriptToolbarItemMakes the text small and positioned below the paragraph line.
RichTextEditorSubscriptToolbarItemMakes the text small and positioned above the paragraph line.
RichTextEditorUndoToolbarItemUn-does the last action.
RichTextEditorRedoToolbarItemRe-does the last action.
RichTextEditorColorPickerToolbarItemAllows picking a specific color from a collection of colors.
RichTextEditorCopyToolbarItemCopies the selected HTML to the clipboard.
RichTextEditorCutToolbarItemCuts the selected HTML to the clipboard.
RichTextEditorPasteHtmlToolbarItemPastes HTML from the clipboard.
RichTextEditorAddOrEditHyperlinkToolbarItemOpens a popup to add ot edit a hyperlink.
RichTextEditorAddHyperlinkToolbarItemAdds a hyperlink.
RichTextEditorRemoveHyperlinkToolbarItemRemove the hyperlink for the current selection.
RichTextEditorAddOrEditImageToolbarItemIf image is selected, a dialog opens. If image is not selected, the PickImage event fires.
RichTextEditorHyperlinkNavigationToolbarItemIf hyperlink is selected, navigates to the predefined toolbar items related to hyperlink operations like: Edit, Open, Remove. If huperlink is not selected, opens a popup with predefined UI for adding a hyperlink to the current selection.
RichTextEditorImageNavigationToolbarItemIf image is selected, navigates to the operations related to image editing like: Cut, Copy, Remove, Paste, Edit.

Here are the all toolbar items definition:

xaml
<Grid RowDefinitions="{OnIdiom Desktop='Auto, *', Phone='*, Auto'}">
    <telerik:RadRichTextEditorToolbar x:Name="richTextToolbar"
                                      Grid.Row="{OnIdiom Desktop=0, Phone=1}"
                                      ZIndex="10"
                                      RichTextEditor="{x:Reference richTextEditor}"
                                      AutoGenerateItems="False">
        <telerik:RichTextEditorFontFamilyToolbarItem/>
        <telerik:RichTextEditorFontSizeToolbarItem/>
        <telerik:SeparatorToolbarItem/>
        <telerik:RichTextEditorBoldToolbarItem/>
        <telerik:RichTextEditorItalicToolbarItem/>
        <telerik:RichTextEditorUnderlineToolbarItem/>
        <telerik:SeparatorToolbarItem/>
        <telerik:RichTextEditorAlignLeftToolbarItem/>
        <telerik:RichTextEditorAlignCenterToolbarItem/>
        <telerik:RichTextEditorAlignRightToolbarItem/>
        <telerik:RichTextEditorAlignJustifyToolbarItem/>
        <telerik:SeparatorToolbarItem/>
        <telerik:RichTextEditorTextColorToolbarItem/>
        <telerik:RichTextEditorHighlightTextColorToolbarItem/>
        <telerik:SeparatorToolbarItem/>
        <telerik:RichTextEditorAddOrEditHyperlinkToolbarItem IsVisible="{OnPlatform Default='true', iOS='false', Android='false'}"/>
        <telerik:RichTextEditorRemoveHyperlinkToolbarItem IsVisible="{OnPlatform Default='true', iOS='false', Android='false'}"/>
        <telerik:RichTextEditorAddOrEditImageToolbarItem IsVisible="{OnPlatform Default='true', iOS='false', Android='false'}"/>
        <telerik:SeparatorToolbarItem IsVisible="{OnPlatform Default='true', iOS='false', Android='false'}"/>
        <telerik:RichTextEditorBulletingToolbarItem/>
        <telerik:RichTextEditorNumberingToolbarItem/>
        <telerik:SeparatorToolbarItem/>
        <telerik:RichTextEditorOutdentToolbarItem/>
        <telerik:RichTextEditorIndentToolbarItem/>
        <telerik:SeparatorToolbarItem/>
        <telerik:RichTextEditorTextFormattingToolbarItem/>
        <telerik:SeparatorToolbarItem/>
        <telerik:RichTextEditorClearFormattingToolbarItem/>
        <telerik:SeparatorToolbarItem/>
        <telerik:RichTextEditorStrikethroughToolbarItem/>
        <telerik:RichTextEditorSubscriptToolbarItem/>
        <telerik:RichTextEditorSuperscriptToolbarItem/>
        <telerik:SeparatorToolbarItem/>
        <telerik:RichTextEditorUndoToolbarItem/>
        <telerik:RichTextEditorRedoToolbarItem/>
        <telerik:RichTextEditorHyperlinkNavigationToolbarItem IsVisible="{OnPlatform Default='true', MacCatalyst='false', WinUI='false'}"/>
        <telerik:RichTextEditorImageNavigationToolbarItem IsVisible="{OnPlatform Default='true', MacCatalyst='false', WinUI='false'}"/>
    </telerik:RadRichTextEditorToolbar>
    <telerik:RadRichTextEditor x:Name="richTextEditor" Grid.Row="{OnIdiom Desktop=1, Phone=0}" />
</Grid>

RichTextEditor Toolbar Placement

Some specifics you'd need to take into account when placing RichTextEditorToolbar on the page:

  • On Android—When you place the RichTextEditor Toolbar below the RichTextEditor, you set the Application's WindowSoftInputModeAdjust to Resize. This setting causes the page to resize when the keyboard is shown, and in this way, if the RichTextEditorToolbar is on the bottom of the page, it will be displayed over the keyboard when it appears.

You can apply it on application level like this:

C#
App.Current.On<Android>().UseWindowSoftInputModeAdjust(WindowSoftInputModeAdjust.Resize);

For more details, check the Soft Keyboard Input Mode on Android from .NET MAUI documentation.

  • On iOS—If the RadRichTextEditorToolbar is positioned under the keyboard, when the keyboard shows, the control is translated over the keyboard so users can access it without a problem. Due to the .NET MAUI implementation, it is important that the RadRichTextEditorToolbar is placed in a container which bounds will contain it after the control is translated over the keyboard. Otherwise, the tap and pan gestures on the RadRichTextEditorToolbar will not work until the keyboard is hidden and the control is translated back to its original place.
  • RichTextEditorToolbar must have a greater ZIndex than the other elements in its parent layout to be visible (and not behind other views, like RichTextEditor) when translated over the keyboard. Also, it must be contained in the bounds of its parent layout after translation. In this case, set the ZIndex property to the RichTextEditorToolbar.

For the RichTextEditor Toolbar examples, see the SDKBrowser Demo Application and go to RichTextEditor > Toolbar.

Custom Toolbar

You can customize the toolbar by setting the AutoGenerateItems to False. Then decide which toolbar items to include. For more details on this—Review the Custom Toolbar article.

See Also