Repository navigation
Conversation
Show how to compose `Radio` with `Card` for high-emphasis single-select options, without a dedicated component. See #76850.
🤖 PR meta 🤖📦 Bundle sizeSize Change: 0 B Total Size: 9.05 MB From 🏁 Flaky testsSome tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information. Regression: updating a specific option will only change its value and will not corrupt others in
|
Use the focus ring mixin on the card when its radio has visible focus, and hide the radio's own ring so that only one ring shows.
Replace the Radio card story with a CardRadio component. It renders a radio option as a card, where clicking anywhere on the card selects the radio, and accepts additional non-interactive content. Consumers group options with Fieldset and RadioGroup. See #76850.
mirka
force-pushed
the
ui-radio-card-pattern-story
branch
from
October 23, 2026 02:21
206a056 to
01978db
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
See #76850
Adds
CardRadioto@wordpress/ui: a radio option presented as a card, for high-emphasis single selection such as choosing a plan or a payment method. Clicking anywhere on the card selects it, and the card accepts additional non-interactive content below the label and description.Options are grouped with the existing
Fieldset.RootandRadioGroupprimitives, so there is noCardRadio.Root:Why?
#76850 proposes a high-emphasis alternative to a plain radio list. This PR started as a story composing
RadiowithCard. The composition works with public components, but every consumer would have to copy the CSS that stretches the label over the card, styles the checked, hover, and disabled states, and moves the focus ring to the card. It also needs aField.Root, which is easy to miss and throws when it is absent. A small component removes that boilerplate.How?
CardRadiofollowsCheckboxControl: it renders its ownField.Root(as aCard.Root) andField.Item, solabelnames the radio anddescriptiondescribes it. Therefand other props go to theRadio, andclassNamegoes to the card.role="radio"treats its children as plain text, so a whole-card radio would flatten headings, lists, and images in the additional content, and its name or description would include all of the card's text. Here, additional content keeps its semantics and is not part of the radio's name or description.::afteron the label covers the card, so clicking anywhere selects the radio. This also prevents interaction with the card's content, so interactive content is not supported.:has()on the radio'sdata-checked,data-disabled, and:focus-visible. The focus ring uses the package'sfocus-ringmixin on the card, and the radio's own ring is hidden.name,required, and the group's layout stay withFieldset.RootandRadioGroup. A per-cardField.Rootinside aRadioGroupbehaves the same as a shared one for names, descriptions, keyboard navigation, form values, andrequired.use-recommended-componentsESLint rule, because the design in AddRadioCardto@wordpress/ui#76850 is still being finalized.The earlier
Radiocard story is replaced by theCardRadiostories.Testing Instructions
npm run storybook:dev.Testing Instructions for Keyboard
Screenshots or screencast
With additional content, in a grid: