Skip to content

Widget Dashboard: host-tunable tile spacing via public custom properties - #81352

Merged
retrofox merged 6 commits into
trunkfrom
update/widget-dashboard-tile-spacing
Aug 11, 2026
Merged

Widget Dashboard: host-tunable tile spacing via public custom properties#81352
retrofox merged 6 commits into
trunkfrom
update/widget-dashboard-tile-spacing

Conversation

@retrofox

@retrofox retrofox commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

What?

Adds two public custom properties to the widget dashboard chrome:

  • --wp-widget-dashboard-tile-padding: padding of the tile surface. Defaults to the Card default (--wpds-dimension-padding-2xl).
  • --wp-widget-dashboard-tile-header-gap: space between the tile header and the body. Follows the tile padding unless set apart; defaults to the Card default (--wpds-dimension-gap-xl).

The chrome resolves them into Card's spacing properties (--wp-ui-card-padding, --wp-ui-card-header-content-gap) at the three places that render tile chrome: the tile itself, the floating header used by full-bleed tiles, and the picker preview chrome.

Part of #77616. Related: #81351 (Card spacing contract).

Why?

Dashboard hosts need denser tiles than the Card default: at small tile sizes the 24px padding takes space that self-sizing widgets need for content.

Card's spacing properties are declared on Card.Root itself, so hosts cannot set them through inheritance and end up with structural selectors against hashed class names.

Making the header gap follow the padding avoids a double space: lowering only the padding leaves Card's derived margin positive, and the header/body separation renders as the header's block-end padding plus a content margin.

How?

Each chrome site resolves the public properties on its own element, where Card's re-declarations live. Module CSS is unlayered, so it deterministically wins over Card's @layer wp-ui declarations.

The fallback chain is repeated per site on purpose: resolving it once on a shared ancestor would recreate the inheritance trap this fixes.

The floating header for full-bleed tiles consumes the same padding property, so its toolbar stays aligned with in-card headers at any density. The preview chrome resolves the properties on its own Card.Root, so picker previews follow the host density even though the picker dialog portals out of the dashboard subtree.

Defaults are unchanged: with no host override, tiles render exactly as today.

Testing Instructions

npm run storybook:dev

Open the Widget Dashboard stories.

In DevTools, set --wp-widget-dashboard-tile-padding: var(--wpds-dimension-padding-lg) on the dashboard wrapper element.

  • Framed tiles: padding and the header/body space tighten to 16px, with no extra margin between header and body.
  • Content-bleed tiles: the body still reaches the side and bottom edges; the space under the header is a single 16px band.
  • Full-bleed tiles: the floating toolbar inset matches the 16px padding.
  • Open the inserter: preview tiles reflect the same spacing.
  • Remove the override and confirm tiles render exactly as trunk.

Screenshots or screencast

(before/after at default and padding-lg densities)

Follow-ups

@retrofox retrofox added [Type] Enhancement A suggestion for improvement. [Feature] Dashboard WordPress admin dashboard, widget framework, and layout customization [Package] Widget Dashboard /packages/widget-dashboard labels Aug 7, 2026
@retrofox retrofox self-assigned this Aug 7, 2026
header gap follows tile padding; defaults unchanged
@retrofox
retrofox force-pushed the update/widget-dashboard-tile-spacing branch from 04daa9c to fdb865b Compare August 7, 2026 16:13
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: retrofox <retrofox@git.wordpress.org>
Co-authored-by: chihsuan <chihsuan@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Size Change: 0 B

Total Size: 7.65 MB

compressed-size-action

@retrofox
retrofox requested a review from chihsuan August 7, 2026 16:39

@chihsuan chihsuan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! @retrofox I tested the main dashboard, and the live tile behavior works nicely. 👍

Just one bigger-picture question:

Do we expect consumers to need different padding already? I can see the value in making it flexible, but I also wonder whether it could make dashboards feel inconsistent
between hosts. Card may eventually provide its own density prop too.

I previously created #81207 to update core default value to use 16px. I was wondering would using 16px consistently for now, give us a simpler path until we have concrete use cases for multiple densities? I don’t feel strongly either way, but I'd love to hear your thoughts.

```

`--wp-widget-dashboard-tile-padding` controls the padding of the tile surface. `--wp-widget-dashboard-tile-header-gap` controls the space between the tile header and the body; it follows the tile padding unless set apart. Use `--wpds-*` spacing tokens as values. The floating header of full-bleed tiles and the picker previews follow the same properties.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One issue I noticed with the picker preview:

the spacing variables are expected to be set on a dashboard ancestor, but the picker is rendered through Dialog.Portal under document.body. Because CSS custom properties follow the DOM tree, the preview won’t inherit values set only on the dashboard wrapper and will fall back to the default spacing.

Maybe we want to document this or propagate the spacing values to the portal or mount it within the configured dashboard ancestor?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch; the mechanism is exactly that.

Took the documentation route: the README example now sets the properties at :root and states why, since the picker mounts in a dialog under document.body, which a wrapper's custom properties never reach.

Propagating computed values into the portal is more machinery than this bridge warrants today. If a real case arises with two dashboards at different densities on one page, that is the moment to add it.

@retrofox

Copy link
Copy Markdown
Contributor Author

Thanks for your feedback, Chi.

The default remains the Card default on purpose. How density should work at the system level is still an open question upstream (#74556), and the earlier implementation was dropped (#78741).
The current direction is to experiment with the Card variables rather than fork the default.

These two properties are how a host of this dashboard can run that experiment: the chrome re-declares --wp-ui-card-padding on the tile, so a value set on an ancestor can never reach it without this bridge.

A fixed 16px would change the default for every host before the experiments report back, and the range being explored is 16-20px rather than a fixed 16.

With the properties, a host that wants 16px today sets one line; if a Card density prop lands later, the properties retain their meaning and the bridge remaps to it.

On consistency: values funnel through --wpds-* tokens, and per-host tuning is the use case rather than drift: a dense host aligns tiles with its own chrome, while the default remains uniform elsewhere.

@chihsuan
chihsuan requested a review from simison August 11, 2026 02:32

@chihsuan chihsuan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, thanks for the detailed reply Damián!

Not going to block this, the package is experimental so we can always adjust the default later. LGTM! 👍

@retrofox
retrofox merged commit 1a1b94c into trunk Aug 11, 2026
61 checks passed
@retrofox
retrofox deleted the update/widget-dashboard-tile-spacing branch August 11, 2026 08:38
@github-actions github-actions Bot added this to the Gutenberg 23.8 milestone Aug 11, 2026
shail-mehta pushed a commit that referenced this pull request Aug 12, 2026
…ies (#81352)

* add host-tunable tile spacing to widget chrome

header gap follows tile padding; defaults unchanged

* document :root placement for tile spacing vars
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Dashboard WordPress admin dashboard, widget framework, and layout customization [Package] Widget Dashboard /packages/widget-dashboard [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Sponsor
SponsoredKunjungi sekarang
Promo