Component evidence

Accessible Modal Dialog (components/Modal.tsx)

opencrow · src/web/ui/components/Modal.tsx · typescript · MIT
uilang:typescriptfw:reacttag:focus

Provides a React modal with focus management, focus restoration, keyboard-accessible controls, optional titles, and configurable width. Reuse it for dialogs, confirmations, and focused content overlays.

Source preview first 800 characters · full source over MCP
// Source: https://github.com/gokhantos/opencrow | License: MIT | Copyright 2026 OpenCrow
// Provided via justclaw.it.com; keep this notice with the code.
import React, { useEffect, useId, useRef } from "react";
import { X } from "lucide-react";

interface ModalProps {
  readonly open: boolean;
  readonly onClose: () => void;
  readonly title?: string;
  readonly children: React.ReactNode;
  readonly width?: string;
}

const FOCUSABLE =
  'button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),a[href],[tabindex]:not([tabindex="-1"])';

export function Modal({ open, onClose, title, children, width }: ModalProps) {
  const dialogRef = useRef<HTMLDivElement>(null);
  const titleId = useId();

  useEffect(() => {
    if (!open) return;

    // Capture the 

... (truncated -- full source via MCP)