Skip to main content

Components

Tokens

The tokens below are custom properties set on :root in tokens.css. Tokens for individual components are listed in each component's section.

Color tokens

Colors vary between the light and dark themes. You can switch themes using the buttons at the top of the page.

Shared tokens

Token Value Dark Use
Colors
--wp-bg #f5f5f5 #131518 Page background
--wp-card-bg #ffffff #1d2025 Background of cards, fields, and dialogs
--wp-sunken-bg #ececec #0d0f11 Background of code blocks, thumbnails, and photo tiles. A step darker than the page.
--wp-hover-bg #ececec #272b31 Background of hovered buttons, rows, and choice tiles, and of default badges. A step darker than cards, or a step lighter in dark mode.
--wp-text #1a1a1a #eaecf0 Body text
--wp-text-subtle #595959 #a7adb5 Hints, secondary details such as dates, and table headings
--wp-border #e0e0e0 #383d45 Lines around cards and rows
--wp-border-strong #8a8a8a #6b727c Borders of buttons, fields, and other controls
--wp-link #3366cc #7ba6f7 Links, the focus ring, and the current step
--wp-link-hover #2a4b8d #a6c3fa Hovered links and the text of info badges
--wp-link-soft #eaf0fb #1d2a45 Background of selected items, info notices, and info badges
--wp-on-link #ffffff #131518 Text on a link-color background, such as the current step's number
--wp-brand #c8102e Filled brand buttons
--wp-brand-hover #a50d26 #d81b3a Brand button hover
--wp-on-brand #ffffff Text on brand buttons
--wp-logo-bg #ffffff Circle behind the header logo
--wp-logo-color #000000 Color of the W in the SVG logo when the logo is added with <use>, as the .wp-brand row shows. For a logo with no circle, set this to currentColor (the header's text color) and set --wp-logo-bg to transparent.
--wp-black var(--wp-text) Black buttons. They turn light in dark mode.
--wp-black-hover #000000 #ffffff Black button hover
--wp-on-black #ffffff #131518 Text on black buttons
--wp-danger #b3271e #f28b80 Errors and delete buttons
--wp-danger-soft #fae9e6 #3b1e1b Background of error notices, badges, and toasts
--wp-success #28724a #62d1b2 Success text and finished steps
--wp-success-soft #e2f2e7 #11332b Background of success notices, badges, and toasts
--wp-warning #a04a08 #f0b45a Warning text
--wp-warning-soft #faf2d9 #372b10 Background of warning notices, badges, and toasts
--wp-bar-bg #1d1d1d Header and footer background
--wp-bar-text #ffffff Text in the header and footer
--wp-bar-current #ef4058 Line that marks the current page's link in the header
--wp-bar-text-subtle color-mix(in srgb, var(--wp-bar-text) 72%, transparent) Dimmer text in the header and footer. It's computed once on :root, so if you set --wp-bar-text on .wp-header or .wp-footer, set this there too.
--wp-bar-hover color-mix(in srgb, var(--wp-bar-text) 12%, transparent) Hover background and divider lines in the header and footer. It's computed once on :root, so if you set --wp-bar-text on .wp-header or .wp-footer, set this there too.
--wp-on-media #ffffff Text and icons in captions, and round buttons over photos
--wp-overlay rgb(0 0 0 / 0.6) Background of captions and round buttons over photos, and the layer over the page behind an open dialog
--wp-media-bg #000000 Lightbox background
--wp-photo-pressed #ffc83d Background of a pressed button in a photo tile or lightbox
Type
--wp-font -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif Most text
--wp-font-mono ui-monospace, SFMono-Regular, Menlo, Consolas, monospace Monospaced text, used in code blocks
--wp-font-size-sm 0.8125rem (13px) Small print (for hints, badges, captions, table headings, the footer, etc.)
--wp-font-size-base 0.9375rem (15px) Body text, buttons, tables, and menus
--wp-font-size-lg 1.0625rem (17px) h3, intro paragraphs (.wp-lead), and the site name
--wp-font-size-xl 1.25rem (20px) h2 and the numbers in stats
--wp-font-size-2xl 1.75rem (28px) h1
--wp-font-size-3xl 2.25rem (36px) Large page titles
--wp-font-size-4xl 3rem (48px) Largest titles (.wp-title-xl) and error code, such as 404
Spacing
--wp-space-3xs 0.125rem (2px) Badge and tag padding
--wp-space-2xs 0.25rem (4px) Between a label and its field, and between tabs
--wp-space-xs 0.5rem (8px) Between buttons in a row and between choice tiles
--wp-space-sm 0.75rem (12px) Notice and table cell padding
--wp-space-md 1rem (16px) Button padding and between fields
--wp-space-lg 1.25rem (20px) Card padding
--wp-space-xl 1.5rem (24px) Under a page title row and around the pager
--wp-space-2xl 2rem (32px) Page and footer padding
--wp-space-3xl 2.5rem (40px) Around an empty state
--wp-space-4xl 3.5rem (56px) Padding above and below a full-width section
Sizes
--wp-control-height 2.25rem (36px) Buttons and fields, 44px on touch screens
--wp-control-height-sm 1.875rem (30px) Small buttons, 36px on touch screens
--wp-line-length 40em Longest line in .wp-prose, intro paragraphs, and the text under a page title
--wp-bar-height 3.75rem (60px) Header bar
--wp-page-width 1200px Maximum width of the page content
--wp-sidebar-width 15rem (240px) Width of the header in the sidebar layout, body.wp-sidebar
--wp-gutter var(--wp-space-lg) Space at the page's sides, var(--wp-space-md) at 760px wide or less
--wp-tap-size 2.75rem (44px) Smallest touch target
--wp-avatar-size 2.5rem (40px) Avatars
--wp-thumb-size 4rem (64px) Thumbnails
--wp-logo-size 40px Header logo
--wp-logo-padding 3px Padding between the logo and the edge of its circle
--wp-logo-radius 50% Corner radius of the logo's background. For a square logo, set it to 0.
Radius, shadow, focus, and duration
--wp-radius 6px Buttons, fields, and cards
--wp-radius-lg 10px Dialogs
--wp-radius-full 999px Badges, tags, avatars, and other fully rounded shapes
--wp-shadow 0 4px 16px rgb(0 0 0 / 0.12) 0 4px 16px rgb(0 0 0 / 0.5) Toasts, the combobox list, and loading messages
--wp-focus-color var(--wp-link) Focus ring, and the ring drawn just inside a focused tab or scrolling table
--wp-focus-ring 0 0 0 2px var(--wp-card-bg), 0 0 0 4px var(--wp-focus-color) Keyboard focus ring
--wp-duration 0.15s Length of hover effects and short animations (e.g. toast sliding in)

Theming

Choosing a theme

By default, the theme follows the operating system or browser's light/dark setting.

To force a theme, set data-theme="light" or "dark" on <html>.

Overriding tokens

To change a token, set it on :root in your site's stylesheet.

The --wp-on-* tokens are text colors for a matching background, so change both together. For example, a light --wp-brand needs a dark --wp-on-brand.

The following example changes the theme to green and makes buttons, fields, and cards more rounded.

:root {
  --wp-brand: #1b6e3a;
  --wp-brand-hover: #145229;
  --wp-link: #1b6e3a;
  --wp-link-hover: #145229;
  --wp-bar-current: #4caf6e;
  --wp-border-strong: #6b8a74;
  --wp-radius: 12px;
}
@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --wp-brand-hover: #23874a;
    --wp-link: #6fcf97;
    --wp-link-hover: #9de0b8;
    --wp-border-strong: #7a9a83;
  }
}
@media screen {
  :root[data-theme="dark"] {
    --wp-brand-hover: #23874a;
    --wp-link: #6fcf97;
    --wp-link-hover: #9de0b8;
    --wp-border-strong: #7a9a83;
  }
}

This is an example using the above customizations.

Breakpoints

  • At 960px or less:
    • Sidebar becomes a header bar at the top of the page.
    • In a footer with columns, the first column spans the page width, and link lists appear three per row.
  • At 760px or less:
    • Header links move behind a menu button.
    • Page margins shrink.
    • Buttons in .wp-actions-stacked stack vertically.
    • Description list values move below their terms.
    • Filters use two columns.
    • Media-row actions move to their own line.
    • Step lists show only the current step's name.
  • At 480px or less:
    • Toasts take up the page width.
    • Footer link lists switch to two per row.
    • The pager's status line moves to its own row.
  • On touch screens, (pointer: coarse):
    • Buttons and fields become 44px tall, and small buttons 36px.
    • Small controls get 44px touch areas (e.g. checkbox rows, header links, and tag-remove buttons).
    • Field text is at least 16px.
  • On screens without hover ((hover: none)), photo captions stay visible.

Page

Layouts for the main column, full-width sections, and title rows.

Main column

.wp-page Centers <main> and limits its width to --wp-page-width. To make one page full width, set that token to none on its main. When set on :root, the token also sets the width of the header, footer, and full-width sections.
.wp-page-narrow A narrower main column (max 48rem wide), such as for a form. Used with .wp-page.

Full-width sections

.wp-container .wp-section .wp-section-alt

A section that spans the window's width, written as <section class="wp-section"><div class="wp-container">. Put it in a main without .wp-page.

  • .wp-section adds padding above and below.
  • .wp-container keeps the content as wide as .wp-page.
  • For a card background with borders above and below, add -alt.

Title rows

All events
.wp-back

Events

Upcoming events with a photographer.

.wp-page-head .wp-page-head-actions

Photographers

12See all
.wp-section-head .wp-count
.wp-back A link back to the parent page or the page the user came from. Sits above the page title.
.wp-page-head .wp-page-head-actions Page title and its intro line, with the page's buttons beside them in .wp-page-head-actions. Use an h1 for the title, and wrap it and the intro line in one div.
.wp-section-head .wp-count Heading for a section within a page, with an optional count after it. A link or button at the end of the row sits on the far side.

Cards

A panel with a thin border, on its own or in a grid.

Uploads are open until 30 November.

.wp-card

Comic-Con

San Diego · 24–27 July

a.wp-card
  • National Book Awards

    New York · 19 November

    Photos

  • Toronto International Film Festival

    Toronto · 4–14 September

    Photos

  • Comic-Con

    San Diego · 24–27 July

    Photos

.wp-grid .wp-card-foot
a.wp-card Linked card with a link-color border on hover
.wp-grid .wp-card-foot A grid of cards with as many columns as fit. To adjust it, set these on the grid:
  • --wp-grid-min: smallest column width, 18rem by default. A narrower container gets one column.
  • --wp-grid-columns: most columns to show, 12 by default
  • --wp-grid-gap: space between cards, which the column widths take into account

.wp-card-foot stays at the bottom of each card. For a link card in a list, put the card inside a plain <li>.

Empty states

A message shown when a list or page has no content.

404

Page not found

The page may have moved.

.wp-message-page .wp-error-code
No events yetYou may add an event.
.wp-empty
.wp-message-page .wp-error-code A message in place of a whole page, such as errors or a logged-out notice.
.wp-empty Dashed box in place of an empty list. To give it a title, start it with a <strong>.

Text and helpers

Styles for titles, long text, user-written content, and small helper classes.

Titles and long text

A landing page title

.wp-title-xl

An intro paragraph under a page title, in larger gray text.

.wp-lead
.wp-title-xl Largest title style, such as for a landing page's main heading. It scales from 28px to 48px as the screen widens.
.wp-prose

For long-form text, with lines ~75 characters wide. It styles the headings, lists, quotes, rules, figures, notices, and code blocks inside it.

To show labels and values in two columns, use .wp-dl.

User-written text

Keeps line breaks users type, like this one.

.wp-user-text

Dorothea Lange was an American photographer, known for her work for the Farm Security Administration during the Great Depression. Her 1936 photograph of a migrant mother in Nipomo is considered a defining image of the period, and is among the most reproduced pictures of the century.

.wp-clamp data-wp-clamp
.wp-user-text User-written text, such as a profile bio, with its spaces and line breaks kept. Start and end the text on the same lines as the tags.
.wp-clamp data-wp-clamp Truncates text after three lines. Setting --wp-clamp-lines on the element changes the limit. To add a Read more button, add data-wp-clamp and load the script. The script measures the text on load and when it opens a tab, dialog, or data-wp-toggle target. For text added or shown any other way, call wpClamp(root).

Helpers

Gray text for notes
.wp-subtle
A line too long for its column ends in an ellipsis
.wp-truncate
View the original
.wp-new-tab
.wp-truncate Cuts off a line of text with an ellipsis. To set where it cuts off, limit the width of the element or of its parent.
.wp-new-tab An icon marking a link with target="_blank" as opening in a new tab. Screen readers read it as "opens in a new tab".
.wp-visually-hidden .wp-visually-hidden-focusable Hides text from view and keeps it for screen readers. To hide an element until it or a descendant has focus, use .wp-visually-hidden-focusable.

Details

A bordered box built with details.wp-details. It opens and closes without the script. Put the content after the summary in a .wp-details-body.

Example 1

Content goes here!

Example 2

To start open, add the open attribute.

For a simpler show/hide control with a small arrow, put a .wp-chevron in the summary of an unstyled details, or use a button with data-wp-toggle. To hide the browser's own triangle, set list-style: none on the summary. Safari also needs summary::-webkit-details-marker { display: none }.

Example 3
{ "title": "National Book Awards" }

Code

Inline code has a gray background. For a block of preformatted text, such as commands, code, or output, use .wp-code.

To add a copy button in the block's corner:

  1. In .wp-code-wrap, put the block and a .wp-button with a short label, such as Copy.
  2. Give the button data-wp-copy="id", where id is the ID of the element to copy.
  3. Load the script, and put a .wp-toasts holder on the page for the "Copied" toast.
git clone https://example.com/photo-library.git
cd photo-library
npm install && npm run build -- --out-dir dist/public --source-map --minify

Buttons

Use one filled button per screen, and pick either brand or black for the whole site. Style and size classes go with .wp-button, as in class="wp-button wp-button-brand".

Variants

.wp-button-brand
.wp-button-black
.wp-button
.wp-button-danger
.wp-button-quiet
A link that looks like a button
a.wp-button
.wp-link-button
.wp-link-button-danger
.wp-button-brand Colored by --wp-brand.
.wp-button-quiet Button for row actions and toolbars, with a background only on hover.

Sizes

.wp-button-sm
.wp-button
Create an account
.wp-button-lg
.wp-button-full
.wp-button-lg A larger button for a call to action.

States and behaviors

disabled
.wp-spinner
wpBusy(button, task)
data-wp-confirm
data-wp-toggle="id"
aria-pressed="true"
disabled To make a button or a.wp-button look disabled but keep it focusable, set aria-disabled="true". Your click handler must ignore its clicks.
.wp-spinner wpBusy(button, task) To show a spinner in place of the label, either:
  • Add a .wp-spinner inside the button and set aria-busy="true".
  • Call wpBusy with a function that returns a promise. Until it settles, the button shows the spinner and ignores repeat calls. If it fails, a toast shows the error.
data-wp-confirm On a button or link, asks the attribute's question in a dialog and lets the click go ahead only if the user confirms. Optional attributes:
  • data-wp-confirm-body: supporting text
  • data-wp-confirm-label and data-wp-confirm-cancel: labels for the confirm and cancel buttons
  • data-wp-confirm-danger: styles the confirm button as wp-button-danger
  • data-wp-confirm-class: the confirm button's class, wp-button-brand by default

On a submit button in an invalid form, the browser shows the form's errors instead of the dialog. Ctrl-, Cmd-, Shift-, and middle-clicks on a link skip the dialog, so use a button for destructive actions. To ask from code, call wpConfirm(), listed under Script.

data-wp-toggle="id" .wp-chevron Shows or hides the element with that ID. To start closed, give the button aria-expanded="false" and the target hidden. A chevron directly inside the button rotates when open.
aria-pressed="true" Toggle button in its pressed state, such as the chosen view. Your click handler must update this attribute.

Button rows

.wp-actions .wp-push-start
.wp-actions .wp-push-start A row of buttons. To keep one button at the start and push the rest to the end, add .wp-push-start to that button.
.wp-actions-stacked .wp-actions-sticky For full-width buttons on narrow screens, add -stacked. To keep the row at the bottom of the window while a long form scrolls, add -sticky. With both, the buttons share one row.

Form fields

Text inputs, selects, textareas, and file pickers need no class. Wrap each label and control in .wp-field.

Enter a full email address.
Up to 500 characters.
Newsletter
Reminders
Available on
Date format
Markup

Layout

.wp-field Stacks a label above its control and makes the control full width. To group checkboxes or radios, use a fieldset.wp-field with a legend.
.wp-field-row Fields side by side, sharing the width evenly. They wrap when the row can't give each field 10rem. To change that minimum, set --wp-field-min on the row.
.wp-field-row-fit The first field stretches to fill the row, and a short field or a button beside it keeps its own width. To keep the button aligned with the input, put any hint or error after the row.
Touch screens Buttons, fields, checkbox and radio rows, and the dialog close button grow to 44px tall, and small buttons to 36px. Field text is at least 16px, which keeps iOS Safari from zooming in on focus.

Labels and messages

.wp-label Bold style for a label outside a .wp-field. Labels and legends inside one are already bold.
.wp-optional Marks a field you may leave empty
.wp-hint Help text under a field. To tie it to the field, use aria-describedby.
.wp-field-error Error message under a field. Set aria-invalid="true" on the control, and tie the two together with aria-describedby.

Checks and choices

.wp-check A checkbox or radio with its label beside it. For a hint under the label, put the label text and the .wp-hint together in one <span>.
.wp-checks Lays out many .wp-check items in columns. Put it inside a fieldset.wp-field.
.wp-choices .wp-choice A few large options as bordered tiles. Each .wp-choice is a <label> wrapped around a radio or checkbox.

Combobox

A text input with a list of suggestions. To set one up:

  1. Wrap the input in .wp-combo. The list is as wide as the .wp-combo, so place it in a .wp-field, or give it a width and give the input width: 100%.
  2. Give the input a <label>. Screen readers use it to name the suggestions list.
  3. Call wpCombobox(input, options) after the input and ui.js have loaded.

sources

Required. An array of functions that each take the typed text and an AbortSignal and return a promise of an array of items. They're called 150ms after typing stops, and each source's items show as soon as they arrive.

The signal aborts when a newer search starts or the list closes. If a source fails, the list shows "Couldn't search."

Item fields
  • label: the item's text
  • meta: short text beside the label
  • description: a line under the label
  • group: a heading above neighboring items with the same group
  • action: true for a command row, such as "Create an item for ..."
onPick(item) Required. Called with the chosen item, the same object the source returned. The input still shows the typed text, so to show the choice, set input.value.
onEnter(text) Called with the trimmed text when the user presses Enter in a field that has text and no highlighted row. If the field is empty or you leave out onEnter, Enter submits the form.
emptyText(text) Returns the message to show in place of "No matches". Command rows don't count as matches.
showOnFocus If true, the list opens when the empty field gets focus, and each source is called with empty text.
preselectFirst If true, the first result is highlighted so that Enter picks it. Left, Right, Home, or End clears the highlight.
Keys
  • Up and Down open the list and move through it.
  • Enter picks the highlighted row.
  • Escape closes the list and leaves a dialog around the combobox open.
Screen readers The highlighted row, the number of results, and any message are announced.
close() destroy()

Methods on the object that wpCombobox() returns:

  • close() closes the list.
  • destroy() removes the list, and the event listeners and attributes that the script added to the input.

Calling wpCombobox() again on the same input keeps the first options, so to change them, call destroy() first.

Badges and dots

Small labels and dots that show a status.

Draft
.wp-badge
New
.wp-badge-info
Confirmed
.wp-badge-success
Pending
.wp-badge-warning
Canceled
.wp-badge-error

Published

.wp-dot

Uploading

.wp-dot-pending

Failed

.wp-dot-error

Draft

.wp-dot-off
.wp-dot A dot before a status word

Notices

A message in a colored box. To have screen readers announce a notice that appears after an action, add it inside an element with role="status" that is already on the page. An error notice gets role="alert" on the notice itself.

The event list updates every hour.

.wp-notice

Saved your profile.

.wp-notice-success .wp-notice-close
Email not confirmed

Confirm it to receive updates.

.wp-notice-warning .wp-notice-title .wp-notice-actions

Couldn't reach the server. Try again in a minute.

.wp-notice-error
.wp-notice A notice for information, in blue
.wp-notice-success .wp-notice-close A notice for success, in green. To let the user close the notice, end it with a .wp-notice-close button, and give the button an aria-label. The script removes the notice when the button is pressed.

Progress

A bar that shows how much of a task is done. Give the <progress> a value. For a task of unknown length, show a .wp-spinner instead.

7 of 12
<progress>

Loading

Content that loads after the page needs a placeholder that takes up its space. To dim content while it reloads, wrap it in a .wp-busy-region and set aria-busy="true" on the region. Wait ~150ms before showing a placeholder or dimming the content, so fast responses don't cause a flash. If loading fails, replace the placeholder with an error notice and a Retry button.

Loading can start after the page loads, such as when a filter changes. To have screen readers announce it, also write a loading message into an element with role="status" that is already on the page and outside the busy region. That element can be .wp-visually-hidden. Inside an element with aria-busy="true", screen readers may hold back changes until it is no longer busy.

Loading events...
.wp-loading

A list, dimmed while the next page loads.

.wp-busy-region[aria-busy="true"]

The photos.

Loading photos...
.wp-loading-overlay
A load error
.wp-loading -list -page A placeholder with a spinner and a message. For one at least 24rem tall, add -list. For one that fills most of the window, add -page.
.wp-loading-overlay Holder for a .wp-loading message. Put it directly inside a .wp-busy-region. It appears only while the region is busy, and the message stays in view while the page scrolls.

Avatars

A person's photo, or their initials when there is none.

.wp-avatar-sm
.wp-avatar
Girl with a Pearl Earring
.wp-avatar-lg
Gordon Parks
data-wp-initials
.wp-avatar A person's photo or initials in a circle. To change the size, set --wp-avatar-size.
data-wp-initials To show initials when the image fails to load, set data-wp-initials on the image to the initials and load the script.

Thumbnails

A small square picture, or short text such as "No image" in its place.

.wp-thumb-sm
No image
.wp-thumb
.wp-thumb-lg
.wp-thumb -contain A small square that crops its picture to fill it. To fit the whole picture in the square, add -contain. To change the size, set --wp-thumb-size.

Photos / Lightboxes

A grid of square photo tiles. Captions appear on hover and focus, and stay visible on touch screens. Each tile links to the photo's page or full-size file. To open the photo in a lightbox instead, set data-wp-lightbox on the link to a group name and load the script.

Markup
.wp-photos .wp-photo Photo grid, and a tile. The picture is cropped toward the top. The grid always has at least two columns. To change the minimum tile width (10rem by default), set --wp-photo-min on the list.
.wp-photo-caption -always Caption over the bottom of the picture. To keep a status such as "Missing since 1911" visible at all times, add -always.
.wp-photo-toggle A round button in the top corner of a tile. See Photo toggles below.
.wp-dialog.wp-dialog-lightbox .wp-lightbox-stage .wp-lightbox-button .wp-lightbox-close .wp-lightbox-prev .wp-lightbox-next .wp-lightbox-toggle

The lightbox shows the image from the link's href, with the tile's caption under it, and gives the image the tile's alt text. If the link goes to a page about the photo, put the image URL in data-wp-large. The caption then ends with a "View on example.com" link to that page, which opens in a new tab. To use a different caption, set data-wp-caption.

The Previous and Next buttons and the Left and Right arrow keys move through the links in the same group. When the lightbox closes, focus returns to the link for the last photo shown.

To show more than a caption, build your own dialog with these classes and put its text in a .wp-dialog-body. Put the image and the round buttons in .wp-lightbox-stage, which dims the image under a spinner while the stage has aria-busy="true". Give the close, previous, and next buttons .wp-lightbox-button as well.

Photo toggles

A round button with a symbol, such as ★ or ✓, in the corner of a photo tile.

Put it after the photo link in the same li, since links can't contain buttons, and give it an aria-label that names the photo. Set aria-pressed="true" to mark the photo. Your click handler must update this attribute and save the choice.

To change the pressed button's color, set --wp-photo-pressed on the button or on :root. Pick a light color, since the symbol on the pressed button is black.

When a tile with a toggle opens in the lightbox, the lightbox shows a matching button. Pressing it clicks the tile's button, so the tile's click handler runs and both stay in step.

Markup

Tags

Short labels in a row, such as a photo's subjects.

.wp-tags .wp-tag
button.wp-tag aria-pressed
  • New York
  • Toronto
.wp-tag-remove
.wp-tags .wp-tag A row of tags, and a tag. Put .wp-tag on the li, or on a link or button inside it.
button.wp-tag aria-pressed Toggle filters. Your click handler must update aria-pressed and apply the filter.
.wp-tag-remove Round × button for removing a tag. Give it an aria-label that names the tag, and handle removal in your own code.

Description lists

Labels and values in two columns.

Event
National Book Awards
Dates
19 November
Photographers
3 confirmed
.wp-dl Labels in the first column and values in the second. On narrow screens, each label sits above its value. For that layout at every width, add .wp-dl-stacked. Give each dt a single dd. Each pair may be wrapped in a div.

Media rows

A picture, text, and actions in a row.

Girl with a Pearl Earring.jpg

Uploaded 2 November · 4.1 MB

.wp-media .wp-media-body .wp-media-actions A thumbnail or avatar at the start, text beside it in .wp-media-body, and buttons at the end in .wp-media-actions. On narrow screens, the buttons move to a line of their own.

Rows

A bordered list with dividers between items. Each item holds a link or a .wp-media. A link fills the whole item.

.wp-rows .wp-row-title .wp-row-meta List of rows. In each row:
  • .wp-row-title: the first line
  • .wp-row-meta: secondary details under it

In a link, put both in one span. To mark the row whose details are open beside the list, put aria-current="true" on its link and remove the attribute from the other rows.

Stats

Numbers with labels in a row of boxes. Write the row as a dl with each dt and dd pair in a div.

Photos
12,480
Photographers
96
Events
31
Downloads
8,902
.wp-stats

Tables

A table.wp-table spans the full width. To make a column sortable, put data-wp-sort on its th in the first row of the thead and load the script.

Photo Event City Photographer Photos Status
National Book Awards New York Dorothea Lange 1,204 Confirmed
— Comic-Con San Diego — 0 Pending
Toronto International Film Festival Toronto Gordon Parks 86 Draft
.wp-table-scroll

A wrapper that scrolls a wide table sideways on narrow screens. To let keyboard users scroll it, give it tabindex="0", role="region", and an aria-label.

Its side shadows use --wp-scroll-bg, which should match the color behind the table. It's already set:

  • On the page: the page background
  • Inside .wp-card, .wp-dialog, .wp-details, and .wp-section-alt: the card background

On any other background, set --wp-scroll-bg on the .wp-table-scroll to that color.

.wp-table-wide A 44rem minimum width, so the wrapper scrolls
.wp-num A cell in a column of numbers, aligned to the end, with digits of equal width
th[data-wp-sort] .wp-sort

A sortable column heading. The script wraps its text in a .wp-sort button. For a table added later, call wpSortable(table).

  • By default, cells compare as text, and numbers inside the text sort in numeric order, so "Room 9" comes before "Room 10".
  • To compare as numbers, set data-wp-sort="number".
  • To sort a cell by a value in place of its text, give the cell data-wp-value.

When the server sorts, set aria-sort on the th and put a .wp-sort link inside it for the same look.

.wp-table-empty A message for a table with no rows: one td whose colspan spans every column

Filters

A .wp-filters form: fields in a row above a list. To give a field a row of its own, add .wp-field-full to it. On narrow screens, the fields sit two to a row, and the .wp-actions buttons get a row of their own.

Clear

Pager

Page links are small buttons inside nav.wp-pager. Mark the current page with aria-current="page"; it will look pressed.

Show the first and last pages and the pages next to the current one, using .wp-pager-gap for skipped pages. If just one page is skipped, show its number instead. On the first page, omit Previous or disable it: a button with disabled, or a link with aria-disabled="true" and no href.

For a list that updates without reloading, add a .wp-pager-info status line with role="status". After each update, give the list heading tabindex="-1" and move focus to it, since the pressed button may disappear or become disabled.

Tabs

A row of tabs that switch between panels. The tabs are role="tab" buttons in a .wp-tabs element with role="tablist" and data-wp-tabs, and each button's aria-controls is its panel's ID. Leave out any tab the user can't open.

The script shows the panel for the tab with aria-selected="true", or the first tab if none is selected, and lets users move between tabs with Left, Right, Home, and End. Wide tab rows scroll sideways and use the same shadows and --wp-scroll-bg as .wp-table-scroll.

The event's photos.

data-wp-tabs="hash" Keeps the chosen panel's ID in the URL, so a link can open a tab and a reload keeps it. A link to an element inside a panel also opens that panel. Choosing the default tab removes the ID from the URL, and a tab change replaces the current history entry. Use it on one tab row per page, since the URL holds one ID.
.wp-tab-note A count or a word of status after a tab's name
wp-tab event Fires on the tab row each time a tab is selected, with detail.tab and detail.panel. The event bubbles. To catch the initial event, listen on document in a script placed before ui.js. Code that runs later can check which tab has aria-selected="true".
wpTabs(list) Sets up tabs added later and returns { select(panelId) }, which opens the tab for that panel. When no tab's aria-controls matches an element on the page, it returns null. A second call on the same tab row returns the same object.

Steps

An ol.wp-steps that shows where a user is in a multi-step process. Put each step's name in a link or a span, and link the steps the user has already visited. For steps that change without loading a new page, use a button in place of the link.

The current step takes aria-current="step" on its li or on the link inside it. To mark a finished step, add .wp-step-done to its li and put "(done)" in a .wp-visually-hidden span. Narrow screens show every number but only the current step's name.

  1. Account (done)
  2. Upload (done)
  3. Captions
  4. Publish

Dialogs

A native <dialog> element with .wp-dialog. With the script, a button with data-wp-dialog="id" opens the dialog with that ID, and a button inside the dialog with data-wp-dialog-close closes it. Without the script, call showModal() and close() yourself. If your own code opens a dialog with showModal(), call wpClamp(dialog) to add "Read more" buttons to its clamped text.

An open dialog covers the page's toasts and hides them from screen readers, so give a dialog that shows toasts its own .wp-toasts holder. The script empties that holder when the dialog closes.

Markup
.wp-dialog Dialog box, 35rem wide, or 48rem with .wp-dialog-wide. Give it an aria-labelledby with its title's ID. The page behind it can't scroll while it's open. With the script, a click on the backdrop closes it.
.wp-dialog-head .wp-dialog-body .wp-dialog-foot Title row, scrolling middle, and button row. Put them directly in the dialog or in one form or div inside it.
.wp-dialog-close Round close button in the title row. Give it data-wp-dialog-close and an aria-label.
data-wp-dialog-static On the dialog, stops a backdrop click or Escape from closing it. Use it for a long form. Browsers may still close the dialog on repeated Escape presses.
wpConfirm() .wp-dialog-confirm Small dialog the script builds for wpConfirm() and data-wp-confirm, described under Buttons and Script
.wp-dialog-lightbox Lightbox, described under Photos

Toasts

A short message at the bottom of the screen. Put one .wp-toasts holder at the end of the page. Every toast needs it, including the ones from wpBusy and data-wp-copy.

To show a toast, call wpToast('Saved.'), which needs the script. A second argument of 'error', 'warning', or 'info' makes the toast red, amber, or blue. A third argument of { link: { href, text } } ends the message with a link. A green toast with a link takes null as the second.

A toast closes after four seconds. Hovering or focusing it stops the timer, which restarts once the pointer and focus have both left. An error, or a toast with a link, stays until closed.

Markup and script
.wp-toasts Holder, fixed at the bottom of the screen. To have screen readers announce new toasts, give it role="status".
.wp-toast -error -warning -info A toast, green by default, and the classes that make it red, amber, or blue. Without the script, add toasts to the holder and remove them yourself.
.wp-toast-close Close button

Script

Load ui.js with defer. Put your setup code in another deferred script after it, or run it on DOMContentLoaded.

  • On page load, the script marks the menu link for the current page and sets up clamped text, tabs, and sortable tables. For a header, clamped text, tabs, or a sortable table added later, call the matching function below.
  • Menu buttons, dialogs, confirms, copy and toggle buttons, notices, avatar fallbacks, and lightbox links work on markup added at any time.
  • Comboboxes are set up only when you call wpCombobox().

Menu

.wp-menu-button Opens and closes the menu on narrow screens.
wpMarkCurrentPage()

Sets aria-current="page" on the menu link for this page, unless a menu link has it already, and scrolls that link into view in the sidebar layout. Runs at load. After adding a header, call it again.

  • When several links match, the longest path wins: on /events/mine, a link to /events/mine beats one to /events.
  • The home page is the path of the .wp-brand link, or / without one. A link to it, or to a path above it, matches only its own page.
  • A link with a query string matches only the same query, and links with .wp-button stay unmarked.

Dialogs and toasts

data-wp-dialog="id" data-wp-dialog-close data-wp-dialog-static
  • data-wp-dialog="id": on a button, opens the dialog with that ID
  • data-wp-dialog-close: on a button, closes the dialog it's in
  • data-wp-dialog-static: on a dialog, blocks backdrop clicks and the first Escape. Browsers may still close it on repeated Escape presses.

A click on the backdrop closes a .wp-dialog.

wpToast(message, kind, { link })

Shows a toast in the page's .wp-toasts holder, or in the open dialog's own holder when it has one.

  • kind: 'error', 'warning', or 'info'. For green, leave it out, or pass null when a link follows.
  • link: { href, text } for a link after the message
wpConfirm({ title, body, confirmLabel, cancelLabel, danger, buttonClass }) data-wp-confirm

Asks a question in a dialog with two buttons and returns a promise of true for confirm or false for cancel. Escape or a click outside answers false. A question asked while another is open waits until the first is answered.

  • title: the question
  • body: optional text under it
  • confirmLabel and cancelLabel: button labels, OK and Cancel by default
  • danger: true makes the confirm button a delete button
  • buttonClass: the confirm button's class, wp-button-brand by default

On a button or link, data-wp-confirm holds the question and lets the click through once confirmed.

data-wp-confirm-body data-wp-confirm-label data-wp-confirm-cancel Body text, the confirm button's label, and the cancel button's label
data-wp-confirm-danger data-wp-confirm-class Make the confirm button a delete button, or give it another class, such as wp-button-black

Buttons

wpBusy(button, task)

Shows a spinner on the button while task runs. task is a function that returns a promise, as in wpBusy(button, () => save()).

  • While the task runs, repeat calls for that button are ignored. Other click handlers still run.
  • If the task fails, a toast shows the error's message.
  • Returns a promise that resolves to the task's value, or to undefined after an error or when the button is already busy.
data-wp-copy="id" Copies the text of the element with that ID, or its value when it is an input or textarea, and confirms with a toast. The ID may start with #.
data-wp-toggle="id" Shows or hides that element and sets the button's aria-expanded

Content

data-wp-clamp wpClamp(root) On .wp-clamp text, adds a Read more button when the text is cut off. Tabs, data-wp-toggle, and data-wp-dialog check the text they show. For other clamped text added or shown after load, call wpClamp(root) on the text or an element that contains it.
.wp-notice-close Removes the notice it is in
img[data-wp-initials] Initials that replace an avatar image when it fails to load

Tabs and tables

data-wp-tabs wpTabs(list)

Sets up every data-wp-tabs tab row at load. For a tab row added later, call wpTabs(list). It returns:

  • { select(panelId) }, where select opens the tab for that panel
  • null when no tab's aria-controls matches an element on the page
  • The same object on a second call for the same tab row
data-wp-tabs="hash" Keeps the chosen panel's ID in the URL.
wp-tab event Fires on the tab row when a tab is selected, with the tab and the panel in detail. The event bubbles. To catch the initial event, listen on document in a script placed before ui.js.
th[data-wp-sort] wpSortable(table)

Makes a column sortable. Put the attribute on a th in the first row of the thead. For a table added later, call wpSortable(table). A second call on the same table leaves it as it is.

  • Each tbody is sorted separately.
  • To compare the first number in each cell, set data-wp-sort="number". The sort ignores thousands commas, and a cell with no number sorts as 0.
td[data-wp-value] Value a cell sorts by, in place of its text

Lightbox and combobox

a[data-wp-lightbox="group"] Opens the linked photo in a large dialog, with Previous and Next buttons for the other links in the same group.
data-wp-large data-wp-caption On a lightbox link, data-wp-large is the image to show in place of the href, and the href becomes a "View on" link after the caption. data-wp-caption is the caption, in place of the link's .wp-photo-caption text.
wpCombobox(input, options) Adds a list of suggestions under a text input in a .wp-combo as the user types. The options argument is described under Combobox. Returns { close, destroy }, the same object on each call for that input.

Publish 12 photos

Thank you for your contribution!