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

# Portal Boundary

Most of floating components in `@membranehq/react`,\
like [Combobox](/docs/ways-to-use-membrane/sdk/react/combobox), use `Portal` to mount outside of the stacking context.

If you are using a floating component on the default stacking context, no additional setup is required\
as the default portal boundary is the `<body/>` element.

But for cases when you want to use a floating component within another floating component, the stacking context needs to be adjusted by bounding the portal area.\
This can be done with the `FloatingPortalBoundary` component.

A common situation is a custom `Modal` rendered in a `Portal` with a [Combobox](/docs/ways-to-use-membrane/sdk/react/combobox) as part of [DataInput](/docs/ways-to-use-membrane/sdk/react/data-input).

```javascript theme={null}
import { DataInput } from "@membranehq/react";
import { Modal } from './my-modal'

const schema = {...}
const variablesSchema = {...}

export function ModalWithDataInput() {

  return (
    <Modal.RootWithPortal>
      <Modal.Header>Create record</Modal.Header>

      <Modal.Content>
        <DataInput
          schema={schema}
          variablesSchema={variablesSchema}
        />
      </Modal.Content>
    </Modal.RootWithPortal>
  )
}
```

With this setup both `Modal` and `Combobox` are rendered over their respective `Portal` inside of the `<body />`,\
resulting in two separate stacking contexts and `Modal` might appear above `Combobox`.

<Frame>
  <img src="https://files.readme.io/1deabdea7b268683ecff4a4c97a6a7690758b59b8c5706cf78aec5c49e890143-portal-boundary-broken.png" alt="Portal Boundary illustration" />
</Frame>

To fix this problem we should bound the `Combobox` portal with `Modal.Content`.\
Use `FloatingPortalBoundary` to wrap the content container.

> Note: `FloatingPortalBoundary` should only have a single child because it attaches a `data-*` attribute to it,\
> which serves as an anchor for `Portal`.

```javascript theme={null}
import { DataInput, FloatingPortalBoundary } from "@membranehq/react";
import { Modal } from './my-modal'

const schema = {...}
const variablesSchema = {...}

export function ModalWithDataInput() {

  return (
    <Modal.RootWithPortal>
      <Modal.Header>Create record</Modal.Header>

      <FloatingPortalBoundary>
        <Modal.Content>
          <DataInput
            schema={schema}
            variablesSchema={variablesSchema}
          />
        </Modal.Content>
      </FloatingPortalBoundary>
    </Modal.RootWithPortal>
  )
}
```

Now, as the content has its own boundary, the `Combobox` from `DataInput` is portalled into the correct stacking context.

<Frame>
  <img src="https://files.readme.io/71d4d0afbf2487aa2eef091c5c0d66c7ab17c4622de4b6a024698bb95b16d081-portal-boundary-fixed.png" alt="Portal Boundary illustration" />
</Frame>

<br />

## Props: `FloatingPortalBoundary`

<table className="stripe w-full">
  <thead>
    <tr>
      <th>Prop</th>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td><code>children</code></td>
      <td><code>React.ReactElement</code></td>
      <td>Components Children. Accepts only single child.</td>
    </tr>

    <tr>
      <td><code>id</code></td>
      <td><code>string | undefined</code></td>
      <td>Custom ID for boundary container. If not passed - <code>useId</code> is used.</td>
    </tr>
  </tbody>
</table>
