Skip to content

Add widget.json metadata schema #77629

Open

Description

@retrofox

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:

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

Scope

Out of scope, in follow-ups:

Related

Note

This shape mirrors what the pipeline reads today and extends without breaking changes as new fields land.

Activity

  1. added
    [Type] New API
    [Feature] Dashboard
    on Apr 23, 2026
  2. changed the title [-]Add widget.json metadata schema[/-] [+]Add `widget.json` metadata schema[/+] on Apr 23, 2026
  3. added
    [Status] In Progress
    on Apr 24, 2026
  4. im3dabasia commented on Apr 24, 2026

    @im3dabasia
    Contributor

    @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

  5. jameskoster commented on May 1, 2026

    @jameskoster
    Contributor

    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.

  6. retrofox commented on May 5, 2026

    @retrofox
    ContributorAuthor

    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.

    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

  7. simison commented on May 5, 2026

    @simison
    Member

    @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:

    Image

    An example of a small metric-oriented widget is one that likely just includes a number of some sort.

  8. retrofox commented on May 5, 2026

    @retrofox
    ContributorAuthor

    @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.

    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.json entirely 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 sizeHint field. 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.

  9. jameskoster commented on May 5, 2026

    @jameskoster
    Contributor

    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.

  10. retrofox commented on May 5, 2026

    @retrofox
    ContributorAuthor

    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.

    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.

  11. retrofox commented on May 11, 2026

    @retrofox
    ContributorAuthor

    Working on a static, declarative presentation field on widget.json for this.

    The widget expresses its intent for its own rendering (framed by default, or full-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.

    Image

    It's connected with #77856

  12. jameskoster commented on May 12, 2026

    @jameskoster
    Contributor

    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.

  13. retrofox commented on May 12, 2026

    @retrofox
    ContributorAuthor

    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.

    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.

  14. jameskoster commented on May 12, 2026

    @jameskoster
    Contributor

    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 ThemeProvider instance and populate the bg prop 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.

  15. retrofox commented on May 12, 2026

    @retrofox
    ContributorAuthor

    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.

  16. retrofox commented on Jun 29, 2026

    @retrofox
    ContributorAuthor

    Refreshed the description to match what has landed since this was opened:

    Also added a note that the shape is a work in progress and subject to change.

  17. retrofox commented on Jun 30, 2026

    @retrofox
    ContributorAuthor

    #79701 takes on part of the "PHP register_widget_type() and manifest reader" follow-up, specifically translating the metadata strings.

    It forwards title, description, and keywords from widget.json to the server, translates them at registration through an i18n schema (the same translate_settings_using_i18n_schema() path block.json uses), and returns the localized values from /wp/v2/widget-modules.

    Still pending for end-to-end translations: wp i18n make-pot learning to scan widget.json, which lives in the WP-CLI i18n-command. Same dependency block.json had.

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

Metadata

Metadata

Labels

[Feature] Dashboard[Status] In Progress[Type] New API

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions