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

---

# FocalPointPicker

## In this article

 * [Usage](https://developer.wordpress.org/block-editor/reference-guides/components/focal-point-picker/?output_format=md#usage)
 * [Props](https://developer.wordpress.org/block-editor/reference-guides/components/focal-point-picker/?output_format=md#props)
    - [url](https://developer.wordpress.org/block-editor/reference-guides/components/focal-point-picker/?output_format=md#url)
    - [autoPlay](https://developer.wordpress.org/block-editor/reference-guides/components/focal-point-picker/?output_format=md#autoplay)
    - [value](https://developer.wordpress.org/block-editor/reference-guides/components/focal-point-picker/?output_format=md#value)
    - [onChange](https://developer.wordpress.org/block-editor/reference-guides/components/focal-point-picker/?output_format=md#onchange)
    - [onDrag](https://developer.wordpress.org/block-editor/reference-guides/components/focal-point-picker/?output_format=md#ondrag)
    - [onDragEnd](https://developer.wordpress.org/block-editor/reference-guides/components/focal-point-picker/?output_format=md#ondragend)
    - [onDragStart](https://developer.wordpress.org/block-editor/reference-guides/components/focal-point-picker/?output_format=md#ondragstart)
    - [resolvePoint](https://developer.wordpress.org/block-editor/reference-guides/components/focal-point-picker/?output_format=md#resolvepoint)

Focal Point Picker is a component which creates a UI for identifying the most important
visual point of an image.

It addresses two common issues when displaying images in cropped containers. First,
large background images can be cropped in undesirable ways, especially on smaller
viewports such as mobile devices. Second, the CSS aspect-ratio property can inadvertently
crop out the area of highest visual interest. This component allows the selection
of the point with the most important visual information and returns it as a pair
of numbers between 0 and 1. The output value can be applied to either CSS `background-
position` (for elements with `background-image`) or `object-position` (for `<img
>` / `<video>` elements rendered with `object-fit: cover`).

 * Example focal point picker value: `{ x: 0.5, y: 0.1 }`;
 * Corresponding CSS: `object-position: 50% 10%`;

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

    ```language-jsx
    import { FocalPointPicker } from '@wordpress/components';
    import { useState } from '@wordpress/element';

    const Example = () => {
        const [ focalPoint, setFocalPoint ] = useState( {
            x: 0.5,
            y: 0.1,
        } );

        const url = '/path/to/image';

        /* Example function to render the CSS styles based on Focal Point Picker value */
        const style = {
            width: '100%',
            aspectRatio: '16 / 9',
            objectFit: 'cover',
            objectPosition: `${ focalPoint.x * 100 }% ${ focalPoint.y * 100 }%`,
        };

        return (
            <>
                <FocalPointPicker
                    url={ url }
                    value={ focalPoint }
                    onDragStart={ setFocalPoint }
                    onDrag={ setFocalPoint }
                    onChange={ setFocalPoint }
                />
                <img src={ url } alt="" style={ style } />
            </>
        );
    };
    ```

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

### 󠀁[url](https://developer.wordpress.org/block-editor/reference-guides/components/focal-point-picker/?output_format=md#url)󠁿

 * Type: `Text`
 * Required: Yes

URL of the image or video to be displayed

### 󠀁[autoPlay](https://developer.wordpress.org/block-editor/reference-guides/components/focal-point-picker/?output_format=md#autoplay)󠁿

 * Type: `Boolean`
 * Required: No
 * Default: `true`

Autoplays HTML5 video. This only applies to video sources (`url`).

### 󠀁[value](https://developer.wordpress.org/block-editor/reference-guides/components/focal-point-picker/?output_format=md#value)󠁿

 * Type: `Object`
 * Required: Yes

The focal point. Should be an object containing `x` and `y` params.

### 󠀁[onChange](https://developer.wordpress.org/block-editor/reference-guides/components/focal-point-picker/?output_format=md#onchange)󠁿

 * Type: `Function`
 * Required: Yes

Callback which is called when the focal point changes.

### 󠀁[onDrag](https://developer.wordpress.org/block-editor/reference-guides/components/focal-point-picker/?output_format=md#ondrag)󠁿

 * Type: `Function`
 * Required: No

Callback which is called repetitively during drag operations.

### 󠀁[onDragEnd](https://developer.wordpress.org/block-editor/reference-guides/components/focal-point-picker/?output_format=md#ondragend)󠁿

 * Type: `Function`
 * Required: No

Callback which is called at the end of drag operations.

### 󠀁[onDragStart](https://developer.wordpress.org/block-editor/reference-guides/components/focal-point-picker/?output_format=md#ondragstart)󠁿

 * Type: `Function`
 * Required: No

Callback which is called at the start of drag operations.

### 󠀁[resolvePoint](https://developer.wordpress.org/block-editor/reference-guides/components/focal-point-picker/?output_format=md#resolvepoint)󠁿

 * Type: `Function`
 * Required: No

Function which is called before internal updates to the value state. It receives
the upcoming value and may return a modified one.

First published

March 9, 2021

Last updated

October 14, 2026

Edit article

[ Improve it on GitHub: FocalPointPicker ](https://github.com/WordPress/gutenberg/edit/trunk/packages/components/src/focal-point-picker/README.md)

[  Previous: Flex](https://developer.wordpress.org/block-editor/reference-guides/components/flex/)

[  Next: FocusableIframe](https://developer.wordpress.org/block-editor/reference-guides/components/focusable-iframe/)