← All Components
<mth-link>
Token-styled accessible hyperlink with automatic noopener noreferrer hardening and URL allowlist checks.
When NOT to use: Use a lightweight @methane-ui/css layout class instead of a custom element when static CSS suffices.
Live Interactive Preview
Ready · interact with <mth-link>, or toggle Theme, Direction (LTR/RTL), or props above.
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/ui/link"></script>
<mth-link underline="always">Example</mth-link>import '@methane-ui/ui/link';
import '@methane-ui/react';
export function Example() {
return <mth-link underline="always">Example</mth-link>;
}<script setup lang="ts">
import '@methane-ui/ui/link';
</script>
<template>
<mth-link underline="always">Example</mth-link>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/ui/link';
import { MthLinkDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthLinkDirective],
template: `<mth-link underline="always">Example</mth-link>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/ui/link';
import MthLink from '@methane-ui/svelte/MthLink.svelte';
</script>
<MthLink underline="always">Example</MthLink>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
href | href | string | "" | Destination URL (https:, http:, mailto:, tel:, or relative paths). |
target | target | string | "" | Link browsing context target. |
rel | rel | string | "" | Relationship attribute; _blank targets automatically enforce noopener noreferrer. |
external | external | boolean | false | Marks link as external, defaulting target to _blank when unset and displaying an indicator. |
disabled | disabled | boolean | false | Marks the link aria-disabled="true", omits href, and blocks activation. |
underline | underline | 'always' | 'hover' | 'none' | "always" | Underline behavior (always, hover, or none). |
Events
| Event | Detail Type | Description |
|---|---|---|
mth-press | { originalEvent: Event } | Cancelable event fired when an enabled link is activated. |
APG Keyboard Matrix
| Key | Direction | When | Expected Behavior |
|---|---|---|---|
| Enter | both | Enabled link is focused | Activates the link and emits cancelable mth-press |
Accessibility Checklist
| Category | Requirement | Verified By |
|---|---|---|
| aria | All aria-* IDREFs resolve within the same DOM root (ADR-003). | scanSameRootAria |
| focus | delegatesFocus: true with zero host internals.role (ADR-014). | lint-plugin & spec-compiler |
| contrast | Renders legible borders, focus outlines, and selection indicators under forced-colors: active. | Playwright forced-colors matrix |
| keyboard | Implements all 1 APG keyboard transitions across LTR/RTL. | mth-link.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(disabled), :state(external). | Conformance suite |
| i18n | Routes 1 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |