Skip to main content

Migrate UnstyledButton from Polaris React

Use a native button for app-owned custom controls or s-clickable for a supported clickable composition. Preserve button semantics, focus visibility, and disabled behavior.


Anchor to Choose the destinationChoose the destination

Polaris ReactPolaris web componentsMigration type
UnstyledButtonNative button or s-clickableNative HTML

Anchor to Map unstyled-button behaviorMap unstyled-button behavior

Polaris ReactPolaris web componentsMigration notes
onClick and disabledNative button behavior or s-clickable activationPreserve keyboard activation and don't replace the button with a clickable div.
accessibilityLabelNative aria-label or component accessibilityLabelPrefer visible text when the control can accommodate it.
Navigation or submit behaviorA real href or native button type="submit"Preserve browser navigation and form validation semantics.

Anchor to Migrate the call siteMigrate the call site

  1. Choose the native element whose semantics match the UnstyledButton call site.

  2. Rebuild its accessible name and relationships before adding layout or app-owned styling.

  3. When the element is interactive or form-associated, connect its native events and form behavior to existing app state.

  4. After verification, remove the UnstyledButton import and any Polaris-only state, wrappers, or helpers that no longer have a caller.


Anchor to Preserve these behaviorsPreserve these behaviors

  • Native semantics, accessible names, and document structure.
  • Keyboard and form behavior supplied by the browser, where applicable.
  • App state, validation, and responsive layout around the element.

Anchor to Test and remove Polaris ReactTest and remove Polaris React

Test the migrated UnstyledButton with browser and accessibility semantics in mind. Verify document structure, keyboard and form behavior where applicable, accessible relationships, and app-owned state changes.

Don't remove @shopify/polaris while another component still imports it. Once all call sites are migrated, remove the package and its provider-level setup, then run the app's full test suite.


Migrating UnstyledButton

export function UnstyledButtonMigrationExample() {
return (
<><button type="button">Custom action</button></>
);
}
import {UnstyledButton} from '@shopify/polaris';


export function UnstyledButtonMigrationExample() {

return (
<UnstyledButton onClick={() => {}}>Custom action</UnstyledButton>
);
}

Preview


Was this page helpful?