This component provides an isolated environment for arbitrary HTML via iframes.
Import
import { SandBox } from '@wordpress/components';
Props
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
allowSameOrigin | boolean | false | Whether to include Only enable this for content that is NOT directly user-controlled, such as server-fetched oEmbed previews. @default false | |
html | string | The HTML to render in the body of the iframe document. @default ” | ||
title | string | The @default ” | ||
type | string | The CSS class name to apply to the | ||
styles | string[] | An array of CSS strings to inject into the @default [] | ||
scripts | string[] | An array of script URLs to inject as @default [] | ||
onFocus | React.DOMAttributes< HTMLIFrameElement >[ 'onFocus' ] | The | ||
tabIndex | HTMLElement[ 'tabIndex' ] | The @default 0 |
Examples
Default
const Default = () => <SandBox onFocus={fn()} html="<p>Arbitrary HTML content</p>" />;