SkipLink
SM · 950B gzip budgetThe page's first focusable element, visible only once focused.
- Category
- Navigation
- Budget
- sm, single-purpose control
- External runtime
- React / React DOM only
axe fixtureSSR rendersource scanbundle budget
Preview
Live fixtureTry the component here. Locale-aware formatting and direction follow the selected language; example content and labels are not automatically translated. Overlay demos use interactive launchers.
Install
npx shadcn@latest add https://gear5-ui.vercel.app/r/skip-link.jsonCopies the source into your project. Pulls in 2 shared registry items: sanitize, cn.
New here? Set up Tailwind and import aliases first →Source & props
Edit on GitHub ↗Prop types and inline documentation are included below. This is repository source; the installer rewrites shared imports for your project.
import { sanitizeHref } from "../lib/sanitize";
import { cn } from "../lib/cn";
export interface SkipLinkProps {
href: string;
children?: React.ReactNode;
className?: string;
}
/**
* The first focusable element on the page for a keyboard user — invisible
* until it receives focus, at which point it must become visible; a skip
* link a sighted keyboard user cannot see when it is focused is not
* meaningfully different from no skip link at all.
*/
export function SkipLink({ href, children = "Skip to content", className }: SkipLinkProps) {
return (
<a
href={sanitizeHref(href)}
className={cn(
"sr-only focus:not-sr-only focus:fixed focus:start-4 focus:top-4 focus:z-50 focus:rounded-md focus:bg-blue-600 focus:px-4 focus:py-2 focus:text-on-accent",
className,
)}
>
{children}
</a>
);
}
What CI checks
Quality contract- Bundled, minified and gzipped against its tier budget
- Audited by axe in the state previewed above
- Rendered through react-dom/server with no browser globals
- Scanned for network calls, dangerous sinks, and unguarded animation