Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/ui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@

- `Icon`: Merge a consumer-supplied `style` prop with the icon's intrinsic styles instead of replacing them, so styles like `fill: none` on stroke-based icons survive unless the consumer overrides the same property explicitly. ([#78808](https://github.com/WordPress/gutenberg/pull/78808))

### Documentation

- Add a Form best practices Storybook page for labeling composed controls ([#82197](https://github.com/WordPress/gutenberg/pull/82197)).

## 0.21.0 (2026-08-26)

### New Features
Expand Down
8 changes: 8 additions & 0 deletions packages/ui/src/form/stories/best-practices.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Meta, Stories } from '@storybook/addon-docs/blocks';
import * as BestPracticesStories from './best-practices.story';

<Meta of={ BestPracticesStories } />

# Best practices

<Stories title="Examples" />
48 changes: 48 additions & 0 deletions packages/ui/src/form/stories/best-practices.story.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import type { Meta, StoryObj } from '@storybook/react-vite';
import { Fieldset, InputControl, InputLayout } from '..';
import { Stack } from '../../stack';

const meta: Meta = {
title: 'Design System/Components/Form/Best Practices',
tags: [ '!dev' ],
parameters: {
controls: { disable: true },
},
};
export default meta;

/**
* When several controls share one visible group label, use a fieldset
* legend for the group. Give each `InputControl` its own `label` and set
* `hideLabelFromVision` so only the group label stays visible.
*/
export const LabelingComposedComponents: StoryObj = {

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.

Nit: The fields show lb and oz, but their accessible names are Pounds and Ounces, so voice-control users cannot reliably target them using the visible text.

Should we include the unit in each label, such as label="lb, pounds", and clarify that labels should only be visually hidden when other visible text still identifies each control?

(related, related)

render: function Template() {
return (
<Fieldset.Root>
<Fieldset.Legend>Shipping weight</Fieldset.Legend>
<Stack direction="row" gap="sm">
<InputControl
label="Pounds"
hideLabelFromVision
type="number"
suffix={
<InputLayout.Slot aria-hidden>lb</InputLayout.Slot>
}
/>
<InputControl
label="Ounces"
hideLabelFromVision
type="number"
suffix={
<InputLayout.Slot aria-hidden>oz</InputLayout.Slot>
}
/>
</Stack>
<Fieldset.Description>
Enter the total weight of your shipment.
</Fieldset.Description>
</Fieldset.Root>
);
},
};
Loading