DeepWorks Studios Blazor Component Library

Demo user Administrator ยท Blazor Server Library 20261206222504-6e8ff32.dirty

DwsAnchor

The reason for an anchor link is that it is not possible to use an HTML anchor in Blazor. Here, a component is implemented using JavaScript.

API Reference

Anchor

A link to an element with an ID on the same page: a click scrolls to it.

Show Code
Anchor.razor
<DwsAnchorLink Name="AnchorDemo_Link-Chapter1" href="#chapter1">Chapter 1</DwsAnchorLink>
<DwsTypography Name="AnchorDemo_chapter1_Title" ID="chapter1" Typography="DwsTypographyType.Heading2">Chapter 1</DwsTypography>
Anchor.razor.cs
// No additional code-behind is required for this example.

Color

Color sets the text colour of the link from the theme.

Show Code
Anchor.razor
<DwsAnchorLink Name="AnchorDemo_Link-Chapter2" href="#chapter2" Color="DwsColor.Link">Chapter 2</DwsAnchorLink>

<DwsTypography Name="AnchorDemo_chapter2_Title" ID="chapter2" Typography="DwsTypographyType.Heading2">Chapter 2</DwsTypography>
Anchor.razor.cs
// No additional code-behind is required for this example.

Tooltip

Tooltip shows on hover, on keyboard focus and on a long press, and describes the link for screen readers.

Chapter 3 Tooltip example
Show Code
Anchor.razor
<DwsAnchorLink Name="AnchorDemo_Link-Chapter3" href="#chapter3" Tooltip="Tooltip example">Chapter 3</DwsAnchorLink>

<DwsTypography Name="AnchorDemo_chapter3_Title" ID="chapter3" Typography="DwsTypographyType.Heading2">Chapter 3</DwsTypography>
Anchor.razor.cs
// No additional code-behind is required for this example.

Underline

Underline keeps the underline visible; without it the underline appears on hover only.

Show Code
Anchor.razor
<DwsAnchorLink Name="AnchorDemo_Link-Chapter4" href="#chapter4" Underline="true">Chapter 4</DwsAnchorLink>

<DwsTypography Name="AnchorDemo_chapter4_Title" ID="chapter4" Typography="DwsTypographyType.Heading2">Chapter 4</DwsTypography>
Anchor.razor.cs
// No additional code-behind is required for this example.

Disabled link

Disabled renders the link greyed out; a click does nothing.

Show Code
Anchor.razor
<DwsAnchorLink Name="AnchorDemo_Link-Disabled" href="https://learn.microsoft.com/aspnet/core/blazor/" Disabled="true" StartIcon="@Icons.BS.BoxArrowUpRight">Disabled external link (does nothing)</DwsAnchorLink>
Anchor.razor.cs
// No additional code-behind is required for this example.

Chapter 1

A paragraph with a huge bottom margin to make the page scroll.

Chapter 2

A paragraph with a huge bottom margin to make the page scroll.

Chapter 3

A paragraph with a huge bottom margin to make the page scroll.

Chapter 4

A paragraph with a huge bottom margin to make the page scroll.

Interface-Description

Name Typ Default Description
href string string.Empty Target anchor or URL. Fragment links (e.g. #section1) scroll to the matching element; other internal routes are routed through IDwsNavigationService.NavigateTo so navigation participates in the app's save-guard/pre-post-navigate hooks. External URLs (http(s), mailto, tel) and hrefs with a target attribute fall back to native browser navigation. Passed through unmatched attributes.
ChildContent RenderFragment? null Link label content.
Color DwsColor DwsColor.Primary Text colour of the link, applied as the --dws-link-color CSS variable.
Underline bool false When true, underline is always visible. When false, underline appears only on hover.
StartIcon string string.Empty Icon class rendered before the link text, as a decorative DwsIcon in the link's colour and font size.
EndIcon string string.Empty Icon class rendered after the link text, as a decorative DwsIcon in the link's colour and font size.
Tooltip string string.Empty Tooltip text, shown by a DwsTooltip: on hover, on keyboard focus and on a long press (touch). It also describes the link (aria-describedby).
TooltipPosition DwsTooltipPosition DwsTooltipPosition.Top Preferred side of the tooltip; it flips when it does not fit.
OnClick EventCallback<MouseEventArgs> default Raised when the link is clicked, before any in-page scroll or navigation happens.
ForceLoad bool false Forces a full page reload when navigating to an internal href instead of a client-side SPA navigation.
ScrollOffset int? null For a #target link: pixels kept free above the target after scrolling (a sticky header). Applied for this one scroll, so links on one page can differ. Null: the target's own scroll-margin-top from CSS applies.
Attributes IDictionary<string, object> new Dictionary<string, object>() Further attributes of the link element, for example href or aria-label.
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 Disables the form control, ensuring it doesn't participate in form submission.
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.
An error has occurred. This app may no longer respond until reloaded.