Anchor

As defined by the W3C:

An anchor is a piece of text which marks the beginning and/or the end of a hypertext link.

<FluentAnchor> wraps the <fluent-anchor> element, a web component implementation of an HTML anchor element leveraging the Fluent UI design system.

The <FluentAnchor> component supports the same visual appearances as the <FluentButton> component (accent, lightweight, neutral, outline, stealth) as well as a hypertext appearance for use inline with text.

Examples

Simple anchors

Example

Default

Anchor

With target

Anchor

With aria-label

With custom action

Link with no Href
Download: 

Appearance

Example
Neutral Accent Hypertext Lightweight Outline Stealth

Lorem ipsum dolor sit amet consectetur adipisicing elit. Nesciunt ut aliquam quas quod ipsam cupiditate, voluptate, corrupti doloremque totam dicta perspiciatis commodi consequatur reprehenderit laborum aliquid minima. Neque, recusandae. Adipisci.

Download: 

Anchors with icons

By placing the icon the content of the anchor, it is possible to specify a Color for the icon.

Example

Neutral appearance

Icon at start Icon at end Icon at start in content Icon at end in content

Hypertext appearance

By default, the margin between the icon and the link is equal to the margin that is used for the other appearances. If you find that margin to large, you can add the following to your CSS:


        /* for icon at the start */
        fluent-anchor[appearance="hypertext"]::part(start) {
            margin-inline-end: calc(var(--design-unit) * 1px);
        }
        /* for icon at the end */
        fluent-anchor[appearance="hypertext"]::part(end) {
        margin-inline-start: calc(var(--design-unit) * 1px);
        }
    

Do not use these styles if there is no icon being displayed with a hypertext. It will cause the hypertext to get a margin at the start/end.

Icon at start Icon at end Icon at start in content Icon at start in content
With icon in default slot:
Download: 

Documentation

FluentAnchor Class

Parameters

Name
Type
Default
Description
AppearanceAppearance?
Neutral
Gets or sets the visual appearance. See FluentAnchor.Appearance
Defaults to Appearance.Neutral
ChildContentRenderFragment?
Gets or sets the content to be rendered inside the component.
Downloadstring?
Prompts the user to save the linked URL. See a element for more information.
Hrefstring?
Gets or sets the URL the hyperlink references. See a element for more information.
Use Target parameter to specify where.
Hreflangstring?
Hints at the language of the referenced resource. See a element for more information.
IconEndIcon?
Gets or sets the Icon displayed at the end of anchor content.
IconStartIcon?
Gets or sets the Icon displayed at the start of anchor content.
Pingstring?
See a element for more information.
Referrerpolicystring?
See a element for more information.
Relstring?
See a element for more information.
Targetstring?
Gets or sets the target attribute that specifies where to open the link, if Href is specified.
Possible values: _blank | _self | _parent | _top.
Typestring?
See a element for more information.

EventCallbacks

Name
Type
Description
OnClickEventCallback

Methods

Name
Parameters
Type
Description
DisposeAsyncValueTask
Neutral
Accent
Hypertext
Lightweight
Outline
Stealth
Filled
An error has occurred. This application may no longer respond until reloaded. Reload 🗙