Skip to main content

Migrate ButtonGroup from Polaris React

Use s-button-group for a small set of related local actions. Move actions that define the page to s-page's primary-action and secondary-actions slots.


Anchor to Migrate a local action groupMigrate a local action group

Migrating form actions

<s-button-group>
<s-button slot="primary-action">Save</s-button>
<s-button slot="secondary-actions">Cancel</s-button>
</s-button-group>
import {Button, ButtonGroup} from '@shopify/polaris';

<ButtonGroup>
<Button onClick={cancel}>Cancel</Button>
<Button variant="primary" onClick={save}>Save</Button>
</ButtonGroup>

Preview

Place supporting buttons in slot="secondary-actions" and the main action in slot="primary-action". The group owns ordering and responsive presentation.


Anchor to Replace group behaviorReplace group behavior

Polaris ReactPolaris web componentsMigration notes
Child Button elementsChild s-button elementsMigrate each button's behavior independently.
Primary actionslot="primary-action"Use at most one primary action in the group.
Other actionsslot="secondary-actions"Order them by task importance.
segmentedGrouped buttons only when the actions form one controlUse a choice field for persistent selection.
fullWidthContaining grid or stackDon't stretch low-priority actions solely to match old styling.
connectedTopRemovePlace the group in the destination section or page layout.
noWrapDestination responsive behaviorShorten labels or move infrequent actions to a menu.

Don't move every overflowed action into a menu automatically. Keep frequent actions visible and put contextual, lower-frequency actions in an s-menu opened by a sibling button.


  • Verify action order and hierarchy at narrow and wide widths.
  • Exercise loading and disabled states without shifting the primary action unexpectedly.
  • Confirm form submit and cancel behavior, including keyboard order.
  • Test overflow-menu focus return where used.

Anchor to Remove Polaris ReactRemove Polaris React

Remove ButtonGroup, layout wrappers used only to space it, and old overflow logic after the action hierarchy is migrated. Remove @shopify/polaris only after no other route in scope imports it.



Was this page helpful?