Providing contenteditable functionality for Blazor
- Automatically sizes to prefilled text
- Automatically sizes to to text as it's typed
Include NuGet package from https://www.nuget.org/packages/BlazorContentEditable/
- Add
@using BlazorContentEditable
to _Imports.razor - Add
<script src="_content/BlazorContentEditable/BlazorContentEditable.js"></script>
to wwwroot/index.html
- Add
@using BlazorContentEditable
to _Imports.razor - Add
<script src="_content/BlazorContentEditable/BlazorContentEditable.js"></script>
to Pages/_Host.cshtml
<BlazorContentEditableComponent @bind-Value="Text" />
- @bind-Value - the property to which the component should be bound
- Enabled - (optional, defaults to true) - allows the component to be disabled directly
Enabled="false"
or conditionallyEnabled="@(UserIsAuthorized ? true : false)"
- CSSClass - (optional) add css classes
- CSSStyle - (optional) add css styles
- Rows - (optional, defaults to 1) allows setting the number of rows (height) the component should display if no text is present
- Columns - (optional) sets the number of columns (width) for the component (1 column = 1 average-width character)
- Width - (optional, defaults to 100% if neither Columns nor Width are set) sets the width of the component with CSS
- Changed to auto-resizing TextArea
- Can conditionally disable component
- Use
@using BlazorContentEditable
in _Imports.razor instead of@using BlazorContentEditable.Source