Componentnavigation1.18 KB gzipZero dependencies
Keyboard Nav Helper
Keyboard shortcut overlay opened with the ? key.
Preview
Live Preview
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add keyboard-nav-helperOr install the full npm package:
npm install bigbulluiUsage
tsx3 lines
import { KeyboardNavHelper } from "@/components/ui/keyboard-nav-helper"; <KeyboardNavHelper />Source code
keyboard-nav-helper.tsx + 2 helpersZero third-party dependencies (3 local files shown in tabs below).
tsxkeyboard-nav-helper.tsx93 lines
"use client"; import * as React from "react";import { getFocusable, lockBodyScroll, registerEscapeLayer, trapFocus } from "./lib/focus-trap";import { cn } from "./lib/utils"; export interface KeyboardShortcut { keys: string[]; label: string;} export interface KeyboardNavHelperProps extends React.HTMLAttributes<HTMLDivElement> { shortcuts: KeyboardShortcut[];} /** Keyboard shortcuts modal overlay triggered by "?" key. */export function KeyboardNavHelper({ shortcuts, className, ...props }: KeyboardNavHelperProps) { const [open, setOpen] = React.useState(false);Props
| Prop | Type | Description |
|---|---|---|
| shortcuts | KeyboardShortcut[] | Configures shortcuts. |