A styled anchor element with support for semantic color tones and an unstyled escape hatch.
See the Usage Guidelines
for when to use Button, IconButton, Link, or LinkButton.
import { Link } from '@wordpress/ui';
LinksPermalink to this section
PropsPermalink to this section
| Name | Default | Description |
|---|---|---|
target |
Where to open the linked document. When both | |
variant | 'default' |
The visual treatment of the link.
|
tone | 'brand' |
The tone of the link. Tone describes a semantic color intent.
Only applies when |
openInNewTab | false |
Adds a visual indicator and accessible notice for opening in a new tab.
Defaults |
children |
The content to be rendered inside the component. | |
style |
CSS style to apply to the element. | |
className |
CSS class name to apply to the element. | |
render |
Replaces the component’s default HTML element using a given React element, or a function that returns a React element. |
ExamplesPermalink to this section
DefaultPermalink to this section
const Default = () => <Link href="#">Learn more</Link>;
Open In New TabPermalink to this section
const OpenInNewTab = () => <Link href="https://wordpress.org" openInNewTab>Visit WordPress.org</Link>;
All Tones And VariantsPermalink to this section
Note: tone has no effect on unstyled variant
const AllTonesAndVariants = ( args ) => (
<Stack direction="column" gap="lg">
{ ( [ 'brand', 'neutral' ] as const ).map( ( tone ) =>
( [ 'default', 'unstyled' ] as const ).map( ( variant ) => (
<Stack
direction="column"
gap="xs"
key={ `${ tone }-${ variant }` }
>
<Text variant="heading-sm">
{ tone } tone, { variant } variant
</Text>
<Link { ...args } tone={ tone } variant={ variant } />
</Stack>
) )
) }
</Stack>
);
InlinePermalink to this section
const Inline = () => <Text variant="body-md" render={ <p /> }>This is a paragraph with an <Link>inline link</Link>that inherits its
typography from the parent Text component.
</Text>;
StandalonePermalink to this section
When composing Text and Link via the render prop, keep Text as the
host and pass Link via render so the resulting element stays an <a>.
const Standalone = ( args ) => (
<Text variant="body-md" render={ <Link { ...args } /> }>
A standalone link with body-md typography
</Text>
);