Skip to content

Storybook: Add Settings Page design system patterns - #86451

Merged
jameskoster merged 13 commits into
trunkfrom
add/settings-page-patterns
Nov 20, 2026
Merged

jameskoster merged 13 commits into
trunkfrom
add/settings-page-patterns

Conversation

@jameskoster

@jameskoster jameskoster commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

What?

Adds a "Design System / Patterns / Settings Page" docs page to Storybook with templates for settings screens, composed from the admin-ui Page, @wordpress/ui components, @wordpress/theme tokens and DataViews:

  • Simple settings page: a single page with a few cards of settings.
  • Adjacent pages: peer sections switched with the Page navigation, each with its own draft and Save.
  • Subpages: a card listing payment gateways as full-width rows with a status Badge, each opening a subpage with breadcrumbs and the same badge in the header.
  • Adjacent pages and subpages: how breadcrumbs work when a subpage belongs to one of several adjacent pages.
  • Records: an API keys table in DataViews, with records that open a subpage, a dialog or a drawer (including an irreversible revoke confirmation).

The templates are starting points, not prescriptions. Not every settings page has to follow these exact patterns, and the docs page says so too. They show one well-composed way to build each kind of screen, to adapt or depart from where a product's settings call for something different.

It also extends the Save & Submit pattern's "Unsaved changes on exit" section with guidance the templates follow.

Why?

Settings screens are among the most common admin surfaces, and there's no reference for composing them from the new design system packages. These templates give a starting point that follows the Save & Submit and Destructive Actions patterns, so each settings screen doesn't have to rediscover the same decisions.

How?

Each template is a story with its source shown via "Show code". Shared helpers live alongside them in storybook/stories/design-system/patterns/settings-page/:

  • Manual save: one Save per page in the Page header, disabled when there's nothing to save, with a snackbar on success. On/off settings use checkboxes rather than toggles, since nothing applies until Save.
  • Unsaved changes guard: navigating away with unsaved edits asks "Discard unsaved changes?" in an AlertDialog, and reloading uses the browser's beforeunload warning. The in-canvas TanStack router uses a small memory-history wrapper, because memory history ignores blockers.
  • Overlays: dialogs and drawers that hold a draft close only through their footer actions. They portal into a container inside each example, so they stay within the example and only lock its scrolling, not the docs page. Confirmations render alongside the dialog or drawer rather than nested in it, so their backdrop covers it.
  • Accessibility: subpage rows are a ul named by the card heading, with each link named after its destination and the status badge connected through aria-describedby.
  • Width: form content is capped at --wpds-dimension-surface-width-xl, and records tables at --wpds-dimension-surface-width-2xl.

Testing Instructions

  1. Run npm run storybook:dev and open Design System / Patterns / Settings Page.
  2. In any template, change a field: Save becomes enabled. Click Save and confirm a snackbar appears and Save is disabled again.
  3. In "Adjacent pages", change a field, then switch to another page. Confirm the "Discard unsaved changes?" dialog appears, that "Keep editing" keeps your edit, and that "Discard changes" navigates.
  4. In "Subpages", open a gateway. Confirm the breadcrumb reads "Settings / Card payments" and the header shows the gateway's status badge. Clear or change the key, save, and go back: the badge in the row reflects the saved value.
  5. In "Records that open a dialog" and "Records that open a drawer", open a key. Confirm the overlay stays inside the example, the docs page still scrolls, clicking outside does nothing, and Escape with unsaved edits asks first.
  6. In the drawer, click Revoke. Confirm the confirmation dims the drawer, Cancel returns to the drawer, and "Revoke key" removes the row.

Testing Instructions for Keyboard

  1. Tab through each template and confirm every control is reachable, with a visible focus ring on the subpage rows.
  2. Open a record with Enter, edit with the keyboard, and press Escape: confirm the discard confirmation appears and focus moves into it.
  3. In the drawer, activate Revoke, then Cancel: focus returns to the Revoke button.
  4. With a screen reader, confirm the gateways list announces as "Payment gateways, list, 3 items" and each row as the gateway name, with its status as the description.

Screenshots or screencast

Simple settings page

01-simple

Adjacent settings pages

02-adjacent-pages

Settings subpages

04-subpages 05-subpage

Adjacent pages with subpages

06-adjacent-pages-and-subpages Image

Records with subpages

07-records 08-record-subpage

Records dialog

09-records-dialog

Records drawer

10-records-drawer

Use of AI Tools

This PR was authored with Cursor (Claude), working from my direction and feedback across many iterations. I've reviewed the templates and guidance in Storybook.

@jameskoster jameskoster added [Type] Developer Documentation Documentation for developers Storybook Storybook and its stories for components labels Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground Preview in Storybook

🎉 Props

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: jameskoster <jameskoster@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: aduth <aduth@git.wordpress.org>

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


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

📦 Bundle size

Size Change: -397 B (0%)

Total Size: 8.66 MB

📦 View Changed
Filename Size Change
build/scripts/block-library/index.min.js 427 kB +14 B (0%)
build/scripts/core-data/index.min.js 76.8 kB -182 B (-0.24%)
build/scripts/editor/index.min.js 572 kB -229 B (-0.04%)

f79ee1a Run

@jameskoster
jameskoster requested a review from a team November 6, 2026 16:24
@jasmussen

Copy link
Copy Markdown
Contributor

I like this a lot. And since we have a slew of React-based settings canvases in the admin already, e.g. Appearance → Fonts and Settings → Connectors, it makes sense to have this guidance.

I'd argue we could even benefit from a bit more componentry, such as SectionHeader, ActionList, and SummaryButton, but that's separate.

What does this need to land?

@jameskoster

jameskoster commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor Author

The main open question is whether the 'adjacent pages' are included in the breadcrumb trail. Consider this example:

06-adjacent-pages-and-subpages

When I click into the Card payments subpage, what does the breadcrumb read?

Settings / Card payments

Or

Settings / Payments / Card payments

There are arguments both ways. The latter is more explicit but there's a wrinkle; it makes the active 'adjacent page' part of the path meaning that the breadcrumb on the 'General' page should be Settings / General which might feel a bit unexpected if you followed a 'Settings' link.

Perhaps more importantly it exposes a question that's tricky to answer, if the breadcrumb is Settings / General then where is the user taken when they click Settings? There is no Settings page—Settings and General are the same page, so it's arguably inappropriate for them to appear separately in the breadcrumb.

This really gets into the weeds of wider navigation patterns that we probably can't solve here. Overall I lean toward including the adjacent pages in the breadcrumb, so two potential options for this PR:

  1. Omit the first navigation item, meaning there's no active item when you land on Settings.
  2. Keep the first navigation item, but sync its label with the section title. In this case both would read "General settings". I don't love this because it produces General settings / Payments when Payments isn't a child of General.

There are trade-offs both ways, so I'm interested to hear what y'all think on this subject.

@jameskoster

Copy link
Copy Markdown
Contributor Author

I asked AI for feedback and it suggested a third option:

On General itself, I’d be comfortable making Settings a nonlinked ancestor to avoid a link to the current destination. There is some redundancy, but I find that less troublesome than changing the navigation model to eliminate it.

So the title in the example would be Settings / General, and 'Settings' would not be a link. Breadcrumb doesn't currently support this so it would involve an API change that I don't love.


On balance I think I actually lean toward showing a Settings / General breadcrumb, where clicking Settings link to General, but it's by no means perfect.

@jasmussen

Copy link
Copy Markdown
Contributor

I dabbled with related breadcrumbs recently and came to a similar or adjacent conclusion.

WooCommerce has deep settings, so imagine you have something like their shipping settings. Starting from WooCommerce Settings as the starting breadcrumb, you might end up with something like:

Settings → Shipping → Shipping zones → Denmark → Flat rate

Now the top level Settings page could either show a stack of buttons, of which one of them was a "Shipping" SummaryButton. OR it could show tabs, of which "Shipping" was a tab. Consider the tab angle, here, "Shipping zones" would be a button on that tab page.

I experimented with the tab, what I found was:

  • When you see Settings as the title and have tabs, you don't need to also update the breadcrumb trail when selecting a tab. Just press the "General" tab—the first tab in the row, it feels entirely organic.
  • When you press the Shipping tab, and then Shipping zones, the breacrumb trail would read Settings → Shipping → Shipping zones, and pressing "Shipping" would take you back to the top level, but with the Shipping tab active.

The behaviour I'm describing there feels totally intuitive to me. What do you think?

I know this would be "page navigation" not "tabs" and there's a difference, but I'm calling it tab just for conversation here.

@jameskoster

Copy link
Copy Markdown
Contributor Author

I'm a bit unsure about that; a single navigation action adds two items to the breadcrumb trail which feels a bit unexpected. We can try it though.

@jameskoster

Copy link
Copy Markdown
Contributor Author

Implemented the suggestion and added a screenshot to the Adjacent pages with subpages section.

@jameskoster
jameskoster marked this pull request as ready for review November 10, 2026 13:45
@jasmussen

Copy link
Copy Markdown
Contributor

I genuinely think it works, and is worth starting with here.

@jameskoster
jameskoster requested a review from a team November 10, 2026 14:06
jameskoster and others added 4 commits November 10, 2026 14:08
Add templates for settings screens composed from the admin-ui Page,
@wordpress/ui components, theme tokens and DataViews: a simple page,
adjacent pages, subpages with breadcrumbs, and records that open a
subpage, dialog or drawer. Document the manual save model's unsaved
changes guard in the Save & Submit pattern.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Adjacent pages now show a "Settings / <page>" breadcrumb, with Settings
leading to the first adjacent page since the area has no page of its own.
Subpages of an adjacent page pass through it, for example
"Settings / Payments / Card payments".

Co-authored-by: Cursor <cursoragent@cursor.com>
The navigation already shows which adjacent page is current, so the
title stays "Settings" rather than repeating it in a breadcrumb.
Subpages keep a trail through their adjacent page, for example
"Settings / Payments / Card payments".

Co-authored-by: Cursor <cursoragent@cursor.com>
@jameskoster
jameskoster force-pushed the add/settings-page-patterns branch from 9a04af5 to 92bd059 Compare November 10, 2026 14:09

@ciampo ciampo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks like a good direction and builds on the existing Page, DataForm, and DataViews patterns. Alongside the inline fixes, could we:

  • Align the Destructive Actions and Dialog guidance with these examples, including when a confirmation can open over an editor.
  • Note that several UI components used here are still marked "Use with caution", so these templates aren't an unconditional migration recommendation yet.
  • Add one failed-save example that preserves the draft, shows an error, and allows retry.

I'm also thinking about a few potential follow-ups:

  • an autosave example
  • migrating DataForm's remaining Components controls centrally
  • applying the agreed save/discard behavior to existing screens.

We should choose the save model and editor type for each workflow, while keeping validation, pending saves, and protection against lost edits consistent.

Following a breadcrumb or subpage row moves focus to the new page's heading, so screen readers announce it. The section navigation keeps focus on the newly current item. Document the guidance.

Co-authored-by: Cursor <cursoragent@cursor.com>
@jasmussen jasmussen mentioned this pull request Nov 11, 2026
Match @wordpress/boot, which moves focus to the new page's Page region when a navigation removes the focused element. Name subpage regions after the current page, since their breadcrumbs replace the title, and update the guidance.

Co-authored-by: Cursor <cursoragent@cursor.com>
jameskoster and others added 2 commits November 12, 2026 10:16
Explain when to use cards and how to plan headings: card titles are h2s on a page without sections, and h3s under an h2 section heading on the canvas. Add a Settings page with sections example.

Co-authored-by: Cursor <cursoragent@cursor.com>
Keep Save enabled when fields are invalid and let form submission show
the errors, keep editors open when the draft changes during a save,
warn before unloading with an open dirty editor, add a failed save
example, and move the unsaved changes guidance to the Save and submit
pattern (#86725).

Co-authored-by: Cursor <cursoragent@cursor.com>
@jameskoster

jameskoster commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

@ciampo Thanks for the thorough review! I've pushed changes that address most of it:

  • Validation: Save no longer disables when fields are invalid. Fields sit in a <form>, and Save submits it, so native validation shows the errors and focuses the first invalid field. This applies to the subpage, dialog and drawer, and follows the rule being settled in Save & Submit pattern: Use @wordpress/ui components and refine guidance #86725.
  • Unsaved changes guidance: moved out of this PR and into Save & Submit pattern: Use @wordpress/ui components and refine guidance #86725, so it lives in one place. The discard prompt there will use "Discard unsaved changes?" with "Keep editing" and "Discard changes".
  • Copy: "Save changes", with a "No unsaved changes" tooltip when there's nothing to save. The docs now describe manual save as the usual choice and use "switches".
  • Pending saves: if the draft changes while a save is in flight, the dialog or drawer stays open with the newer edits still unsaved.
  • beforeunload: registered while a dialog or drawer holds unsaved edits.
  • Failed save: new "Failed save" story. An error notice at the top of the form keeps the user's changes and offers "Try again".
  • Use with caution: the intro now notes that several of the @wordpress/ui components used (Button, Dialog, Drawer, AlertDialog…) are still marked "Use with caution".

Aligning destructive-actions.mdx, which still recommends ConfirmDialog and Modal, with AlertDialog (including confirmations over an editor) feels like a separate follow-up PR. The autosave example is covered in #86725, and migrating the DataForm controls or the existing screens is out of scope here.

jameskoster added a commit that referenced this pull request Nov 12, 2026
Move the unsaved changes guidance from the Settings Page pattern
(#86451), use "Discard unsaved changes?" wording in the confirmation,
and guard the example with beforeunload.

Co-authored-by: Cursor <cursoragent@cursor.com>
Hold navigation until a pending save settles, clear the failed save
notice once there's nothing to retry, name each adjacent page's region,
drop the disabled Save tooltip, and describe focus restoration as
something the example provides until #86701 lands.

Co-authored-by: Cursor <cursoragent@cursor.com>
After a key is revoked, focus the next record, the previous one when it
was last, or Add API key when the list is empty. Canceling the
confirmation still returns focus to Revoke.

Co-authored-by: Cursor <cursoragent@cursor.com>

@ciampo ciampo left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

At least in terms of correctness of the examples, code is mostly looking good (one open thread left)

Not sure if anyone else wants to review the actual patterns being proposed, although I trust @jameskoster to have the right context

After revoking a key from the drawer, focus moves to a neighbouring row.
The row was found by name, so when two keys shared a name it could pick
the row being removed and focus fell to the document body. Mark each row
with its record ID and match on that instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@ciampo ciampo left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I took another look at the patterns themselves. They make sense to me as starting points. Experiments already groups settings in cards, Post List offers both a full editor and a Quick Edit modal, and Widget Settings uses a drawer. Experiments · Post List · Widget Settings

Re. breadcrumbs, I guess we should pick an approach and potentially re-evaluate as we get more feedback

The duplicate-name revoke case works for me now too. I'd coordinate the save wording with #86725 so the two guides agree on when to use manual save.

// on top of the record that was just saved.
const latest = draftRef.current;
if ( JSON.stringify( latest ) === JSON.stringify( submitted ) ) {
setIsOpen( false );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

With Access filtered to "Read only", I opened Analytics dashboard, changed Access to "Read and write", and saved. The row disappeared and keyboard focus landed on the document body in both the dialog and the drawer. Could we focus a remaining row, or the "Add API key" button when the filtered table is empty?

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.

Fixed in 1cfa687. Before saving, the editor captures where focus should go if the row leaves the table: the next row, the previous one when it was last, or "Add API key" when the filtered table is empty. If the save leaves the row in place, focus returns to whatever opened the editor as before. The lookup is shared with revoke, and both the dialog and the drawer use it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Non-blocking follow-up. I filtered to one key, renamed it so it left the results, and edited Notes while Save was busy. Saving the notes then sent focus to the document body in both the dialog and drawer. Could we keep the first save's focus target until the editor closes?

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.

Fixed in f79ee1a. A later save only replaces the focus target when it finds the row in the table, so the first save's target survives until the editor closes. There was a second cause too: Base UI also calls the finalFocus function on re-renders while the overlay is open, and ours cleared the target the first time it was called. It now only reads the target, and opening the editor clears it. Your steps now end on the next row, or on "Add API key" when no rows remain, in both the dialog and the drawer.

- Make the record name searchable.
- Keep focus in the table when a save moves a record out of the
  filtered view, in both the dialog and the drawer.
- Warn before reloading while a record save is in progress.
- Use an unstyled Link for subpage rows, as admin UI does for its
  navigation links.
- Align the saving guidance with Save & Submit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jameskoster

Copy link
Copy Markdown
Contributor Author

Thanks for the review. The inline points are addressed in 1cfa687. On the save wording: the Saving section now gives the same reason as #86725 for choosing manual save (settings fields often depend on each other and should apply together), uses the same autosave example (the block editor's Preferences modal), and links to its "Choose one save model per surface" section rather than restating it. The two guides already agreed on the rest, including the discard dialog copy. Re. breadcrumbs, agreed: let's keep the current approach and revisit as feedback comes in.

@ciampo ciampo left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A few smaller pieces of feedback

const key = keys.find( ( { id } ) => path === `/keys/${ id }` );

if ( ! key ) {
return <KeysPage keys={ keys } />;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Non-blocking. I searched for "Mobile app", opened it, and followed the "API keys" breadcrumb. The search cleared and all four rows came back. Could we keep the table view when returning so people can work through their filtered results?

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.

Fixed in f79ee1a. KeysTable can now take its view and onChangeView from outside, and the subpage example holds the view above its routes, so following the "API keys" breadcrumb brings back the search, filters and page as you left them. The guide now says to keep the view somewhere that outlives the table, and notes that real screens usually keep it in the URL or user preferences.


const save = async () => {
setIsSaving( true );
setHasFailed( false );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Non-blocking. Pressing Enter on "Try again" removes the focused button and leaves focus on the document body, even after the retry succeeds. Could a valid retry move focus to "Save changes" before the notice disappears?

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.

Fixed in f79ee1a. When a retry passes validation, focus moves to "Save changes" before the notice goes; the button stays focusable while busy or disabled. A retry with an invalid field still sends focus to that field. The "When a save fails" guidance now says the same.

- Move focus to Save changes when a valid retry removes the failed
  save notice and its Try again button.
- Keep the records table's search, filters and page when returning
  from a record's subpage.
- Keep the first save's focus target when a later save follows edits
  made while saving, and only read it in finalFocus, which Base UI
  also calls on re-renders while the overlay is open.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jameskoster

Copy link
Copy Markdown
Contributor Author

Thanks for the continued reviews @ciampo ❤️

@jameskoster

Copy link
Copy Markdown
Contributor Author

In the future I guess it would make sense to add these stories one at a time 😅

@jameskoster

Copy link
Copy Markdown
Contributor Author

Anything left here @ciampo?

@ciampo ciampo left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I rechecked the two-save case in both editors, retry focus, and returning to a filtered table. All 3 work for me now!

One small docs update: #86701 has merged, so could we update the focus paragraph and router comment to say Boot now handles this on trunk?

Otherwise LGTM 🚀

@aduth

aduth commented Nov 20, 2026

Copy link
Copy Markdown
Member

Another optional micro-nit: The design-system-patterns.md review routing description currently hard-codes all the existing patterns and adding this there would give us some more visibility to pull requests implementing the pattern. Optional because #86921 will be removing the need for hard-coding, but it's not merged yet.

@jameskoster

Copy link
Copy Markdown
Contributor Author

I think I'llleave that to #86921. I understand the guidance here will be picked up automatically once both are PR's are in.

@jameskoster
jameskoster merged commit 4f0abb3 into trunk Nov 20, 2026
77 checks passed
@jameskoster
jameskoster deleted the add/settings-page-patterns branch November 20, 2026 16:07
@github-actions github-actions Bot added this to the Gutenberg 24.6 milestone Nov 20, 2026
@ciampo

ciampo commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

could we update the focus paragraph and router comment to say Boot now handles this on trunk?

@jameskoster just to make sure, is this change being implemented anywhere? I'm struggling to keep track of al the parallel Storybook-related PRs 😅

Vedant-Gandhi pushed a commit to Vedant-Gandhi/gutenberg that referenced this pull request Nov 30, 2026
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: aduth <aduth@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Storybook Storybook and its stories for components [Type] Developer Documentation Documentation for developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants