Loading...
Loading...
Embed the Real A11y Semantic Navigator panel in an app with @real-a11y-dev/react (SemanticNavigator, hooks) or @real-a11y-dev/inspector (createInspector). Use for Next.js / Vite / vanilla embeds and keeping the panel out of production bundles.
npx skill4agent add real-a11y/skills embed-semantic-navigator| Stack | Package |
|---|---|
| React | |
| Any other / vanilla | |
if (import.meta.env.DEV)import()import { lazy, Suspense, useRef } from "react";
const SemanticNavigator = lazy(() =>
import("@real-a11y-dev/react").then((m) => ({
default: m.SemanticNavigator,
})),
);
export function DevAuditOverlay({ children }: { children: React.ReactNode }) {
// Vite: `import.meta.env.DEV`. Webpack/Next: `process.env.NODE_ENV !== "production"`.
if (!import.meta.env.DEV) return <>{children}</>;
const rootRef = useRef<HTMLDivElement>(null);
return (
<div ref={rootRef}>
{children}
<Suspense fallback={null}>
<SemanticNavigator root={rootRef} mode="a11y" floating />
</Suspense>
</div>
);
}root<main><DevAuditOverlay><App /></DevAuditOverlay>useSemanticTreeuseActiveModalwindow is not definedimport { createInspector } from "@real-a11y-dev/inspector";
const inspector = createInspector({
root: document.getElementById("app"),
container: document.getElementById("tree-panel"),
viewMode: "a11y", // "dom" | "a11y" | "tab"
theme: "auto",
});
inspector.mount();
// inspector.setRoot / setViewMode / refresh / getTreemount: "shadow"highlightOnHovera11y-in-storybooka11y-snapshot-tests