> ## Documentation Index
> Fetch the complete documentation index at: https://docs.skybridge.tech/llms.txt
> Use this file to discover all available pages before exploring further.

# useRequestModal

> Open the view as a modal overlay and read its modal state

A modal overlay is host-owned: a [view](https://docs.skybridge.tech/build/view.md) cannot mount one itself. `useRequestModal` lets the view ask the host to open it as a modal, pass data into it, and read whether the modal is currently showing.

## Example

The carousel opens a product in a modal to confirm adding it to the cart, then runs the add when the shopper confirms.

```tsx highlight={4,6,15} theme={null}
import { useRequestModal } from "skybridge/web";

function Carousel() {
  const { isOpen, params, open } = useRequestModal();

  if (isOpen) {
    return (
      <ConfirmAddToCart productId={params?.productId} />
    );
  }

  return (
    <ProductGrid
      onSelect={(product) =>
        open({ title: product.name, params: { productId: product.id } })
      }
    />
  );
}
```

## Returns

`useRequestModal` returns the modal state plus an opener.

### `isOpen`

```tsx theme={null}
isOpen: boolean;
```

`true` when the host is currently rendering the view in `"modal"` display mode. It tracks the modal lifecycle on its own: `true` after `open`, back to `false` when the modal closes.

### `params`

```tsx theme={null}
params: Record<string, unknown> | undefined;
```

The `params` the modal was opened with, surfaced back to the view while it is open. `undefined` when no modal is open, or when `open` was called without `params`.

### `open`

```tsx theme={null}
open(options: RequestModalOptions): void;
```

Asks the host to render the view as a modal. Returns `void`: read the result from [`isOpen`](#isopen) and [`params`](#params) once the modal opens.

**`options`**

```tsx theme={null}
type RequestModalOptions = {
  title?: string; // label for the modal chrome
  params?: Record<string, unknown>; // data surfaced back through `params` while the modal is open
  template?: string; // view resource to render, when it differs from the current view
  anchor?: { top?: number; left?: number; width?: number; height?: number }; // pixel bounds to position the modal
};
```

> [!NOTE]
>
> **ChatGPT** opens a native host modal with the full `RequestModalOptions`. Other hosts polyfill it, rendering the modal inside the view's iframe and honoring only `params`; `title`, `template`, and `anchor` are ignored.

> [card] [Design for the Host](https://docs.skybridge.tech/guides/ux.md)
>
> Adapt the view to display mode, theme, and device

> [card] [useDisplayMode](https://docs.skybridge.tech/api-reference/use-display-mode.md)
>
> Read and request the non-modal display modes

> [card] [useRequestClose](https://docs.skybridge.tech/api-reference/use-request-close.md)
>
> Ask the host to dismiss the view


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.