Skip to content

← All components

Foundation and layout

SkipLink

Keyboard shortcut to the primary page content.

Live example

Usage

Each example includes the complete adapter-specific parameter reference. Copy it as a starting point, then remove options your use case does not need.

React

tsx
import { SkipLink } from "@cofob/design-system-react";

/**
 * Complete SkipLink parameter reference.
 * @param targetId/href
 *   type: string
 *   default: "main-content" / "#main-content"
 *   example: "main-content" / "#main-content"
 * @param children
 *   type: ReactNode | Svelte Snippet | child HTML
 *   default: —
 *   example: children / snippet / child HTML
 * @param anchor attributes
 *   type: native element attributes
 *   default: —
 *   example: class / style / aria-* / data-*
 */
export function SkipLinkExample() {
  return (
    <SkipLink targetId="content" />
  );
}

Svelte

svelte
<script lang="ts">
  import { SkipLink } from "@cofob/design-system-svelte";

  // Complete SkipLink parameter reference.
  // targetId/href
  //   type: string
  //   default: "main-content" / "#main-content"
  //   example: "main-content" / "#main-content"
  // children
  //   type: ReactNode | Svelte Snippet | child HTML
  //   default: —
  //   example: children / snippet / child HTML
  // anchor attributes
  //   type: native element attributes
  //   default: —
  //   example: class / style / aria-* / data-*
</script>

<SkipLink targetId="content" />

HTML

html
<!--
  Complete SkipLink parameter reference.
  targetId/href
    type: string
    default: "main-content" / "#main-content"
    example: "main-content" / "#main-content"
  children
    type: ReactNode | Svelte Snippet | child HTML
    default: —
    example: children / snippet / child HTML
  anchor attributes
    type: native element attributes
    default: —
    example: class / style / aria-* / data-*
-->
<a class="cf-skip-link" href="#content">Skip to content</a>

<script type="module">
  import { initDesignSystem } from "@cofob/design-system-css";

  const designSystem = initDesignSystem(document);
  window.addEventListener("pagehide", () => designSystem.destroy(), { once: true });
</script>

Parameters

Adapter differences are explicit. Native element attributes are forwarded in React and Svelte and can be written directly in HTML.

ParameterTypeDefaultAdaptersExampleDescription
targetId/hrefstring"main-content" / "#main-content"React · Svelte · HTML"main-content" / "#main-content"Main content destination; React accepts an ID, while Svelte and HTML accept an href.
childrenReactNode | Svelte Snippet | child HTMLReact · Svelte · HTMLchildren / snippet / child HTMLIdiomatic adapter composition content.
anchor attributesnative element attributesReact · Svelte · HTMLclass / style / aria-* / data-*Forwards native class/style, accessibility, event, and data attributes to the root element.