Docs

Prompt

Prompt

A modal dialog that interrupts the user with important content and expects a response.

Built on top of the Alert Dialog component.

import * as React from "react";
 
import { Button } from "@/components/ui/button";
import {
  Prompt,
  PromptAction,
  PromptOverlay,
  PromptCancel,
  PromptContent,
  PromptDescription,
  PromptFooter,
  PromptHeader,
  PromptTitle,
  PromptTrigger,
} from "@/components/ui/prompt";
 
export function PromptExample(): React.JSX.Element {
  return (
    <Prompt variant="danger">
      <PromptTrigger render={<Button variant="outline">Show Dialog</Button>} />
      <PromptOverlay />
      <PromptContent>
        <PromptHeader>
          <PromptTitle>Are you absolutely sure?</PromptTitle>
          <PromptDescription>
            This action cannot be undone. This will permanently delete your account and remove your
            data from our servers.
          </PromptDescription>
        </PromptHeader>
        <PromptFooter>
          <PromptCancel>Cancel</PromptCancel>
          <PromptAction>Continue</PromptAction>
        </PromptFooter>
      </PromptContent>
    </Prompt>
  );
}

Installation

npx lotru@latest add ui/prompt

Usage

import { Prompt } from "@/components/ui/prompt";
<Prompt>
  <PromptTrigger>Open</PromptTrigger>
  <PromptOverlay />
  <PromptContent>
    <PromptHeader>
      <PromptTitle>Are you absolutely sure?</PromptTitle>
      <PromptDescription>
        This action cannot be undone. This will permanently delete your account and remove your data
        from our servers.
      </PromptDescription>
    </PromptHeader>
    <PromptFooter>
      <PromptCancel>Cancel</PromptCancel>
      <PromptAction>Continue</PromptAction>
    </PromptFooter>
  </PromptContent>
</Prompt>

On this page