Saltar al contenido
Logic2BUI

Buscar en la documentación

Busca componentes y documentación

Nuevo
Menú

Diálogo de alerta

Diálogo modal que interrumpe al usuario con contenido importante y requiere una respuesta.

Instalación

npx logic2b@next add alert-dialog

Uso

import {
  AlertDialog,
  AlertDialogAction,
  AlertDialogCancel,
  AlertDialogContent,
  AlertDialogDescription,
  AlertDialogFooter,
  AlertDialogHeader,
  AlertDialogTitle,
  AlertDialogTrigger,
} from "@/components/ui/alert-dialog"

<AlertDialog>
  <AlertDialogTrigger>Eliminar cuenta</AlertDialogTrigger>
  <AlertDialogContent>
    <AlertDialogHeader>
      <AlertDialogTitle>¿Confirmas la acción?</AlertDialogTitle>
      <AlertDialogDescription>
        Esta acción no se puede deshacer.
      </AlertDialogDescription>
    </AlertDialogHeader>
    <AlertDialogFooter>
      <AlertDialogCancel>Cancelar</AlertDialogCancel>
      <AlertDialogAction>Continuar</AlertDialogAction>
    </AlertDialogFooter>
  </AlertDialogContent>
</AlertDialog>

Notas de uso

AlertDialogAction y AlertDialogCancel usan respectivamente las variantes de botón predeterminada y outline. Pasa className para cambiar su estilo, por ejemplo en una acción destructiva.

Ejemplos

Acción destructiva

Aplica la variante destructiva al botón de confirmación en operaciones irreversibles.

Controlado

Abre el diálogo desde tu propio estado con open y onOpenChange.

Accesibilidad

  • Sigue el patrón WAI-ARIA de diálogo de alerta y mantiene el foco dentro mientras está abierto.
  • Al abrirse mueve el foco al diálogo; al cerrarse lo devuelve al disparador.
  • Escape cierra el diálogo y dispara AlertDialogCancel. A diferencia de un diálogo normal, un clic en la capa exterior no lo cierra: es necesario responder.
  • AlertDialogTitle etiqueta el contenido y AlertDialogDescription lo describe.

Playground interactivo

Edita las propiedades del componente y revisa el JSX exacto antes de copiarlo. La vista previa se carga solo cuando esta sección entra en pantalla.

JSX generado
<AlertDialog>
  <AlertDialogTrigger
    className="rounded-md border px-4 py-2 text-sm font-medium"
  >Delete release</AlertDialogTrigger>
  <AlertDialogContent>
    <AlertDialogHeader>
      <AlertDialogTitle>Delete this release?</AlertDialogTitle>
      <AlertDialogDescription>This action permanently removes the release artifacts.</AlertDialogDescription>
    </AlertDialogHeader>
    <AlertDialogFooter>
      <AlertDialogCancel>Cancel</AlertDialogCancel>
      <AlertDialogAction>Delete</AlertDialogAction>
    </AlertDialogFooter>
  </AlertDialogContent>
</AlertDialog>

Referencia de API

Generada a partir de las exportaciones públicas de TypeScript en src/ui/alert-dialog.tsx. Las descripciones técnicas conservan el texto canónico del código fuente.

Ver JSON

AlertDialog

Componente
Props: React.ComponentProps<typeof AlertDialogPrimitive.Root>

AlertDialogPortal

Componente
Props: React.ComponentProps<typeof AlertDialogPrimitive.Portal>

AlertDialogOverlay

Componente
Props: React.ComponentProps<typeof AlertDialogPrimitive.Overlay>

AlertDialogTrigger

Componente
Props: React.ComponentProps<typeof AlertDialogPrimitive.Trigger>

AlertDialogContent

Componente
Props: React.ComponentProps<typeof AlertDialogPrimitive.Content>

AlertDialogHeader

Componente
Props: React.ComponentProps<"div">

AlertDialogFooter

Componente
Props: React.ComponentProps<"div">

AlertDialogTitle

Componente
Props: React.ComponentProps<typeof AlertDialogPrimitive.Title>

AlertDialogDescription

Componente
Props: React.ComponentProps<typeof AlertDialogPrimitive.Description>

AlertDialogAction

Componente
Props: React.ComponentProps<typeof AlertDialogPrimitive.Action>

AlertDialogCancel

Componente
Props: React.ComponentProps<typeof AlertDialogPrimitive.Cancel>

Contrato de accesibilidad

Comportamiento legible por máquinas y responsabilidades de quien integra alert-dialog. Los detalles normativos conservan el texto canónico del registro.

Ver JSON
Soporte
Gestionado por la primitiva
Patrón
alertdialog
Radix Alert Dialog
Interacciones de teclado para alert-dialog
TeclasComportamiento
EscapeClose the open surface and restore focus.
Tab Shift+TabMove between confirmation actions.

Semántica incorporada

  • Uses alertdialog semantics, traps focus and requires an explicit action.

Responsabilidades de integración

  • Describe the consequence and give destructive/escape actions unambiguous labels.