Link
Navigates somewhere. Always underlined so links are never confused with buttons.
Example
Read the
<p> Read the <focsd-link href="#">migration guide</focsd-link> or check the <focsd-link href="https://example.com" external>status page</focsd-link>.</p>Usage
Import the module once, then use the tag like any HTML element. Every framework below renders the same element; see Frameworks for setup.
<script type="module"> import '@focsd-dev/components/focsd-link.js';</script>
<focsd-link href="#">migration guide</focsd-link>import { Link } from '@focsd-dev/react';
export function Example() { return <Link href="#">migration guide</Link>;}<script setup>import '@focsd-dev/components/focsd-link.js';</script>
<template> <focsd-link href="#">migration guide</focsd-link></template>// Add CUSTOM_ELEMENTS_SCHEMA to the component's schemas, then:import '@focsd-dev/components/focsd-link.js';
// template<focsd-link href="#">migration guide</focsd-link><script> import '@focsd-dev/components/focsd-link.js';</script>
<focsd-link href="#">migration guide</focsd-link>API
Attributes
| Attribute | Property | Type | Default |
|---|---|---|---|
href | href | string | — |
external | external | boolean | false |
target | target | string | — |
rel | rel | string | — |
download | download | string | null | null |
hreflang | hreflang | string | — |
type | type | string | — |
referrerpolicy | referrerPolicy | string | — |
ping | ping | string | — |
Slots
| Slot | Description |
|---|---|
(default) | Default content. |
CSS parts
Style the inside of the component with ::part(), for example focsd-link::part(link).
| Part | Description |
|---|---|
link | The link element. |
Accessibility
target="_blank"addsnoopenerand announces "opens in new tab".download,hreflang,type,referrerpolicyandpingare forwarded.- A native
<a>inside the shadow root, with focus delegated to it. externalopens a new tab and adds "(opens in new tab)" to the accessible name, so the change of context is announced.
Keyboard
| Key | Action |
|---|---|
| Enter | Follows the link |
Ask the docs
Hi, what are you building?
Ask about any component, theming, forms or frameworks. I answer with the right component, a snippet and a link to its docs.