Skip to content
FrameworkStyle

useDialogContext

Hook to access the nearest dialog compound-component context

Import

import { useDialogContext } from "@videojs/react";

Usage

Use this hook to build a custom part inside Dialog.Root, AlertDialog.Root, or ErrorDialog.Root.

function CustomCloseButton() {
  const { dialog } = useDialogContext();

  return <button onClick={() => dialog.close()}>Close</button>;
}

The hook throws when there is no surrounding dialog root.

API Reference

Return Value

PropertyTypeDetails
coreDialogCore
dialogobject
stateDialogCore.State
stateAttrMap{ [Key in keyof State]?: string; }
popupIdstring