Skip to main content
Login Join
Snippet · PHP

Register Custom Font Sizes In Gutenberg

Shared by Bharat Kathiriya · July 17, 2026 · @after_setup_theme

21 views
1 upvote
Back to Snippets

Register Custom Font Sizes

Add the following code to your theme’s functions.php file or a custom functionality plugin:

function cs_font_sizes() {

add_theme_support(
'editor-font-sizes',
array(
array(
'name' => __( 'Small', 'mytheme' ),
'shortName' => __( 'S', 'mytheme' ),
'size' => 14,
'slug' => 'small',
),
array(
'name' => __( 'Medium', 'mytheme' ),
'shortName' => __( 'M', 'mytheme' ),
'size' => 18,
'slug' => 'medium',
),
array(
'name' => __( 'Large', 'mytheme' ),
'shortName' => __( 'L', 'mytheme' ),
'size' => 32,
'slug' => 'large',
),
array(
'name' => __( 'Extra Large', 'mytheme' ),
'shortName' => __( 'XL', 'mytheme' ),
'size' => 48,
'slug' => 'x-large',
),
)
);
}
add_action( 'after_setup_theme', 'cs_font_sizes' );
Know a different way to do this? Add your approach as a variation so folks can compare them side by side.
Submit a variation

0 comments