Repository navigation
Description
Part of the Dashboard Overview #77616.
Widget types need a single source-of-truth metadata file, the way blocks have block.json. Three consumers read it: @wordpress/build (emits the widget manifest), Core PHP (registers types on init), and JS (type-checks consumers).
This issue formalizes that shape and publishes the JSON Schema at schemas/json/widget.json (mirrored to schemas.wp.org/trunk/widget.json). The runtime contract settled first, piece by piece; the schema mirrors it rather than defining it up front.
Shape
widget.json holds the JSON-expressible identity of the widget: nine fields, exactly the set the build pipeline copies into the registry and PHP exposes over REST. Runtime values (icon, the attributes fields, example data) are authored in the widget's JS module (widget.ts) and merged over this file at registration.
{
"$schema": "https://schemas.wp.org/trunk/widget.json",
"name": "core/on-this-day",
"title": "On this day",
"category": "dashboard",
"description": "Surface posts published on this day in previous years.",
"keywords": [ "posts", "history" ],
"textdomain": "default",
"presentation": "framed",
"help": {
"content": "Posts are matched by publish date.",
"links": [ { "label": "Documentation", "href": "https://wordpress.org/documentation/" } ]
},
"actions": [
{ "id": "view-posts", "label": "View posts", "href": "edit.php" }
]
}Where fields overlap with block.json (name, title, category, description, keywords, textdomain), the schema reuses its wording and conventions: same name pattern, the open category string with an enum suggesting the core values, and the same property order for the shared fields, with the widget-specific ones (presentation, help, actions) grouped after. Authors moving between the two files find the same language.
Notes on the fields:
presentation('framed' | 'content-bleed' | 'full-bleed') is the host-agnostic rendering hint, settled in this thread.categorygroups types in pickers. Both travel through the build pipeline and REST before any module loads (Expose widget category through the build pipeline and REST API #79638).help(Widgets: add a declarativehelpmetadata field, surfaced as a header infotip #79830) andactions(Dashboard Widgets: declarative actions in the widget schema #80363) are declarative. The host renders them; sanitization happens at registration (help.contentkeeps<em>/<strong>only, actionhrefs are resolved and validated server-side).title,description,keywords, help content and link labels, and action labels are translated server-side withtextdomain, through the sametranslate_settings_using_i18n_schema()pathblock.jsonuses (Widgets: translatetitle,description, andkeywordsserver-side #79701).attributesstays out of this file for now, authored inwidget.tsand typed asWidgetAttributeField< Item >(Widget Primitives: AddWidgetAttributeFieldfor typed attribute schemas #79544). The API aims to be fully declarative, and the declarations are already serializable in practice:core/eventsdeclares its field with plain data, and custom types likelocationare resolved by name through the field type registry (Widget Primitives: Add a field type registry for widget attributes #80148), with the implementation registered by the host. Bringing them intowidget.jsonneeds pipeline support and a schema sync strategy; see Scope.
Module entry points and styles are discovered by convention (render.*, widget.*, style.module.css, via #77576); the schema declares no pointers for them.
Divergences from block.json
Only what changes from block.json:
block.json |
widget.json |
Reason |
|---|---|---|
apiVersion |
— | Not read by any layer yet; can be introduced when a versioned revision needs it. |
__experimental |
— | The whole widget system is gated by the gutenberg-dashboard-widgets experiment; a per-widget flag can follow when needed. |
icon / example |
— | Authored in the widget's JS module today. icon is expected to move here as a registered icon name or as SVG once the pipeline carries it, see Scope; example stays a runtime value. |
save |
— | Dynamic render; no serialized save. |
parent / ancestor / allowedBlocks |
— | Not nested in a block tree. |
providesContext / usesContext |
— | Block-tree context does not apply. |
supports |
— | Block-specific; widget supports can follow. |
editorScript |
— | No block-editor authoring script. |
render, script, style, viewScript |
— | Discovered by convention from the widget directory. |
attributes |
— | Authored in the widget's JS module today; the serializable subset is planned to move into widget.json as the API becomes fully declarative. |
| — | presentation |
Widget-specific rendering hint; the host translates or ignores it. |
| — | help |
Declarative help content and links, rendered by the host. |
| — | actions |
Declarative verbs the host offers for the widget; today each carries a link target. |
Tasks
- Publish JSON Schema at
schemas/json/widget.json, mirroring the runtime shape (Widgets: Addwidget.jsonmetadata schema #77640) - Integration tests under
test/integration/validating the corewidgets/*/widget.jsonfiles (Widgets: Addwidget.jsonmetadata schema #77640) - Add the
$schemakey to the core widget metadata files (Widgets: Addwidget.jsonmetadata schema #77640) - TS types in
@wordpress/widget-primitives(WidgetType+WidgetAttributeField;WidgetTypeMetadatais the internal authoring shape) - Document the shape in the schema README (Widgets: Add
widget.jsonmetadata schema #77640)
Scope
Out of scope, in follow-ups:
- Auto-discovery in
@wordpress/build(wp-build: Add automatic widget discovery and registration #77576) - PHP
register_widget_type()and manifest reader. Widgets: translatetitle,description, andkeywordsserver-side #79701 forwards and translates the metadata strings; a public registration API is still open - The
Field[]attribute editor and rendering contract, settled in Widget settings: surface and attribute model #79246 and extended by the field type registry (Widget Primitives: Add a field type registry for widget attributes #80148) - Declarative
attributesinwidget.json: the pipeline reading them (build, PHP, REST, i18n for field labels) plus a sync strategy for the Field shape, either generated from the@wordpress/dataviewstypes with a drift test, or a$refto a shared definition owned by that package, so the schema section is derived rather than hand-maintained. DataViews defines the core field types; the field type registry (Widget Primitives: Add a field type registry for widget attributes #80148) accepts custom ones resolved by name at runtime, soattributes[].typestays an open string with the core vocabulary suggested through an enum, the same conventioncategoryuses - Declarative
iconinwidget.json: one string field accepting a registered icon name from Core's Icons API, inline SVG, or a.svgfile in the widget directory, with thewidget.tsReact element still standing when none is declared. Names resolve inuseWidgetTypes, the same boundary that already resolves attribute field type references, against a resolver the host registers. Tracked in Widgets: carry a declarativeiconthrough the widget pipeline #80938 - Overrides for module entry points and style assets, once real cases need them
- Render types beyond JS modules (block compositions, saved entities); the schema extends without breaking changes
- Promotion from
__experimental
Related
- wp-build: Add blocks folder support for automatic block discovery and registration #74542, wp-build: Add automatic widget discovery and registration #77576
- Widget Primitives: Add
WidgetAttributeFieldfor typed attribute schemas #79544 (WidgetAttributeField) - Expose widget category through the build pipeline and REST API #79638 (
categorythrough build + REST) - Widget settings: surface and attribute model #79246 (settings surface and attribute fields)
- Widgets: translate
title,description, andkeywordsserver-side #79701 (translatable metadata through the manifest + REST) - Widgets: add a declarative
helpmetadata field, surfaced as a header infotip #79830 (declarativehelp) - Dashboard Widgets: declarative actions in the widget schema #80363 (declarative
actions) - Widget Primitives: Add a field type registry for widget attributes #80148 (field type registry)
- Widgets: carry a declarative
iconthrough the widget pipeline #80938 (declarativeicon) - SVG Icon API: Iteration for WordPress 7.1 #75715 (SVG Icon API iteration for 7.1)
Note
This shape mirrors what the pipeline reads today and extends without breaking changes as new fields land.
Activity
[-]Add widget.json metadata schema[/-][+]Add `widget.json` metadata schema[/+]im3dabasia commentedon Apr 24, 2026
@retrofox, Thanks for the issue! I'll be actively working on this. Once my PR is ready, I’ll tag you for quick feedback. Here is the PR in progress: #77640
jameskoster commentedon May 1, 2026
How would a widget define it's grid dimensions? Many widgets will want to specify a default size, and others may like to specify min/max.
retrofox commentedon May 5, 2026
A widget is agnostic of where it's located. It would render the content of a Dashboard tile, in a sidebar, in a modal inserter, etc.
Specifically in the context of the dashboard, the size (and other props) of the dashboard tile is defined by its API.
Also, its definition will be tied to the grid that we use to organize the dashboard. Currently, we've implemented dashboard 2x, but switching to Masonry or another tiles configuration would be possible.
Props like width, height, and position are naturally expected.
Dashboard PR [wip]: #77770
simison commentedon May 5, 2026
@retrofox @jameskoster, it might still make sense to offer size hints like "small, medium, large, full" or similar; then the dashboard can try to accommodate those sizes in a declarative but dashboard agnostic way? It's a hint, not a promise. Avoids declaring things like the number of columns.
A good example of a large/full banner would be a "welcome" banner, which likely should span the full width. Another is any kind of "onboarding checklists", which should likely take significant space:
An example of a small metric-oriented widget is one that likely just includes a number of some sort.
retrofox commentedon May 5, 2026
Worth bringing in a third angle, Matias raised at a recent meetup. The widget may not need to declare a size, and doesn't pick one either.
The host owns the widget chrome (the outer tile/container) and its dimensions; the widget always expands to fill that chrome, or not (this is a designer decision).
What the widget can do is observe the size it's been given and optionally adapt what it renders inside.
A simple widget renders the same thing at any size and lets the layout flex.
A more sophisticated widget can swap representations: a single metric in a small chrome, the same metric plus a sparkline in a wider one, a full chart with a table in a 4x2.
This keeps
widget.jsonentirely out of the size question and avoids the common-goods problem of authors overclaiming size.It also resolves the "same widget, different surfaces" tension: the widget doesn't need to know which surface it's on, only which space it's been given.
Specifically for the schema, this means we don't need a
sizeHintfield. What might still earn a place is a capability declaration (for example, what density modes a widget supports), or the schema stays silent. The widget render contract handles it entirely.jameskoster commentedon May 5, 2026
Yes like Apple widgets. Makes sense. I still wonder if there could be some benefit to having default sizes for different widget types though. But maybe this can be presented as a part of the widget insertion flow. E.g. when you select a Stat widget there's a secondary step where you see previews of different sizes and select the one you want to insert. 'Simple' widgets would just be click-and-go.
retrofox commentedon May 5, 2026
I think this is the natural next step the user will take right after inserting the widget into the dashboard. They can resize, move, and even delete the widget instance.
retrofox commentedon May 11, 2026
Working on a static, declarative
presentationfield onwidget.jsonfor this.The widget expresses its intent for its own rendering (
framedby default, orfull-bleed); the surface translates the hint into its layout, or ignores it.The field describes the widget and never names a surface; a surface with no chrome treats both values the same way.
This covers the case where a widget is inherently edge-to-edge (image-led hero, embedded canvas) and needs to drop the surface chrome unilaterally, without consumers special-casing widget names.
It's connected with #77856
jameskoster commentedon May 12, 2026
I'm curious if we have an actual confirmed use case for this functionality yet? It's neat, but I'd be a little anxious about adding early support for features we might not need.
retrofox commentedon May 12, 2026
The example mentioned earlier can be found here: #74936.
The widget occupies the entire surface of the dashboard tile. Usually, all instances display a title and/or icon, but in this case, the widget suggests filling the entire space.
I think this appears to be a common pattern not only in dashboard/widget implementation but also when working with abstractions like group, stack, and others.
The issue linked above also highlights the same scenario for the Card component: #77856.
jameskoster commentedon May 12, 2026
I'm curious how that design will work with different background images. For instance if the image is very light then the content be very difficult to see. For this to work we might need to wrap the widget in a
ThemeProviderinstance and populate thebgprop with a color extracted from the image, maybe add a readability scrim as well to be safe. I'm not sure how well that will work in practice though.retrofox commentedon May 12, 2026
That's a valid concern. I think what we can do for now is add an awful background color to the text to get the proper contrast, but what you highlight is a valid concern.
retrofox commentedon Jun 29, 2026
Refreshed the description to match what has landed since this was opened:
@wordpress/widget-primitives(renamed fromwidget-types).WidgetTypeand theWidgetAttributeFieldhelper are exported;WidgetTypeMetadatais the internal authoring shapeWidgetTypeextends.presentation(shipped),keywords,version,example, and the__experimentalgate.attributesentries useWidgetAttributeField< Item >(Widget Primitives: AddWidgetAttributeFieldfor typed attribute schemas #79544), narrowingField['id']to the widget's attribute keys.A per-attribute
relevancehint is being settled in Widget settings: surface and attribute model #79246.categorynow travels through the build pipeline and REST (Expose widget category through the build pipeline and REST API #79638), alongsidepresentation.widget.jsonmetadata schema #77640; remaining tasks are tracked against it.Also added a note that the shape is a work in progress and subject to change.
retrofox commentedon Jun 30, 2026
#79701 takes on part of the "PHP
register_widget_type()and manifest reader" follow-up, specifically translating the metadata strings.It forwards
title,description, andkeywordsfromwidget.jsonto the server, translates them at registration through an i18n schema (the sametranslate_settings_using_i18n_schema()pathblock.jsonuses), and returns the localized values from/wp/v2/widget-modules.Still pending for end-to-end translations:
wp i18n make-potlearning to scanwidget.json, which lives in the WP-CLI i18n-command. Same dependencyblock.jsonhad.