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

---

# FontSizePicker

## In this article

 * [Usage](https://developer.wordpress.org/block-editor/reference-guides/components/font-size-picker/?output_format=md#usage)
 * [Props](https://developer.wordpress.org/block-editor/reference-guides/components/font-size-picker/?output_format=md#props)
    - [disableCustomFontSizes: boolean](https://developer.wordpress.org/block-editor/reference-guides/components/font-size-picker/?output_format=md#disablecustomfontsizes-boolean)
    - [fallbackFontSize: number](https://developer.wordpress.org/block-editor/reference-guides/components/font-size-picker/?output_format=md#fallbackfontsize-number)
    - [fontSizes: FontSize[]](https://developer.wordpress.org/block-editor/reference-guides/components/font-size-picker/?output_format=md#fontsizes-fontsize)
    - [onChange: ( value: number | string | undefined, selectedItem?: FontSize ) => void](https://developer.wordpress.org/block-editor/reference-guides/components/font-size-picker/?output_format=md#onchange-value-number-string-undefined-selecteditem-fontsize-void)
    - [units: string[]](https://developer.wordpress.org/block-editor/reference-guides/components/font-size-picker/?output_format=md#units-string)
    - [value: number | string](https://developer.wordpress.org/block-editor/reference-guides/components/font-size-picker/?output_format=md#value-number-string)
    - [valueMode: ‘literal’ | ‘slug’](https://developer.wordpress.org/block-editor/reference-guides/components/font-size-picker/?output_format=md#valuemode-literal-slug)
    - [withReset: boolean](https://developer.wordpress.org/block-editor/reference-guides/components/font-size-picker/?output_format=md#withreset-boolean)
    - [withSlider: boolean](https://developer.wordpress.org/block-editor/reference-guides/components/font-size-picker/?output_format=md#withslider-boolean)

FontSizePicker is a React component that renders a UI that allows users to select
a font size.
 The component renders a user interface that allows the user to select
predefined (common) font sizes and contains an option that allows users to select
custom font sizes (by choosing the value) if that functionality is enabled.

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

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

    const fontSizes = [
        {
            name: __( 'Small' ),
            slug: 'small',
            size: 12,
        },
        {
            name: __( 'Big' ),
            slug: 'big',
            size: 26,
        },
    ];
    const fallbackFontSize = 16;

    const MyFontSizePicker = () => {
        const [ fontSize, setFontSize ] = useState( 12 );

        return (
            <FontSizePicker
                fontSizes={ fontSizes }
                value={ fontSize }
                fallbackFontSize={ fallbackFontSize }
                onChange={ ( newFontSize ) => {
                    setFontSize( newFontSize );
                } }
            />
        );
    };

    ...

    <MyFontSizePicker />
    ```

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

The component accepts the following props:

### 󠀁[disableCustomFontSizes: boolean](https://developer.wordpress.org/block-editor/reference-guides/components/font-size-picker/?output_format=md#disablecustomfontsizes-boolean)󠁿

If `true`, it will not be possible to choose a custom fontSize. The user will be
forced to pick one of the pre-defined sizes passed in fontSizes.

 * Required: no
 * Default: `false`

### 󠀁[fallbackFontSize: number](https://developer.wordpress.org/block-editor/reference-guides/components/font-size-picker/?output_format=md#fallbackfontsize-number)󠁿

If no value exists, this prop defines the starting position for the font size picker
slider. Only relevant if `withSlider` is `true`.

 * Required: No

### 󠀁[fontSizes: FontSize[]](https://developer.wordpress.org/block-editor/reference-guides/components/font-size-picker/?output_format=md#fontsizes-fontsize)󠁿

An array of font size objects. The object should contain properties size, name, 
and slug.
 The property `size` contains a number with the font size value, in `px`
or a string specifying the font size CSS property that should be used eg: “13px”,“
1em”, or “clamp(12px, 5vw, 100px)”. The `name` property includes a label for that
font size e.g.: `Small`. The `slug` property is a string with a unique identifier
for the font size. Used for the class generation process.

**Note:** The slugs `default` and `custom` are reserved and cannot be used.

 * Required: No
 * Default: `[]`

### 󠀁[onChange: ( value: number | string | undefined, selectedItem?: FontSize ) => void](https://developer.wordpress.org/block-editor/reference-guides/components/font-size-picker/?output_format=md#onchange-value-number-string-undefined-selecteditem-fontsize-void)󠁿

A function that receives the new font size value.
 If onChange is called without
any parameter, it should reset the value, attending to what reset means in that 
context, e.g., set the font size to undefined or set the font size a starting value.

 * Required: Yes

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

Available units for custom font size selection.

 * Required: No
 * Default: `[ 'px', 'em', 'rem', 'vw', 'vh' ]`

### 󠀁[value: number | string](https://developer.wordpress.org/block-editor/reference-guides/components/font-size-picker/?output_format=md#value-number-string)󠁿

The current font size value.

**Note**: For the `units` property to work, the current font size value must be 
specified as strings with units (e.g., `'12px'` instead of `12`). When the font 
size is provided as a number, the component operates in “unitless mode” where the`
units` property has no effect.

 * Required: No

### 󠀁[valueMode: ‘literal’ | ‘slug’](https://developer.wordpress.org/block-editor/reference-guides/components/font-size-picker/?output_format=md#valuemode-literal-slug)󠁿

Determines how the `value` prop should be interpreted.

 * `'literal'`: The `value` prop contains the actual font size value (number or 
   string).
 * `'slug'`: The `value` prop contains the slug of the selected font size.
 * Required: No
 * Default: `'literal'`

### 󠀁[withReset: boolean](https://developer.wordpress.org/block-editor/reference-guides/components/font-size-picker/?output_format=md#withreset-boolean)󠁿

If `true`, a reset button will be displayed alongside the input field when a custom
font size is active. Has no effect when `disableCustomFontSizes` is `true`.

 * Required: no
 * Default: `true`

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

If `true`, a slider will be displayed alongside the input field when a custom font
size is active. Has no effect when `disableCustomFontSizes` is `true`.

 * Required: no
 * Default: `false`

First published

March 9, 2021

Last updated

October 14, 2026

Edit article

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

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

[  Next: FormFileUpload](https://developer.wordpress.org/block-editor/reference-guides/components/form-file-upload/)