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
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
Brand surface: read the documentation or see pricing.
Inverted surface: read the documentation or see pricing.
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
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
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): |
disabled | boolean | No | false | Makes the link unavailable. An |
disabledFocusable | boolean | No | false | 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 |
as | React.ElementType | No | '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
| Part | Class |
|---|---|
root | wave-link |