# Lock Colors and Sizes to the Theme Presets

> Removes the custom color picker, custom gradients and free-form font and spacing sizes from the editor, so editors can only choose from your theme's palette and scales.

- Type: PHP
- Runs: Run everywhere
- Category: [Block Editor](https://wpide.com/library/category/gutenberg/)
- Tags: colors, typography, design-system
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/lock-editor-to-theme-presets/

## Code

```php
add_filter( 'wp_theme_json_data_theme', function ( $theme_json ) {
    return $theme_json->update_with( array(
        'version'  => 3,
        'settings' => array(
            'color'      => array(
                'custom'         => false,
                'customGradient' => false,
                'customDuotone'  => false,
            ),
            'typography' => array(
                'customFontSize' => false,
            ),
            'spacing'    => array(
                'customSpacingSize' => false,
            ),
        ),
    ) );
} );
```

## Notes

Existing content with custom values keeps them. Works with block and classic themes.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Lock Colors and Sizes to the Theme Presets" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
