Skip to content

SVG Icon API: Iteration for WordPress 7.1 #75715

Description

@t-hamano

We have stabilized three core features and shipped them in 7.0 Beta1:

  • WP_Icons_Registry class: The singleton class that loads core SVG icons from a manifest file, stores them, and exposes methods to check registration and retrieve icon data and content. There is currently no way to register a custom icon.
  • WP_REST_Icons_Controller: The REST API controller that exposes the icon registry over wp/v2/icons, letting the editor list icons and fetch a single icon by name.
  • Icon block (core/icon): The core block that retrieves a list of icons from the endpoint and lists them in a modal. The selected icon name is saved as an attribute, and the content is rendered server-side via the icon registry.

To make the Icon API more robust and extensible, I believe the following features are necessary:

Code quality

✅ Icon registry enhancements

  • Icon namespace validation (ref): Currently, custom icon registration is not allowed, and the namespace is hardcoded as core/. If we allow custom icon registration in the future, we will need to strictly check that the icon name follows the {namespace/icon-name} format.
    Icons: Enforce strict name validation in register method #76079

✅ REST API enhancements

✅ Collection Support

Similar to Font Library, it should be possible to support collection: consumers will want to group icon sets based on their own brand.

Create Icon Picker Modal component

  • To avoid increasing bundle size, the initial implementation built a custom picker without using DataViewPicker. (ref) Perhaps it should be possible to add a component like IconPickerModal to the @wordpress/block-editor package and load it from a block. This icon picker should be useful for blocks other than the Icon block as well.

Icon block enhancements

For example, the early prototype of the Icon Block had the following features, which we can consider as enhancements:

Customizable icon support for other blocks

Some icons render their own hard-coded SVG content or symbols. Make those icons selectable via the Icon API.

Inline SVG icon (Inline format)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Needs Dev NoteRequires a developer note for a major WordPress release cycle[Block] IconAffects the Icon block[Feature] IconsRelated to Icon registration API and Icon REST API[Status] In ProgressTracking issues with work in progress[Type] IterationScoped iteration of an effort from a tracking issue or overview issue ideally for a major release.

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions