Blazor RichTextEditor
A dependency-free rich text editor with a grouped Bootstrap toolbar.
Full toolbar #
Start with the complete toolbar when authors need the full RichTextEditor feature set in one place. Keep
How to use:
Disabled set to false so every toolbar action remains available, from document styles and text formatting through media, tables, history, printing, and fullscreen mode.
How to use:
- Add
RichTextEditorto the page and provide an initialValue. - Omit
ToolbarItemsto render every supported toolbar control. - Keep
Disabledset tofalse, then use toolbar actions to build a complete document.
Article draft #
Use a focused authoring toolbar to turn a rough release-note draft into structured, scannable content. While
How to use:
Disabled is false, each toolbar action can apply headings, emphasis, color, alignment, lists, and quotations.
How to use:
- Choose the commands that match the authoring workflow in
ToolbarItems. - Place the caret in a paragraph or select text in the draft.
- Use each toolbar action needed for a heading, emphasis, list, alignment, or quotation as the document takes shape.
Publish rich update #
Give a publishing workflow only the insertion commands it needs to add a link, image, separator, or table to an already-authored announcement. This example does not configure
How to use:
ImageUploadHandler, so its Image dialog intentionally shows only the Image URL tab. Keep Disabled set to false while authors use each toolbar action.
How to use:
- Configure the insertion-focused commands in
ToolbarItems. - Place the caret where the new content belongs in the announcement.
- Use the link, image, horizontal-rule, or table toolbar action and complete its dialog when prompted.
Host-controlled image upload #
Configure
How to use:
ImageUploadHandler in the host application instead of configuring a browser endpoint. The Upload image tab is conditional: editors without this callback intentionally show only Image URL. This shared demo supplies the callback, accepts JPEG, PNG, WebP, and GIF files up to 5 MB, returns a trusted temporary HTTPS preview URL, and exposes callback counts so rejected files can be distinguished from host-handler failures. The selectable outcomes also demonstrate cancellation and domain policy rejection.
How to use:
- Set
ImageUploadHandler, the allowed raster types, size limit, and optional HTTPS domain allow-list. - Open the Image dialog, choose Upload image, and select a valid local raster image.
- Review the preview and accessibility options before insertion; use the simulated outcomes to observe host failure, cancellation, and URL-policy feedback.
Disabled #
Use
How to use:
Disabled when rich text should remain visible for review. Editing is disabled: users cannot change the content or invoke a toolbar action.
How to use:
- Provide the rich text through
Value. - Set
Disabledtotruewhen editing is disabled. - Keep the visible content as context; hovering the inactive toolbar explains that editing is disabled, and no toolbar action is available.
Form validation #
Use
How to use:
ValueExpression inside an EditForm to validate the editor's plain-text content while retaining its HTML separately for submission. Keep Disabled set to false while users edit content and use a toolbar action.
How to use:
- Add
DataAnnotationsValidatorand aValidationMessagefor the model property. - Set
ValueExpressionto the validated model property and update that property fromValueChanged. - Keep editing enabled, then delete the editor content and submit to see required validation feedback before entering content and submitting again.
Events #
Use
How to use:
ValueChanged to react to committed content and show its text metrics in surrounding UI. Keep Disabled set to false while observing edits and toolbar actions. This typing-focused example deliberately reports the callback without assigning its HTML back to the editor value.
How to use:
- Handle
ValueChangedto receive sanitized HTML, plain text, and count metrics after an edit is committed. - Update external UI such as metrics or a save indicator without writing the callback HTML back into the active editor value.
- Edit the text or use a toolbar action, then observe the committed word and character counts.