Title: Sandbox
Published: March 9, 2021
Last modified: October 14, 2026

---

# Sandbox

## In this article

 * [Usage](https://developer.wordpress.org/block-editor/reference-guides/components/sandbox/?output_format=md#usage)
 * [Props](https://developer.wordpress.org/block-editor/reference-guides/components/sandbox/?output_format=md#props)
    - [html: string](https://developer.wordpress.org/block-editor/reference-guides/components/sandbox/?output_format=md#html-string)
    - [onFocus: React.DOMAttributes< HTMLIFrameElement >[ ‘onFocus’ ]](https://developer.wordpress.org/block-editor/reference-guides/components/sandbox/?output_format=md#onfocus-react-domattributes-htmliframeelement-onfocus)
    - [scripts: string[]](https://developer.wordpress.org/block-editor/reference-guides/components/sandbox/?output_format=md#scripts-string)
    - [styles: string[]](https://developer.wordpress.org/block-editor/reference-guides/components/sandbox/?output_format=md#styles-string)
    - [title: string](https://developer.wordpress.org/block-editor/reference-guides/components/sandbox/?output_format=md#title-string)
    - [type: string](https://developer.wordpress.org/block-editor/reference-guides/components/sandbox/?output_format=md#type-string)
    - [tabIndex: HTMLElement[ ‘tabIndex’ ]](https://developer.wordpress.org/block-editor/reference-guides/components/sandbox/?output_format=md#tabindex-htmlelement-tabindex)

This component provides an isolated environment for arbitrary HTML via iframes.

## 󠀁[Usage](https://developer.wordpress.org/block-editor/reference-guides/components/sandbox/?output_format=md#usage)󠁿

    ```language-jsx
    import { SandBox } from '@wordpress/components';

    const MySandBox = () => (
        <SandBox html="<p>Content</p>" title="SandBox" type="embed" />
    );
    ```

## 󠀁[Props](https://developer.wordpress.org/block-editor/reference-guides/components/sandbox/?output_format=md#props)󠁿

### 󠀁[html: string](https://developer.wordpress.org/block-editor/reference-guides/components/sandbox/?output_format=md#html-string)󠁿

The HTML to render in the body of the iframe document.

 * Required: No
 * Default: “”

### 󠀁[onFocus: React.DOMAttributes< HTMLIFrameElement >[ ‘onFocus’ ]](https://developer.wordpress.org/block-editor/reference-guides/components/sandbox/?output_format=md#onfocus-react-domattributes-htmliframeelement-onfocus)󠁿

The `onFocus` callback for the iframe.

 * Required: No

### 󠀁[scripts: string[]](https://developer.wordpress.org/block-editor/reference-guides/components/sandbox/?output_format=md#scripts-string)󠁿

An array of script URLs to inject as `<script>` tags into the bottom of the `<body
>` of the iframe document.

 * Required: No
 * Default: []

### 󠀁[styles: string[]](https://developer.wordpress.org/block-editor/reference-guides/components/sandbox/?output_format=md#styles-string)󠁿

An array of CSS strings to inject into the `<head>` of the iframe document.

 * Required: No
 * Default: []

### 󠀁[title: string](https://developer.wordpress.org/block-editor/reference-guides/components/sandbox/?output_format=md#title-string)󠁿

The `<title>` of the iframe document.

 * Required: No
 * Default: “”

### 󠀁[type: string](https://developer.wordpress.org/block-editor/reference-guides/components/sandbox/?output_format=md#type-string)󠁿

The CSS class name to apply to the `<html>` and `<body>` elements of the iframe.

 * Required: No
 * Default: “”

### 󠀁[tabIndex: HTMLElement[ ‘tabIndex’ ]](https://developer.wordpress.org/block-editor/reference-guides/components/sandbox/?output_format=md#tabindex-htmlelement-tabindex)󠁿

The `tabindex` the iframe should receive.

 * Required: No

First published

March 9, 2021

Last updated

October 14, 2026

Edit article

[ Improve it on GitHub: Sandbox ](https://github.com/WordPress/gutenberg/edit/trunk/packages/components/src/sandbox/README.md)

[  Previous: ResponsiveWrapper](https://developer.wordpress.org/block-editor/reference-guides/components/responsive-wrapper/)

[  Next: ScrollLock](https://developer.wordpress.org/block-editor/reference-guides/components/scroll-lock/)