diff --git a/packages/global-styles-ui/CHANGELOG.md b/packages/global-styles-ui/CHANGELOG.md
index 10c04fbd7ad34f..72fb5e240df592 100644
--- a/packages/global-styles-ui/CHANGELOG.md
+++ b/packages/global-styles-ui/CHANGELOG.md
@@ -6,6 +6,7 @@
- Element screens: add an "Overridden by" list of the block types whose own styles override the element, linking to each block's screen ([#84671](https://github.com/WordPress/gutenberg/pull/84671)).
- Show icons for elements in the Blocks & Elements list, and rename Input, Select and Button (element) to Form input, Form select and Form button ([#85363](https://github.com/WordPress/gutenberg/pull/85363)).
+- Font Library: Paginate installed fonts in the Library tab, like in the Install tab ([#86063](https://github.com/WordPress/gutenberg/pull/86063)).
## 2.0.0 (2026-10-20)
diff --git a/packages/global-styles-ui/src/font-library/font-collection.tsx b/packages/global-styles-ui/src/font-library/font-collection.tsx
index 319c2b24af65ed..f4d64d7d891d99 100644
--- a/packages/global-styles-ui/src/font-library/font-collection.tsx
+++ b/packages/global-styles-ui/src/font-library/font-collection.tsx
@@ -1,10 +1,4 @@
-import {
- useContext,
- useEffect,
- useState,
- useMemo,
- createInterpolateElement,
-} from '@wordpress/element';
+import { useContext, useEffect, useState, useMemo } from '@wordpress/element';
import {
__experimentalSpacer as Spacer,
__experimentalText as WCText,
@@ -23,17 +17,10 @@ import {
// eslint-disable-next-line @wordpress/use-recommended-components -- Intentional early adoption of the new Menu, pending WordPress/gutenberg#76135.
Menu,
Progress,
- Select,
} from '@wordpress/ui';
import { debounce } from '@wordpress/compose';
-import { sprintf, __, _x, isRTL } from '@wordpress/i18n';
-import {
- moreVertical,
- next,
- previous,
- chevronLeft,
- chevronRight,
-} from '@wordpress/icons';
+import { __, _x, isRTL } from '@wordpress/i18n';
+import { moreVertical, chevronLeft, chevronRight } from '@wordpress/icons';
import { useEntityRecord } from '@wordpress/core-data';
import type {
FontCollection as FontCollectionType,
@@ -43,6 +30,7 @@ import type {
} from '@wordpress/core-data';
import { FontLibraryContext } from './context';
import FontCard from './font-card';
+import Pagination, { getFontsPerPage } from './pagination';
import filterFonts from './utils/filter-fonts';
import { toggleFont } from './utils/toggleFont';
import {
@@ -61,7 +49,6 @@ const DEFAULT_CATEGORY = {
};
const LOCAL_STORAGE_ITEM = 'wp-font-library-google-fonts-permission';
-const MIN_WINDOW_HEIGHT = 500;
function FontCollection( { slug }: { slug: string } ) {
const requiresPermission = slug === 'google-fonts';
@@ -136,10 +123,7 @@ function FontCollection( { slug }: { slug: string } ) {
[ collectionFonts, filters ]
);
- // NOTE: The height of the font library modal unavailable to use for rendering font family items is roughly 417px
- // The height of each font family item is 61px.
- const windowHeight = Math.max( window.innerHeight, MIN_WINDOW_HEIGHT );
- const pageSize = Math.floor( ( windowHeight - 417 ) / 61 );
+ const pageSize = getFontsPerPage();
const totalPages = Math.ceil( fonts.length / pageSize );
const itemsStart = ( page - 1 ) * pageSize;
const itemsLimit = page * pageSize;
@@ -546,91 +530,11 @@ function FontCollection( { slug }: { slug: string } ) {
justify="end"
spacing={ 6 }
>
-
- { createInterpolateElement(
- sprintf(
- // translators: 1: Current page number, 2: Total number of pages.
- _x(
- 'Page
%1$sof %2$d
',
- 'paging'
- ),
- '',
- totalPages
- ),
- {
- div: ,
- // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
- CurrentPage: (
- {
- if ( newPage !== null ) {
- setPage(
- parseInt( newPage )
- );
- }
- } }
- >
-
-
- { [
- ...Array( totalPages ),
- ].map( ( e, i ) => {
- const value = (
- i + 1
- ).toString();
- return (
-
-
- { value }
-
-
- );
- } ) }
-
-
- ),
- }
- ) }
-
-
-
+
) }
>
diff --git a/packages/global-styles-ui/src/font-library/installed-fonts.tsx b/packages/global-styles-ui/src/font-library/installed-fonts.tsx
index b45f906c1887c9..ecdf423802fe58 100644
--- a/packages/global-styles-ui/src/font-library/installed-fonts.tsx
+++ b/packages/global-styles-ui/src/font-library/installed-fonts.tsx
@@ -25,6 +25,7 @@ import type {
import type { FontFamily } from '@wordpress/core-data';
import { FontLibraryContext } from './context';
import FontCard from './font-card';
+import Pagination, { getFontsPerPage } from './pagination';
import LibraryFontVariant from './library-font-variant';
import { sortFontFaces } from './utils/sort-font-faces';
import {
@@ -130,6 +131,27 @@ function InstalledFonts() {
)
: [];
+ // Theme and custom fonts are paginated as one list, theme fonts first.
+ const [ page, setPage ] = useState( 1 );
+ const pageSize = getFontsPerPage();
+ const totalPages = Math.ceil(
+ ( baseThemeFonts.length + baseCustomFonts.length ) / pageSize
+ );
+ const itemsStart = ( page - 1 ) * pageSize;
+ const itemsLimit = page * pageSize;
+ const pageThemeFonts = baseThemeFonts.slice( itemsStart, itemsLimit );
+ const pageCustomFonts = baseCustomFonts.slice(
+ Math.max( itemsStart - baseThemeFonts.length, 0 ),
+ Math.max( itemsLimit - baseThemeFonts.length, 0 )
+ );
+
+ // Go back a page when the last font of the last page is deleted.
+ useEffect( () => {
+ if ( totalPages > 0 && page > totalPages ) {
+ setPage( totalPages );
+ }
+ }, [ page, totalPages ] );
+
const customFontFamilyId =
libraryFontSelected?.source === 'custom' && libraryFontSelected?.id;
@@ -304,7 +326,7 @@ function InstalledFonts() {
{ __( 'No fonts installed.' ) }
) }
- { baseThemeFonts.length > 0 && (
+ { pageThemeFonts.length > 0 && (
{
@@ -321,7 +343,7 @@ function InstalledFonts() {
role="list"
className="font-library__fonts-list"
>
- { baseThemeFonts.map( ( font ) => (
+ { pageThemeFonts.map( ( font ) => (
) }
- { baseCustomFonts.length > 0 && (
+ { pageCustomFonts.length > 0 && (
{
@@ -366,7 +388,7 @@ function InstalledFonts() {
role="list"
className="font-library__fonts-list"
>
- { baseCustomFonts.map( ( font ) => (
+ { pageCustomFonts.map( ( font ) => (
{
+ // Show the page of the font, so focus can return to it.
+ const fontIndex = [
+ ...baseThemeFonts,
+ ...baseCustomFonts,
+ ].findIndex(
+ ( font ) =>
+ font.slug ===
+ libraryFontSelected?.slug &&
+ font.source ===
+ libraryFontSelected?.source
+ );
+ if ( fontIndex !== -1 ) {
+ setPage(
+ Math.floor(
+ fontIndex / pageSize
+ ) + 1
+ );
+ }
setLastSelectedFontSlug(
libraryFontSelected?.slug
);
@@ -505,6 +545,13 @@ function InstalledFonts() {
) }
+ { ! libraryFontSelected && totalPages > 1 && (
+
+ ) }
{ shouldDisplayDeleteButton && (
void;
+} ) {
+ return (
+
+
+ { createInterpolateElement(
+ sprintf(
+ // translators: 1: Current page number, 2: Total number of pages.
+ _x( 'Page
%1$sof %2$d
', 'paging' ),
+ '',
+ totalPages
+ ),
+ {
+ div: ,
+ // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
+ CurrentPage: (
+ {
+ if ( newPage !== null ) {
+ onChange( parseInt( newPage ) );
+ }
+ } }
+ >
+
+
+ { [ ...Array( totalPages ) ].map(
+ ( e, i ) => {
+ const value = ( i + 1 ).toString();
+ return (
+
+
+ { value }
+
+
+ );
+ }
+ ) }
+
+
+ ),
+ }
+ ) }
+
+
+ onChange( page - 1 ) }
+ disabled={ page === 1 }
+ accessibleWhenDisabled
+ label={ __( 'Previous page' ) }
+ icon={ isRTL() ? next : previous }
+ showTooltip
+ size="compact"
+ tooltipPosition="top"
+ />
+ onChange( page + 1 ) }
+ disabled={ page === totalPages }
+ accessibleWhenDisabled
+ label={ __( 'Next page' ) }
+ icon={ isRTL() ? previous : next }
+ showTooltip
+ size="compact"
+ tooltipPosition="top"
+ />
+
+
+ );
+}
+
+export default Pagination;