tigran tumasov

Modal

Buttons 3

About

Display popup content that requires attention or provides additional information.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Modal to your project and fits it to your theme.

Code

How Modal is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

import { useRef,                                        useState } from "react";
import { Button } from "@/components/ui/button-1";
import { Modal } from "@/components/ui/modal";

export default function ControlInitialFocusDemo() {
  const [open6, setOpen6] = useState(false);
  const initialFocusRef = useRef<HTMLButtonElement>(null);
  return (
        <div>
          <Button onClick={() => setOpen6(true)} size="small">
            Open Modal
          </Button>

          <Modal.Modal
            active={open6}
            initialFocusRef={initialFocusRef}
            onClickOutside={() => setOpen6(false)}
          >
            <Modal.Body>
              <Modal.Header>
                <Modal.Title>Initial Focus</Modal.Title>
                <Modal.Subtitle>
                  This Modal.Modal is set up to programmatically move the focus onto the
                  Submit button, making it possible to promptly continue with the
                  Enter key.
                </Modal.Subtitle>
              </Modal.Header>
            </Modal.Body>

            <Modal.Actions>
              <Modal.Action onClick={() => setOpen6(false)} type="secondary">
                Cancel
              </Modal.Action>

              <Modal.Action onClick={() => setOpen6(false)} ref={initialFocusRef}>
                Submit
              </Modal.Action>
            </Modal.Actions>
          </Modal.Modal>
        </div>
  );
}

Dependencies

More by tigran tumasov

View all
  • Product Hunt Badge

    Product Hunt Badge

    1.8K
  • Book

    Book

    162
  • Calendar

    Calendar

    152
  • Theme Switcher

    Theme Switcher

    135
  • Snippet

    Snippet

    124
  • Table

    Table

    123
  • Toggle

    Toggle

    89
  • Feedback

    Feedback

    88

More in Buttons

View all
  • Button

    Button

    14
  • Button

    Button

    34
  • Texture Button

    Texture Button

    92
  • Button Save

    Button Save

    46
  • Button

    Button

    64
  • Button Group

    Button Group

    3
  • App Store Button

    App Store Button

    454
  • Notification Button

    Notification Button

    103