Skip to content

Link

Link

A hyperlink with Fluent link styling. Renders an <a> by default; as renders a router link (<Link as={RouterLink} to="/">) or a <button> styled as a link (type="button" by default).

- Without href, the <a> runs an action instead of navigating ("Show more"): it keeps its element and gets role="button", a tab stop and Enter/Space activation (the consumer's role and tabIndex win). A non-interactive as (span, div) is treated the same way; any href string, '' included, keeps the link semantics.

- background (brand, inverted) recolors the link for a brand or inverted surface.

Examples

Default

export const Default: Story = {};

Inline In Text

Before you start, read the documentation and check the release notes.

export const InlineInText: Story = {
  render: (args) => (
    <Text as="p">
      Before you start, <Link {...args}>read the documentation</Link> and check the release notes.
    </Text>
  ),
};

Standalone

export const Standalone: Story = {
  args: {
    appearance: 'standalone',
    children: 'See pricing',
  },
};

Subtle

export const Subtle: Story = {
  args: {
    appearance: 'subtle',
    children: 'Privacy',
  },
};

Disabled

export const Disabled: Story = {
  args: {
    children: 'Disabled link',
    disabled: true,
  },
};

Disabled Focusable

export const DisabledFocusable: Story = {
  args: {
    children: 'Download the report',
    disabledFocusable: true,
  },
};

As Button

export const AsButton: ButtonStory = {
  args: {
    as: 'button',
    href: undefined,
    children: 'Show more',
  },
};

Without Href

export const WithoutHref: Story = {
  args: {
    href: undefined,
    children: 'Show more',
  },
};

Appearances

export const Appearances: Story = {
  argTypes: {
    appearance: { control: false },
  },
  render: (args) => (
    <div className="flex gap-4">
      <Link {...args} appearance="inline">
        Inline
      </Link>
      <Link {...args} appearance="standalone">
        Standalone
      </Link>
      <Link {...args} appearance="subtle">
        Subtle
      </Link>
    </div>
  ),
};

On Brand And Inverted Backgrounds

export const OnBrandAndInvertedBackgrounds: Story = {
  argTypes: {
    background: { control: false },
  },
  render: (args) => (
    <div className="flex flex-col gap-4">
      <p className="bg-wave-primary text-wave-primary-foreground p-4">
        Brand surface:{' '}
        <Link {...args} background="brand">
          read the documentation
        </Link>{' '}
        or{' '}
        <Link {...args} background="brand" appearance="standalone">
          see pricing
        </Link>
        .
      </p>
      <p className="bg-wave-inverted text-wave-inverted-foreground p-4">
        Inverted surface:{' '}
        <Link {...args} background="inverted">
          read the documentation
        </Link>{' '}
        or{' '}
        <Link {...args} background="inverted" appearance="subtle">
          see pricing
        </Link>
        .
      </p>
    </div>
  ),
};

Props

NameTypeRequiredDefaultDescription
appearance'inline' | 'standalone' | 'subtle'No'inline'

Color treatment (see LinkAppearance for where each one may be used).

background'default' | 'brand' | 'inverted'No'default'

The surface the link sits on (Fluent's link colors on brand and inverted backgrounds): brand gives it the on-brand text color and focus ring, inverted the inverted-surface ones, so it stays readable on bg-wave-primary and bg-wave-inverted (the underline of inline still marks it as a link). Renders data-background while it is not default.

disabledbooleanNofalse

Makes the link unavailable. An <a> drops its href (no navigation by middle-click, the context menu or drag), keeps role="link" (role="button" when it had no href), and gets aria-disabled="true", data-disabled and tabIndex={-1} (none can be overridden); a custom as (router link) gets the same attributes. Clicks, Enter and Space are prevented: your onClick is not called and the click does not reach ancestor click handlers. as="button" uses the native disabled attribute.

disabledFocusablebooleanNofalse

Marks the link unavailable but keeps it focusable and in the tab order: for a toolbar item or a disabled link that needs a Tooltip. Renders aria-disabled="true", data-disabled and data-disabled-focusable; an <a> drops its href, keeps role="link" (role="button" when it had no href) and gets tabIndex={0}, and as="button" gets these attributes instead of the native disabled. Clicks, Enter and Space are prevented; your onClick is not called and the click does not reach ancestor click handlers. Wins over disabled when both are set. In a Toolbar it stays in the arrow-key order.

asReact.ElementTypeNo'a'

Render as a different element or component (its props are type-checked).

Any other prop is passed to the element it renders (HTMLAnchorElement).

Stable class names

PartClass
rootwave-link