The PlumaLink component renders a styled version of PlainLink. Just like PlainLink, it will use PlumaProvider's linkComponent, if it exists.
For more details on how to set up the link component on PlumaProvider, visit the provider's docs.
Link works just like PlainLink:
The isExternal prop is automatically inferred from the URL (http://, https://, mailto:, tel:), but you can still explicitly set it if needed:
To render the component in the "underlined" variant, use the isUnderlined prop:
To render the component in the "secondary" variant, use the variant prop.
To render the component without an underline, use the isUnderlined prop:
A Link can also be rendered with an icon, for example:
The icon can be placed on either side of the text via the iconPosition prop (by default, leading):
If you need to use a custom icon that isn't part of the Pluma Icon set, you can use the iconSrc prop to provide a URL to an image. The image will be automatically sized to match the button's icon size:
Custom image icons support the same positioning options as standard icons:
You may sometimes need to render a button tag that's styled like the Link component.
For example, you might want to render a clickable button inside a paragraph, which
will perform an action on click (rather than navigating somewhere).
Do do so, pass in the onClick prop to the Link component:
If true, the link will automatically show the spinner when the onClick function is called and it returns a promise.
If false, the spinner will only show if the isLoading prop is set to true. By default, this is true.
The URL passed into the link component (or a tag)
The name of an icon (from Pluma Icons) to render in the link
Override an icon's vertical alignment. By default the alignment is uppercase when the position is leading, and lowercase when the position is trailing
Default:leading
Which side of the text the icon should be rendered on. leading renders the icon before the text, trailing renders it after.
Default:sm
What size to render the icon in (if an icon is provided)
The source URL of a custom image icon to render in the link. When provided, this will be rendered using the Image component with icon sizing. Use v2 sizing (icon-v2-sm, icon-v2-md, icon-v2-lg, icon-v2-xl) for new implementations. The image will always have alt="" as it is purely decorative - meaning comes from link text or aria-label.
Whether the link should be disabled (this prevents click handlers from firing)
Whether the link should render in an error state
When this flag is true, an a tag will be used instead of the provider's linkComponent, even if it exists.
Additionally, target="_blank" rel="noopener noreferrer" will be added automatically
Shows a spinner in the link overlaid on top of the link's content. The link will act as if disabled while in the loading state.
Whether the link should be underlined
This is passed into the provider's linkComponent.
It can be used by the link component implementation to handle replaceState instead of pushState
Whether the content of the link should be truncated if it overflows its container.
Legacy styling flag for backwards compatibility
Default:primary
The visual style variant of the link
This allows turning off the automatic addition of target="_blank" rel="noopener noreferrer".
This can be used for links to other protocols like mailto: