Title: BorderControl
Published: March 24, 2022
Last modified: October 14, 2026

---

# BorderControl

## In this article

 * [Development guidelines](https://developer.wordpress.org/block-editor/reference-guides/components/border-control/?output_format=md#development-guidelines)
 * [Usage](https://developer.wordpress.org/block-editor/reference-guides/components/border-control/?output_format=md#usage)
 * [Props](https://developer.wordpress.org/block-editor/reference-guides/components/border-control/?output_format=md#props)
    - [colors: ( PaletteObject | ColorObject )[]](https://developer.wordpress.org/block-editor/reference-guides/components/border-control/?output_format=md#colors-paletteobject-colorobject)
    - [disableCustomColors: boolean](https://developer.wordpress.org/block-editor/reference-guides/components/border-control/?output_format=md#disablecustomcolors-boolean)
    - [disableUnits: boolean](https://developer.wordpress.org/block-editor/reference-guides/components/border-control/?output_format=md#disableunits-boolean)
    - [enableAlpha: boolean](https://developer.wordpress.org/block-editor/reference-guides/components/border-control/?output_format=md#enablealpha-boolean)
    - [enableStyle: boolean](https://developer.wordpress.org/block-editor/reference-guides/components/border-control/?output_format=md#enablestyle-boolean)
    - [hideLabelFromVision: boolean](https://developer.wordpress.org/block-editor/reference-guides/components/border-control/?output_format=md#hidelabelfromvision-boolean)
    - [isCompact: boolean](https://developer.wordpress.org/block-editor/reference-guides/components/border-control/?output_format=md#iscompact-boolean)
    - [label: string](https://developer.wordpress.org/block-editor/reference-guides/components/border-control/?output_format=md#label-string)
    - [onChange: ( value?: Object ) => void](https://developer.wordpress.org/block-editor/reference-guides/components/border-control/?output_format=md#onchange-value-object-void)
    - [shouldSanitizeBorder: boolean](https://developer.wordpress.org/block-editor/reference-guides/components/border-control/?output_format=md#shouldsanitizeborder-boolean)
    - [value: Object](https://developer.wordpress.org/block-editor/reference-guides/components/border-control/?output_format=md#value-object)
    - [width: CSSProperties[ ‘width’ ]](https://developer.wordpress.org/block-editor/reference-guides/components/border-control/?output_format=md#width-cssproperties-width)
    - [withSlider: boolean](https://developer.wordpress.org/block-editor/reference-guides/components/border-control/?output_format=md#withslider-boolean)

An input control for a border’s color, style, and width.

## 󠀁[Development guidelines](https://developer.wordpress.org/block-editor/reference-guides/components/border-control/?output_format=md#development-guidelines)󠁿

The `BorderControl` brings together internal sub-components which allow users to

set the various properties of a border. The first sub-component, a `BorderDropdown`
contains options representing border color and style. The border width is controlled
via a `UnitControl` and an optional `RangeControl`.

Border radius is not covered by this control as it may be desired separate to
 color,
style, and width. For example, the border radius may be absorbed under a “shape”
abstraction.

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

    ```language-jsx
    import { useState } from 'react';
    import { BorderControl } from '@wordpress/components';
    import { __ } from '@wordpress/i18n';

    const colors = [
        { name: 'Blue 20', color: '#72aee6' },
        // ...
    ];

    const MyBorderControl = () => {
        const [ border, setBorder ] = useState();

        return (
            <BorderControl
                colors={ colors }
                label={ __( 'Border' ) }
                onChange={ setBorder }
                value={ border }
            />
        );
    };
    ```

If you’re using this component outside the editor, you can
 [ensure `Tooltip` positioning](https://developer.wordpress.org/block-editor/reference-guide/components/#popovers-and-tooltips)
for the `BorderControl`‘s color and style options, by rendering your `BorderControl`
with a `Popover.Slot` further up the element tree and within a `SlotFillProvider`
overall.

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

### 󠀁[colors: ( PaletteObject | ColorObject )[]](https://developer.wordpress.org/block-editor/reference-guides/components/border-control/?output_format=md#colors-paletteobject-colorobject)󠁿

An array of color definitions. This may also be a multi-dimensional array where

colors are organized by multiple origins.

Each color may be an object containing a `name` and `color` value.

 * Required: No
 * Default: `[]`

### 󠀁[disableCustomColors: boolean](https://developer.wordpress.org/block-editor/reference-guides/components/border-control/?output_format=md#disablecustomcolors-boolean)󠁿

This toggles the ability to choose custom colors.

 * Required: No

### 󠀁[disableUnits: boolean](https://developer.wordpress.org/block-editor/reference-guides/components/border-control/?output_format=md#disableunits-boolean)󠁿

This controls whether unit selection should be disabled.

 * Required: No

### 󠀁[enableAlpha: boolean](https://developer.wordpress.org/block-editor/reference-guides/components/border-control/?output_format=md#enablealpha-boolean)󠁿

This controls whether the alpha channel will be offered when selecting
 custom colors.

 * Required: No
 * Default: `true`

### 󠀁[enableStyle: boolean](https://developer.wordpress.org/block-editor/reference-guides/components/border-control/?output_format=md#enablestyle-boolean)󠁿

This controls whether to support border style selection.

 * Required: No
 * Default: `true`

### 󠀁[hideLabelFromVision: boolean](https://developer.wordpress.org/block-editor/reference-guides/components/border-control/?output_format=md#hidelabelfromvision-boolean)󠁿

Provides control over whether the label will only be visible to screen readers.

 * Required: No

### 󠀁[isCompact: boolean](https://developer.wordpress.org/block-editor/reference-guides/components/border-control/?output_format=md#iscompact-boolean)󠁿

This flags the `BorderControl` to render with a more compact appearance. It
 restricts
the width of the control and prevents it from expanding to take up additional space.

 * Required: No

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

If provided, a label will be generated using this as the content.

_Whether it is visible only to screen readers is controlled via
 `hideLabelFromVision`.

 * Required: No

### 󠀁[onChange: ( value?: Object ) => void](https://developer.wordpress.org/block-editor/reference-guides/components/border-control/?output_format=md#onchange-value-object-void)󠁿

A callback function invoked when the border value is changed via an interaction

that selects or clears, border color, style, or width.

_Note: the value may be `undefined` if a user clears all border properties._

 * Required: Yes

### 󠀁[shouldSanitizeBorder: boolean](https://developer.wordpress.org/block-editor/reference-guides/components/border-control/?output_format=md#shouldsanitizeborder-boolean)󠁿

If opted into, sanitizing the border means that if no width or color have been
 
selected, the border style is also cleared and `undefined` is returned as the new
border value.

 * Required: No
 * Default: `true`

### 󠀁[value: Object](https://developer.wordpress.org/block-editor/reference-guides/components/border-control/?output_format=md#value-object)󠁿

An object representing a border or `undefined`. Used to set the current border
 
configuration for this component.

Example:

    ```javascript
     {
        color: '#72aee6',
        style: 'solid',
        width: '2px,
    }
    ```

 * Required: No

### 󠀁[width: CSSProperties[ ‘width’ ]](https://developer.wordpress.org/block-editor/reference-guides/components/border-control/?output_format=md#width-cssproperties-width)󠁿

Controls the visual width of the `BorderControl`. It has no effect if the
 `isCompact`
prop is set to `true`.

 * Required: No

### 󠀁[withSlider: boolean](https://developer.wordpress.org/block-editor/reference-guides/components/border-control/?output_format=md#withslider-boolean)󠁿

Flags whether this `BorderControl` should also render a `RangeControl` for
 additional
control over a border’s width.

 * Required: No

First published

March 24, 2022

Last updated

October 14, 2026

Edit article

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

[  Previous: BorderBoxControl](https://developer.wordpress.org/block-editor/reference-guides/components/border-box-control/)

[  Next: BoxControl](https://developer.wordpress.org/block-editor/reference-guides/components/box-control/)