Skip to content
IzzyBlazor 0.1.0-alpha.17

Enter all results ↑ ↓ move Esc close

Anchor

A text link, internal or external.

JavaScript off: what the HTML and CSS do on their own.

A text link in the accent color. External opens it in a new tab, with an icon and a note for screen readers.

Usage

razor
Read the <Anchor Href="/docs">docs</Anchor>.
<Anchor Href="https://github.com/..." External>GitHub</Anchor>

Use External to open a link in a new tab, with an icon and a note for screen readers.

Preview

Read the install guide before you begin.

The source is on GitHub (opens in a new tab).

Code

NewTab.razor
<Stack Gap="3" Grow>
    <TextBlock>Read the <Anchor Href="docs/get-started/blazor-web-app">install guide</Anchor> before you begin.</TextBlock>
    <TextBlock>The source is on <Anchor Href="https://github.com/enabledevmode/izzyblazor" External>GitHub</Anchor>.</TextBlock>
</Stack>

Underline and color

Use Underline for links whose place already says "link", and Inherit to take the color of the text around it.

Mode support

What works in each mode, Anchor
FeatureOffStaticLive
EverythingYesYesYes

Off: JavaScript disabled. Static: a static SSR page with IzzyBlazor's script. Live: an interactive page (Server, WebAssembly or Auto).

Accessibility

  • It renders a native a with an href, so Enter and focus work as the browser defines them.
  • The link text is its name, so write text that makes sense on its own, not "Click here".
  • An external link says it opens a new tab (NewTabLabel), even with HideExternalIcon.
  • AnchorUnderline.Hover and AnchorUnderline.None leave only color to mark the link in text; keep them for links whose place says "link", such as a nav.

Parameters

Anchor parameters
PropTypeDefault
HrefWhere it goes.stringRequired
ExternalOpens in a new tab (target="_blank" rel="noopener noreferrer"), with an icon after the text.boolfalse
HideExternalIconLeaves out an external link's icon, for repeated links where it would be noise (a list of lessons, say).boolfalse
UnderlineWhen it's underlined.AnchorUnderlineAnchorUnderline.Always
InheritUses the surrounding text color instead of the accent, still underlined, for links in muted text or on colored backgrounds.boolfalse
NewTabLabelRead to screen readers after an external link's text.string?"(opens in a new tab)"
ChildContentThe link text.RenderFragment?

See also

  • Button: submits, resets, links or runs C#.
  • IconButton: a square button with a required label.
  • Prose: styles plain HTML, such as rendered Markdown.