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;
}
}
Breakpoints
-
At
960pxor 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
760pxor less:- Header links move behind a menu button.
- Page margins shrink.
-
Buttons in
.wp-actions-stackedstack 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
480pxor 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.
Header
A horizontal nav bar with the logo, site name, links, and other controls. At widths of 760px or less, the links collapse behind the menu button.
Markup
To mark the current page's link, set
aria-current="page" on it, or otherwise the script
will automatically mark the closest matching menu link on-load.
Top bar
.wp-header .wp-header-inner
|
Header bar, and an inner div with the same width and side
padding as
.wp-page
|
|---|---|
.wp-brand .wp-brand-logo
.wp-brand-name
|
Home link with the site's logo and name. For a logo with no
circle, replace the img with
<svg aria-hidden="true"><use
href="/halide/img/wikiportraits-logo.svg#logo"
/></svg>, and set --wp-logo-bg and
--wp-logo-color as the Tokens table describes.
|
.wp-menu .wp-menu-group
|
Links, in one or more groups. The links need no class. |
.wp-menu-link |
Form button that looks like the menu links |
.wp-button |
A link or button that keeps its button look |
.wp-truncate |
Cuts off long text in the menu, such as a user's name, with an ellipsis. See Helpers. |
.wp-menu-button |
Button that shows and hides the links on narrow screens. It
needs the script. Put it before .wp-menu in the
same .wp-header-inner.
|
.wp-skip-link |
A "Skip to main content" link, hidden until it has keyboard focus. To see it, press Tab at the top of this page. |
Sidebar layout
The header can also be shown as a sidebar on desktop widths.
body.wp-sidebar
|
Turns the header into a column down the left side (the right side in RTL languages), as tall as the window. With several link groups, the last group sits at the bottom. When the links are taller than the window, the column scrolls. At widths of 960px or less, the sidebar becomes a top bar with a menu button for the links.
The layout is a CSS grid on |
|---|---|
.wp-menu-quiet |
A smaller link in the sidebar, mainly for meta links |
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
|
|---|
Title rows
.wp-backEvents
Upcoming events with a photographer.
.wp-page-head .wp-page-head-actions
.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-cardComic-Con
San Diego · 24–27 July
a.wp-card-
National Book Awards
New York · 19 November
-
Toronto International Film Festival
Toronto · 4–14 September
-
Comic-Con
San Diego · 24–27 July
.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:
|
Empty states
A message shown when a list or page has no content.
.wp-message-page .wp-error-code
.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-xlAn 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
|
User-written text
Keeps line breaks users type, like this one.
.wp-user-textDorothea 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
.wp-subtle.wp-truncate.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:
-
In
.wp-code-wrap, put the block and a.wp-buttonwith a short label, such as Copy. -
Give the button
data-wp-copy="id", whereidis the ID of the element to copy. -
Load the script, and put a
.wp-toastsholder 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
Form fields
Text inputs, selects, textareas, and file pickers need no class.
Wrap each label and control in .wp-field.
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:
-
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 inputwidth: 100%. -
Give the input a
<label>. Screen readers use it to name the suggestions list. -
Call
wpCombobox(input, options)after the input andui.jshave loaded.
sources |
Required. An array of functions that each take the typed
text and an The signal aborts when a newer search starts or the list closes. If a source fails, the list shows "Couldn't search." |
|---|---|
| Item fields |
|
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 |
|
| Screen readers | The highlighted row, the number of results, and any message are announced. |
close() destroy() |
Methods on the object that
Calling |
Badges and dots
Small labels and dots that show a status.
.wp-badge.wp-badge-info.wp-badge-success.wp-badge-warning.wp-badge-errorPublished
.wp-dotUploading
.wp-dot-pendingFailed
.wp-dot-errorDraft
.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-noticeSaved your profile.
.wp-notice-success
.wp-notice-close
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.
<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.
.wp-loadingA list, dimmed while the next page loads.
.wp-busy-region[aria-busy="true"]
The photos.
.wp-loading-overlayCouldn't load the events.
.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
.wp-avatar-lgdata-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
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
|
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
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.
- National Book Awards
- Toronto International Film Festival
-
Dorothea Lange
.wp-rows .wp-row-title
.wp-row-meta
|
List of rows. In each row:
In a link, put both in one |
|---|
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-statsTables
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
Its side shadows use
On any other background, set |
|---|---|
.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
When the server sorts, set |
.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.
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.
Who is covering it.
Notes for the team.
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.
- Account (done)
- Upload (done)
- Captions
- 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
|
Dialogs and toasts
data-wp-dialog="id"
data-wp-dialog-close
data-wp-dialog-static
|
A click on the backdrop closes a |
|---|---|
wpToast(message, kind, { link })
|
Shows a toast in the page's
|
wpConfirm({ title, body, confirmLabel, cancelLabel, danger,
buttonClass })
data-wp-confirm
|
Asks a question in a dialog with two buttons and returns a
promise of
On a button or link, |
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
|
|---|---|
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="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
|
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.
|