Revolutionizing WordPress typography using theme.json

Nov 4, 2024
Revolutionizing WordPress Typography with full site editing and theme.json

-sidebar-toc>        -language-notice>

Words form the foundation of the Internet in spite of the plethora of digital media. That means that the fonts you choose for your site will be a crucial aspect of your design and layout.

WordPress typography is able to evoke moods, aid in branding, and more. Full site editing (FSE) is a feature of WordPress puts customizing this typography at the fingertips of customers. Additionally, the theme.json file helps the developers create WordPress themes that take advantage of this.

This article explores WordPress typography, both for FSE and theme.json. However, the discussion also includes key contexts such as the typeface you are using and the technical aspects to consider and the future direction of how we use typography in the design.

Typeface on the internet: a quick history

When you go back to the early designs for web, you can see that, in spite of the diversity in design, the typefaces were consistent in their presentation. This is a result of availability, as well as a requirement. In a nutshell, without the technology we have now, words on the web could only utilize fonts on your computer.

The mid- to late '90s "web user" could only have a handful of predictable typefaces: Times New Roman, Arial, Helvetica, Georgia and Verdana. The latter two are Microsoft commissions that render perfectly for web use regardless of time.

A comparison of two serif typefaces, Verdana and Georgia. The image shows uppercase and lowercase letters – as well as numbers – in both fonts. Verdana appears more condensed and geometric, while Georgia has more pronounced serifs and a slightly more traditional look.
The specimens are of the Verdana font as well as Georgia fonts.
The Google Fonts website showing font previews and filtering options. The preview text reads, "Everyone has the right to freedom of thought," displayed in different fonts, including Roboto, SUSE, and Noto Sans Hannunoo. Filter options for language, writing system, and font properties are visible on the left-hand sidebar.
The primary Google Fonts interface.

WordPress and typography

Current default themes use standard font stacks to create an elegant, contemporary and high-quality presentation. Older default themes use pairings like Noto Sans and Noto Serif (for Twenty Fifteen) as well as Montserrat as well as Merriweather (for Twenty Sixteen).

To showcase this typography "circle of the world", Twenty Sixteen uses Helvetica and Georgia as options for fallback. The twenty Ten default theme only utilizes Helvetica, Arial, and Georgia:

The WordPress.org theme preview for "Twenty Ten" displaying a scenic header image of a tree-lined path. The left-hand sidebar shows theme information and download options, while the main area presents sample content and layout.
The Twenty Ten demo page is available on WordPress.org.

Although these options provide the foundation for WordPress design within each theme, they may also inspire you to take note of how you utilize typography -- which is something WordPress FSE can help with.

A brief overview of full site editing as well as theme.json

The WordPress Site Editor interface displaying a landscaping company's homepage. The page has a blue background with white text reading
The user interface of the WordPress Site Editor looks much like Block Editor. Block Editor, but with more customization scope.

The design of your website is unified options in a number of ways:

  • The editing method is used that Blocks offers for the entire website, not only your material.
  • A template library forms an integral part of the configuration which allows you to modify these using the same tools as the content you have created.
  • Styling also happens within the site Editor and provides a general setting scheme.
  • Site editing doesn't need any codes to use one of the options available. It is a bridge between design and development.

You can consider the theme.json file to as a prototype version of FSE. You'll need JavaScript Object Notation (JSON) skills to use the file, however this is within the capabilities for the vast majority of website owners. It's a central configuration file that manages your styles and settings.

A code editor window titled is displayed over a scenic background of forested mountains. The editor shows a portion of a WordPress theme.json file with various styling configurations. The code includes settings for calendar, categories, and code elements, using CSS variables for colors and spacing. Line numbers are visible on the left, and the editor interface has a dark theme for improved readability against the backdrop.
A theme.json document is showcased in an editor for code.

Every setting is based on the key/value pair value:option which you are able to apply this in a variety of ways:

  • Defining global color palettes.
  • The process of setting up font families and sizes.
  • Modifying Block-specific styling.
  • The management of spacing and layout preference.

Typography is set up in the WordPress Site Editor

If you're familiar with how to use the Block Editor You can use it with the Site Editor. Within WordPress, navigate through the appearanceand then the Editor screen. This displays the home screen of the Editor for Site:

The WordPress Site Editor home screen. The left-hand sidebar shows design options, while the main area displays a blue-themed homepage with the heading "A commitment to innovation and sustainability" and an image of a modern building.
The Home Screen of Site Editor.

The Styles screen on the left side of the navigation offers you a variety of global style options, including fonts that change:

A GIF of the WordPress Site Editor showcasing various theme style presets. The main content area displays "A commitment to innovation and sustainability" with a description of Études firm. It changes the color scheme and typography based on the selections within the left-hand sidebar, which shows style options and color schemes.
There are a variety of styles available for presets in WordPress's WordPress Site Editor.

In the majority of cases, individual settings for various factors of typography can provide the most benefit. Two small icons in the middle of the Styles screen that will open additional options, including Style Book and Edit Style Book and the Edit Styles pencil icon.

A portion of the WordPress Site Editor showing style options on the left-hand side, and a preview of the website on the right. Two icons for viewing and editing are highlighted in red.
The Style Editing icons in the site editor.

Additionally, you are able to set typography options at an element level and for each Block.

The Font Library

This edit styles>> Typeography screen will display the Font Library but it does not have this specific title in the Editor for Sites. This lets you handle types and fonts by using several different ways:

  • It is possible to upload and manage typefaces that you have created.
  • You can use Google Fonts directly within WordPress.
  • Create font collections using PHP.

To access the Font Library from the section for Typography in the Site Editor sidebar, click the Manage Fonts icon:

The Typography settings panel within the Site Editor showing font options, including Cardo, Jost, System Sans-serif, and System Serif. A Manage fonts button is highlighted in the top right corner. The panel is displayed alongside a blue website background containing Latin text, demonstrating the applied typography styles.
The Manage Fonts icon in the WordPress Website Editor.

Here, the library tab displays the typefaces that are currently registered for your theme and indicates which ones are active:

The WordPress Font Library interface displaying installed and theme fonts. Merriweather Sans is listed as an installed font with four active variants. Theme fonts include Cardo, Jost, System Sans-serif, and System Serif, each with their respective active variants.
The WordPress Font Library interface.

By clicking through one of them, it lets you activate or deactivate the individual fonts.

The Font Library selection dialog box displaying options for the Cardo font family. The dialog shows three variants: Cardo Normal, Cardo Bold, and Cardo Normal Italic, each with a checkbox selected. Above the variants, there's a note cautioning that too many font variants could slow down the website.
The most current fonts available in the Site Editor's Font Library.

On the upload option, can use an uploader that allows you to drag and drop files. download your fonts of choice in TTF, WOFF, WOFF2, and OTF formats.

The WordPress Font Library showing options to install Google Fonts. The search bar lets users find specific fonts, and a list displays various font options including Merienda, Merriweather, and Metal Mania. Pagination controls are visible at the bottom.
The Google Fonts library within the WordPress Site Editor.

Choose the fonts you want to download from the extensive listing, and click to click the Install button. When the successful notification appears these fonts will be displayed in the Library tab:

The WordPress Font Library displaying installed and theme fonts. Merriweather Sans is listed as an installed font with four variants active. Theme fonts include Cardo, Jost, System Sans-serif, and System Serif, each with their respective active variants.
The fonts installed for an WordPress instance.

This lets you use the fonts the same way as any other font on your website. Now, you have to customize them to fit your needs.

The Style Book

One of the risks of choosing and setting typefaces is the fact that you aren't sure how it will look together with layouts, color schemes and formats. The Style Book is invaluable, because it allows you to preview the typography options across various elements.

The WordPress Style Book editor interface showing a blue background with "Code Is Poetry" repeated in different font sizes as headings. The right-hand sidebar displays style options for typography and elements.
The Style Book of the Site Editor.

Selecting the eye icon can let you open the Style Book, and there are five tabs in the Style Book:

  • Text: Go here for a tutorial on working with paragraphs, headings and lists and many other components that focus on text.
  • Media: Here, you can alter the videos, images and audio presentation designs.
  • Design The section combines structural design facets, like separators, columns and buttons.
  • Widgets The HTML0 widgets have two elements to this screen including dynamic generation like collections of archives or comments. Also, there is a search bar, social media icons, and tag clouds here.
  • Theme It focuses on your header elements for your site including the title, tagline navigation and logo.

If you select one of the elements in the Style Book, you have several options in the sidebar. The font settings for each Block here instead of specific elements.

The Style Book showing the Typography settings panel with options for headings and paragraphs. The heading "Code Is Poetry" is displayed in various sizes, with a sample paragraph below. Font customization options are visible on the right-hand side.
There is no limit to edit typography directly from Style Book. Style Book.

You can arrive at the identical screens by clicking the styles>> Blocks section from the site Editor homepage. Whatever you choose, the choices you see let you customize the typeface (and additional) for each Block in granular detail.

Typography tuning options in the Site Editor

In all blocks and elements, you have the same core options available to the user. Below is an overview of each option within the Panel.

Font type and size

The Font drop-down menu is straightforward: choose the font you would like to apply to the specific element or Block:

The Style Book interface displaying a paragraph from Don Quixote and a list of characters from Alice in Wonderland. The right-hand sidebar shows typography settings, including font selection (currently set to Cardo) and various text formatting options. A quote by Julio Cortázar is featured in a blue box at the bottom.
Choosing a font from the fonts available in the Typography tab.

These Size settings are the most customizable in The Site Editor. Select a size within a range between Small and Extra Extra Large:

The Site Editor's Typography settings panel. The font is set to Cardo, size is set to Medium (M), and the appearance drop-down menu shows Regular selected. Line height is set to 1.55, and additional options for letter spacing and letter case are visible.
WordPress offers font size presets within the Site Editor.

If you modify theme.json, you have the ability to change these settings -- but can't use using the Editor for Sites. The Setting Custom Size button provides an option to define the size you want using an array of sizing units:

The Site Editor interface showing typography settings for a site. The main text area displays a paragraph in white on a blue background. The right-hand sidebar lets you customize font, size, appearance, and line height, with the Cardo font selected and size set to 1.2 rem.
Choosing a custom font size and the unit.

There are a variety of ways to modify typography inside the Site Editor, including techniques that you normally utilize CSS to do.

Appearance, line height, and letter spacing

The appearance drop-down menu appears straightforward: select one of the fonts from a long list, and then it'll be applied to your text. But, it's unlikely that you'll be able to use all the fonts that are suitable for the weight you select.

The Appearance drop-down menu within the WordPress Site Editor. The panel is set to Regular. Below it, a line height adjustment control is set to 1.55, with plus and minus buttons for fine-tuning.
The Appearance drop-down menu in the WordPress Site Editor.

The tests we conducted show that WordPress does not filter this list to show only accessible font weights. In addition, it will apply a "nearest match" when you choose a weight without a matching font. We use, for example, Cardo Normal, Cardo Bold, and Cardo Bold Italic for our example site. Selecting the Semi Bold, Bold, Extra Bold and Black, you can use just Cardo Bold:

A GIF of the WordPress Site Editor showing a blue background with a quote from Don Quixote on the left-hand side. The right-hand sidebar shows a user cycling through options within the Appearance drop-down menu.
Changing the appearance of text within WordPress Site Editor. WordPress Site Editor.

Line height does not use the presets feature and is a balance between the font you choose, its appearance as well as size. This value puts more space between each line and it's often a practical solution when the text appears cluttered in a row:

A GIF of the WordPress Site Editor showcasing a change in the line height setting within the right-hand sidebar. The main area displays text from Don Quixote and a list of characters from Alice in Wonderland. A quote at the bottom reads, "In quoting others, we cite ourselves."
Changing the line height in The WordPress Site Editor.

The spacing for letters is the same, and it follows the CSS tradition of adding to the spacing naturally in place:

The Site Editor Typography sidebar showing the font set to Cardo, with options to adjust size, appearance, line height, and letter spacing. A blue background with white text showcases how the letter spacing (5 px here) appears on the website.
The letter spacing can be pushed enough to make it unusable.

As with custom font sizing, you can select different sizes of measurement. A relative measurement is the most common choice here. WordPress assigns the letter spacing a CSS default of "normal." This allows the browser choose the value which, based on our experience, this works optimal.

It's common usage to employ tiny positive letter spacing values -- usually no more than 0.12rem/em -- and almost no negative spacing.

The last option - letter case - allows you to choose whether to make texts lower, upper or sentence case. You can also eliminate the casing. This will help you maintain the consistency of text, because you don't need to specifically use a specific case in the creation of content.

How do you use theme.json to determine the typography of your WordPress theme's typography

This Site Editor tool is great for those who don't have any technological knowledge. Its theme.json file is what you need to ensure that the Site Editor gives users everything they need to modify their websites. The configuration file serves as the base of development for your theme.

This article doesn't cover the layout and structure of the theme.jsonfile, but we're looking at the best way to define, set, and apply typography within.

Learning how to read the theme.json structure and defining the global settings

You use JSON to define all elements within theme.json, which includes typography. The typography element is nestled in the settings item within the file. Thereafter, you'll add additional elements, properties, and objects in order to create your website's typography.


 "version": 3,
 "settings": 
 "typography": 
 "fontFamilies": [
 
 "fontFamily": "-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Oxygen-Sans,Ubuntu,Cantarell,\"Helvetica Neue\",sans-serif",
 "slug": "system-font",
 "name": "System Font"
 
 ],
 "fontSizes": [
 
 "slug": "small",
 "size": "13px",
 "name": "Small"
 ,
 
 "slug": "medium",
 "size": "20px",
 "name": "Medium"
 
 ]
 
 
 

The entire set of elements follows a similar pattern. The defaults (and the easiest to comprehend can be described as global settings. They are arranged in an easy fashion, however you can also define typography settings for specific Blocks.

"styles": 
 "blocks": 
 "core/paragraph": 
 "typography": 
 "fontFamily": "var(--wp--preset--font-family--primary)",
 "fontSize": "var(--wp--preset--font-size--medium)",
 "lineHeight": "1.5"
 
 ,
 "core/heading": 
 "typography": 
 "fontFamily": "var(--wp--preset--font-family--secondary)",
 "fontWeight": "700"
 
 
 
 

This makes use of blocks as Blocks property, and also a unique namespace for every Block you wish to focus on. In addition, it creates two layers to nest, there is no alternative to this strategy. However, you'll have many properties to explore.

Registration of fonts

  • fontFamily maps to that the font family CSS value. This will be the stack of typefaces you wish to include in your theme.
  • name is the name you will see in the Website Editor when selecting the font. It will be human-readable.
  • Slug appends to the custom CSS property that can be used in the future.

For system fonts, this is easy:

...
 "typography": {
 "fontFamilies": [
 
 "name": "Primary",
 "slug": "primary",
 "fontFamily": "Charter, 'Bitstream Charter', 'Sitka Text', Cambria, serif"
 ,
 
 "name": "Secondary",
 "slug": "secondary",
 "fontFamily": "system-ui, sans-serif"
 

For registration of custom web fonts, you must that you utilize the FontFace property, and then define a few attributes:

...
 "name": "Secondary","slug": "secondary","fontFamily": "'Open Sans', sans-serif","fontFace" (for example:"fontFace": ["fontFamily": "Open Sans""fontFace": "OpenSanss""fontWeight": "300 800","300 800", variation of the font weight. "fontStyle": "normal" The value has to be the correct CSS font-style value. "fontStretch": "normal" Also, this must be a valid CSS font-stretch value. "src": [ "file:./assets/fonts/open-sans.woff2" ] // This is an array of URLs for custom fonts, and can support multiple formats. ,
 ...

After you've registered your Fonts, select them from the various drop-down menus within the Site Editor.

A blue background with white text reading CREATE BLOCK THEME in a bold sans-serif font. The words are stacked vertically with CREATE at the top in the largest size, BLOCK slightly smaller in the middle, and THEME smallest at the bottom.
The Create Block theme header image is from WordPress.org.

It's a boilerplate to use when building a theme, but also lets you register and define typography too. Once you register the fonts you want to register in any way that feels suitable for you (we suggest the Font Library), you are able to begin looking at the size.

Preparing fonts and sizes within theme.json

Another core task with typography is setting the size of fonts. It is done using an attribute called the fontSizes property that allows you to define predefined fonts for the Site Editor:

"settings": 
 "typography": 
 "fontSizes": [
 
 "slug": "small",
 "size": "12px",
 "name": "Small"
 ,
 
 "slug": "x-large",
 "size": "32px",
 "name": "Extra Large"
 
 ]
 
 

Similar to other typography settings, WordPress will generate a unique CSS property for each preset using the name you supply:

body 
 --wp--preset--font-size--small: 12px;
 --wp--preset--font-size--x-large: 32px;
 

WordPress disables the fluid typography feature by default, however, you can switch this off using boolean values. You can set at an overall degree...


 "version": 2,
 "settings": 
 "typography": 
 "fluid": true
 
 
 

...or for each preset and size you define:


 "name": "Medium",
 "size": "1.25rem",
 "slug": "md",
 "fluid": 
 "min": "1rem",
 "max": "1.5rem"
 
 ,

The max and min values and maximum numbers let you know the limits of scalability that apply to every font size that you choose to define.

Utilizing the latest typography features

The theme.json provides a full complement of options, similar to what is available in the Site Editor. This lets you customize the fonts on your website to a set of defaults that make sense for the theme you're using:

"styles": 
 "typography": 
 "letterSpacing": "0.02em",
 "textTransform": "uppercase",
 "textDecoration": "underline",
 "lineHeight": "1.55rem",
 "fontStyle": "normal"
 
 

You can choose to enable or disable these options. Each choice is a boolean value, which allows you to customize options with the Site Editor as well. There are several customizations you can make that go beyond the Site Editor's offerings:

  • customFontSize will be turned on by default and allows users enter the custom sizes of fonts -- but you can turn it off if you wish to tightly control the available options.
  • dropCap defaults to false however, if you choose to enable it you have the option of turning on drop caps for the initial letter of any Paragraph blocks.
  • textColumns enables an "columns" option for every text contained in an Block, and this is turned off by default.
  • writingMode enables options to change the text orientation within The Site Editor. You can give users a choice between horizontal and vertical text.

The range of theme.json means you should work there first in the process of creating themes. The features available within the Site Editor let you or your users modify WordPress typography.

How to implement typography using theme.json A practical case

FSE allows design and development through WordPress simpler than it has ever been. Additionally, the basic process of choosing and applying those fonts becomes easier. Some of this is because of design trends, but the tools exist to fill in the gaps when there isn't a graphic designer on hand to aid.

We can start with the fonts you use most often.

1. Combine typefaces with complementary styles

In reality, due to the latest fashions in design, there's less work involved. It's because the body text may make use of system fonts- specifically the primary operating system (OS) typeface. Your only job is to choose something that works alongside it.

This isn't a tutorial on the pairing of typefaces. However, we have some tips to offer:

  • OS typefaces for the body copy typically are sans-serif. This means looking for either a serif font or a sans-serif font that appears like something else, is unique and is distinctive.
  • Simple is best, perhaps you should only use the OS font, if it fits in the style.
  • Explore different combinations as you can get a feel for the typefaces that work best (and which do not).
The Google Fonts website displaying the Playfair Display font specimen. The sample text reads, "Whereas disregard and contempt for human rights have resulted" in various sizes. Options for specimen, type tester, glyphs, and about, and license are shown, along with a Get font button.
The Google Fonts specimen page for Playfair Display.

With a pair of fonts, be aware of their dimensions in relation to each other, not just on the page but relative to each other.

2. Find the right absolute and comparative sizing

Selecting the right font size is important, since the incorrect absolute sizes can ruin the user experience. It's also an area where you may want to use the default fonts. We encourage users to play around since each pairing will have their own "space" to display the fonts.

Typescale is a great tool to assist you in creating the perfect WordPress typography, no matter what your need:

The Typescale web app interface for customizing typography. The left-hand panel shows font settings, while the right-hand side displays a preview of different heading sizes and a sample landing page design.
The Typescale website.

One of the greatest features of the tool is the scale choices. It basically does all the job for you by allowing you to select complimentary font sizes. The font we choose is Major Third as our Major Third scale here, which has a factor of 1.2 and a base dimension of 16px.

A typography scale interface from Typescale, displaying various heading sizes for
The options for scaling fonts within Typeface.

In the middle of the screen, you can find the size that has been calculated of each paragraph and heading and can choose from several measurements. Take note that Typescale also lets you change the letter spacing, line height, font weight, and more: all adjustable in theme.json.

3. The application of defaults inside theme.json

Once you have the right size and typeface, you can integrate them in your theme.json file. Here's an example of how is a typical theme.json file will be like:


 "version": 3,
 "settings": 
 "typography": 
 "fontFamilies": [
 
 "fontFamily": "-apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen-Sans, Ubuntu, Cantarell, \"Helvetica Neue\", sans-serif",
 "slug": "ubuntu-sans",
 "name": "Ubuntu Sans"
 ,
 
 "fontFamily": "\"Playfair Display\", serif",
 "slug": "playfair",
 "name": "Playfair Display"
 
 ],
 "fontSizes": [
 
 "slug": "small",
 "size": "13px",
 "name": "Small"
 ,
 
 "slug": "medium",
 "size": "16px",
 "name": "Medium"
 ,
 
 "slug": "large",
 "size": "20px",
 "name": "Large"
 ,
 
 "slug": "x-large",
 "size": "25px",
 "name": "Extra Large"
 ,
 
 "slug": "huge",
 "size": "31px",
 "name": "Huge"
 
 ]
 
 ,
 "styles": 
 "typography": 
 "fontFamily": "var(--wp--preset--font-family--system)",
 "fontSize": "var(--wp--preset--font-size--medium)",
 "lineHeight": "1.8"
 ,
 "blocks": 
 "core/paragraph": 
 "typography": 
 "fontSize": "var(--wp--preset--font-size--medium)"
 
 ,
 "core/heading": 
 "typography": 
 "fontFamily": "var(--wp--preset--font-family--playfair)",
 "fontWeight": "700"
 
 ,
 "core/post-title": 
 "typography": 
 "fontSize": "var(--wp--preset--font-size--huge)"
 
 
 
 
 

The same typesetters to every Block as well as think about styling each heading with a distinct style. Make sure you have a consistent and hi-level WordPress typography system that will be the basis of the theme's style. This will create a consistent appearance across your website The Site Editor can give the user more freedom and flexibility to customize.

's role is a key component of the WordPress theme development workflow

An artistic illustration of the Dev logo. It depicts a person working at a computer in a dark environment. The image uses shades of blue and purple, showing hands typing on a keyboard and adjusting equipment. A monitor displays a stylized K logo.
The Dev logo.
The My interface showing a Push to Live dialog box. Options to push files and databases from staging to live environment are presented, with checkboxes for specific files, folders, and database tables.
The tool is a selective push.

Summary

FSE is maturing as is theme.json is central in the entire process of WordPress editing. Typography is a critical factor in this regard, and WordPress gives developers tools as well as access to elements that would have previously required a foundation in CSS as well as PHP.

The Site Editor's user-friendly interface, and the adaptability that is theme.json, you are able to create typography that improves your website's visual appeal, is in sync with your logo and adds to the overall user experience.

We'd like to know about your experiences with WordPress typography and if FSE can be the key to your success. Please share your ideas with us in the comments below.

Jeremy Holcombe

Senior Editor for WordPress Web Developer as well as Content writer. Apart from everything related to WordPress I like playing golf, at the beach, and watching movies. Also, I have height issues.