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

---

# FocusableIframe

## In this article

 * [Usage](https://developer.wordpress.org/block-editor/reference-guides/components/focusable-iframe/?output_format=md#usage)
 * [Props](https://developer.wordpress.org/block-editor/reference-guides/components/focusable-iframe/?output_format=md#props)
    - [onFocus](https://developer.wordpress.org/block-editor/reference-guides/components/focusable-iframe/?output_format=md#onfocus)
    - [iframeRef](https://developer.wordpress.org/block-editor/reference-guides/components/focusable-iframe/?output_format=md#iframeref)

**Deprecated**

`<FocusableIframe />` is a component rendering an `iframe` element enhanced to support
focus events. By default, it is not possible to detect when an iframe is focused
or clicked within. This enhanced component uses a technique which checks whether
the target of a window `blur` event is the iframe, inferring that this has resulted
in the focus of the iframe. It dispatches an emulated [`FocusEvent`](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent)
on the iframe element with event bubbling, so a parent component binding its own`
onFocus` event will account for focus transitioning within the iframe.

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

Use as you would a standard `iframe`. You may pass `onFocus` directly as the callback
to be invoked when the iframe receives focus, or on an ancestor component since 
the event will bubble.

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

    const MyFocusableIframe = () => (
        <FocusableIframe
            src="/my-iframe-url"
            onFocus={ () => console.log( 'iframe is focused' ) }
        />
    );
    ```

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

Any props aside from those listed below will be passed to the `FocusableIframe` 
will be passed through to the underlying `iframe` element.

### 󠀁[onFocus](https://developer.wordpress.org/block-editor/reference-guides/components/focusable-iframe/?output_format=md#onfocus)󠁿

 * Type: `Function`
 * Required: No

Callback to invoke when iframe receives focus. Passes an emulated `FocusEvent` object
as the first argument.

### 󠀁[iframeRef](https://developer.wordpress.org/block-editor/reference-guides/components/focusable-iframe/?output_format=md#iframeref)󠁿

 * Type: `React.Ref`
 * Required: No

If a reference to the underlying DOM element is needed, pass `iframeRef` as the 
result of a `React.createRef` called from your component.

First published

March 9, 2021

Last updated

October 14, 2026

Edit article

[ Improve it on GitHub: FocusableIframe ](https://github.com/WordPress/gutenberg/edit/trunk/packages/components/src/focusable-iframe/README.md)

[  Previous: FocalPointPicker](https://developer.wordpress.org/block-editor/reference-guides/components/focal-point-picker/)

[  Next: FontSizePicker](https://developer.wordpress.org/block-editor/reference-guides/components/font-size-picker/)