- Inicio
- Primitivas
- Alert Dialog
- Ejemplos
Alert Dialog
Ejemplo básico de alert dialog demostrando el comportamiento principal.
Ejemplos
import * as AlertDialog from "@solidiom/alert-dialog"
;<AlertDialog.Root>Contenido de Alert Dialog</AlertDialog.Root>Ver código fuente
export function Root(props: AlertDialogRootProps) {
const baseId = createStableId("alert-dialog")
const { open, requestOpenChange } = createDisclosureState({
open: props.open,
defaultOpen: props.defaultOpen,
onOpenChange: props.onOpenChange,
})
const presence = createPresence({ open })
const ctx: AlertDialogContextValue = {
open,
requestOpenChange,
contentId: `${baseId}-content`,
titleId: `${baseId}-title`,
descriptionId: `${baseId}-description`,
triggerId: `${baseId}-trigger`,
phase: presence.phase,
present: presence.present,
}
return <AlertDialogContext value={ctx}>{props.children}</AlertDialogContext>
}