{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "skip-link",
  "title": "SkipLink",
  "description": "The \"Skip to main content\" link a keyboard or screen-reader user meets first on every page, so one Tab and Enter jump past the header and navigation.",
  "registryDependencies": [
    "@ouro/lib-class-name-check",
    "@ouro/lib-cn",
    "@ouro/lib-dev",
    "@ouro/lib-env",
    "@ouro/lib-use-dev-messages"
  ],
  "files": [
    {
      "path": "registry/ouro/components/ouro/skip-link/skip-link.tsx",
      "content": "\"use client\";\n\nimport { useRef, type AnchorHTMLAttributes, type JSX, type MouseEvent, type ReactNode, type Ref } from \"react\";\nimport { useAppearanceClassNameCheck } from \"@/registry/ouro/lib/ouro/class-name-check\";\nimport { cn } from \"@/registry/ouro/lib/ouro/cn\";\nimport { devWarn } from \"@/registry/ouro/lib/ouro/dev\";\nimport { useDevWarnings } from \"@/registry/ouro/lib/ouro/use-dev-messages\";\n\n/** The props SkipLink adds to the anchor attributes it passes through. */\nexport interface SkipLinkOwnProps {\n  /**\n   * The `id` of the element the link skips to, without `#`: the page's main content,\n   * `<main id=\"main\">`. It need not be focusable; the link makes it take focus.\n   * @default \"main\"\n   */\n  target?: string | undefined;\n  /** The link's text. @default \"Skip to main content\" */\n  children?: ReactNode;\n  /** Layout only: rarely needed, since the link places itself at the top of the screen. Appearance classes warn in development. */\n  className?: string | undefined;\n  ref?: Ref<HTMLAnchorElement> | undefined;\n\n  /** Not a prop. SkipLink takes the id, without `#`: `<SkipLink target=\"main\" />`. */\n  href?: { 'Use <SkipLink target=\"main\" /> (the id, without #)': never };\n  /** Not a prop. SkipLink takes the id: `<SkipLink target=\"main\" />`. */\n  to?: { 'Use <SkipLink target=\"main\" />': never };\n  /** Not a prop. The link's text is its children: `<SkipLink>Skip to recipes</SkipLink>`. */\n  label?: { 'Use <SkipLink>Skip to recipes</SkipLink>': never };\n}\n\n/** Props for {@link SkipLink}: its own props and the anchor attributes it passes through. */\nexport type SkipLinkProps = Omit<AnchorHTMLAttributes<HTMLAnchorElement>, keyof SkipLinkOwnProps> & SkipLinkOwnProps;\n\n// Class strings are literal so the app's Tailwind finds them when it compiles. Until it has\n// focus the link is clipped to a 1px box, still read by screen readers; a fixed element parked\n// above the top edge would still paint in a full-page screenshot of a scrolled page.\nconst base =\n  \"fixed top-2 start-2 z-(--ouro-layer) box-border inline-flex min-h-9 pointer-coarse:min-h-11 items-center rounded-ouro-md \" +\n  \"bg-background px-4 text-sm leading-5 font-medium text-foreground underline underline-offset-4 shadow-(--shadow-lg) ring-1 ring-border/60 \" +\n  \"outline-ring outline-offset-2 focus-visible:outline-2 focus-visible:outline-solid print:hidden \" +\n  \"not-focus:m-0 not-focus:size-px not-focus:min-h-0 not-focus:overflow-hidden not-focus:p-0 not-focus:whitespace-nowrap not-focus:ring-0 not-focus:[clip-path:inset(50%)]\";\n\n/** Whether the element takes focus without a tabindex of its own. */\nfunction focusable(element: HTMLElement): boolean {\n  return element.tabIndex >= 0 || element.hasAttribute(\"tabindex\");\n}\n\n/**\n * The \"Skip to main content\" link a keyboard or screen-reader user meets first on every\n * page, so one Tab and Enter jump past the header and navigation. It stays out of sight\n * until it has focus, then shows at the top corner of the screen. It keeps `href=\"#main\"`\n * for pages without JavaScript; with it, the link moves focus to the target and scrolls it\n * into view without adding a history entry, so Back still leaves the page.\n *\n * Render it as the first element in the page's body, before the header, and give the main\n * content its id: `<main id=\"main\">`.\n *\n * Use `Link` instead for a link that shows all the time, and a table of contents of `Link`s\n * for jumps between sections of a long page.\n *\n * @group Navigation\n * @see https://ui.ouroboros.bot/docs/skip-link\n *\n * @example\n * <body>\n *   <SkipLink />\n *   <Navbar label=\"Main\" items={items} />\n *   <main id=\"main\">…</main>\n * </body>\n * @claim \"link a keyboard or screen-reader user meets first\" registry/ouro/components/ouro/skip-link/skip-link.test.tsx verify:testExists(registry/ouro/components/ouro/skip-link/skip-link.test.tsx::SkipLink > is the first tab stop, and Enter moves focus to the main content without a history entry)\n */\nexport function SkipLink(props: SkipLinkProps): JSX.Element {\n  const {\n    target = \"main\",\n    children = \"Skip to main content\",\n    className,\n    onClick,\n    // Guard props (hint types), dropped here so they never reach the DOM.\n    href,\n    to,\n    label,\n    ...rest\n  } = props;\n  useAppearanceClassNameCheck(\n    \"SkipLink\",\n    className,\n    process.env.NODE_ENV !== \"production\"\n      ? (token: string) => `remove \"${token}\"; SkipLink sets its own look from the theme`\n      : /* istanbul ignore next @preserve -- production only */ \"\",\n  );\n  const id = target.replace(/^#/, \"\");\n  useDevWarnings(\n    \"SkipLink\",\n    process.env.NODE_ENV !== \"production\"\n      ? () => [\n          href !== undefined && [\"href is not a prop\", `<SkipLink target=\"${typeof href === \"string\" ? String(href).replace(/^#/, \"\") : \"main\"}\" />`],\n          to !== undefined && [\"to is not a prop\", '<SkipLink target=\"main\" />'],\n          label !== undefined && [\"label is not a prop\", `<SkipLink>${typeof label === \"string\" ? label : \"Skip to main content\"}</SkipLink>`],\n          target.startsWith(\"#\") && [`target=\"${target}\" starts with #`, `<SkipLink target=\"${id}\" />`],\n        ]\n      : /* istanbul ignore next @preserve -- production only */ undefined,\n  );\n  // Each link names a missing target once, when it is used: the target may render after the link.\n  const instance = useRef({});\n  const skip = (event: MouseEvent<HTMLAnchorElement>) => {\n    onClick?.(event);\n    // A modified click (a new tab or window) keeps the browser's own behaviour.\n    if (event.defaultPrevented || event.button !== 0 || event.metaKey || event.altKey || event.ctrlKey || event.shiftKey) return;\n    const element = document.getElementById(id);\n    if (!element) {\n      /* istanbul ignore else @preserve -- the else path exists only in production bundles; scripts/dev-strip.test.mjs covers it */\n      if (process.env.NODE_ENV !== \"production\") devWarn(\"SkipLink\", `no element has id=\"${id}\", so the link skips nowhere`, `<main id=\"${id}\">`, instance.current);\n      return;\n    }\n    event.preventDefault();\n    if (!focusable(element)) element.setAttribute(\"tabindex\", \"-1\");\n    element.focus({ preventScroll: true });\n    element.scrollIntoView({ block: \"start\" });\n  };\n  return (\n    <a\n      data-ouro-control=\"skip-link\"\n      data-ouro-part=\"root\"\n      {...rest}\n      href={`#${id}`}\n      onClick={skip}\n      data-ouro=\"skip-link\"\n      className={cn(base, className)}\n    >\n      {children}\n    </a>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/skip-link/skip-link.tsx"
    }
  ],
  "docs": "The \"Skip to main content\" link a keyboard or screen-reader user meets first on every page, so one Tab and Enter jump past the header and navigation. Import: import { SkipLink } from \"@/components/ouro/skip-link/skip-link\", with @/components replaced by your components alias (aliases.components in components.json, such as ~/components). Also installed: the helpers it imports in lib/ouro. Needs ouro-base in your stylesheet: add that item once per app, from the same place as this one, if you have not. Docs: https://ui.ouroboros.bot/docs/skip-link.md Ouro UI v1.3.257.",
  "type": "registry:ui"
}