Migrate Inline Code from Polaris React
Use a native code element for inline code and identifiers. Preserve surrounding sentence semantics and add a preformatted container only for code blocks.
Anchor to Choose the destinationChoose the destination
| Polaris React | Polaris web components | Migration type |
|---|---|---|
InlineCode | Native code element | Native HTML |
Anchor to Map inline codeMap inline code
| Polaris React | Polaris web components | Migration notes |
|---|---|---|
children | Native code content | Keep short identifiers, values, commands, or paths inline. |
| Surrounding text | s-paragraph or another semantic text element | Keep punctuation outside the code element unless it belongs to the literal. |
| Multiline content | A code block | Preserve whitespace and copyability for commands and examples. |
The native code element provides the semantics. Any s-box, stack, background, border radius, or padding in an example is optional visual composition, not part of the replacement API. Add those only when the surrounding design needs a distinct code treatment, and keep the code element itself around the literal value.
Anchor to Migrate the call siteMigrate the call site
-
Choose the native element whose semantics match the
InlineCodecall site. -
Rebuild its accessible name and relationships before adding layout or app-owned styling.
-
When the element is interactive or form-associated, connect its native events and form behavior to existing app state.
-
After verification, remove the
InlineCodeimport 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 InlineCode 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.
Anchor to Migration exampleMigration example
Migrating InlineCode
Polaris web components
export function InlineCodeMigrationExample() {
return (
<s-stack direction="inline">
<s-box background="strong" borderRadius="small" padding="small-100 small">
<code>product.status</code>
</s-box>
</s-stack>
);
}Polaris React
import {InlineCode} from '@shopify/polaris';
export function InlineCodeMigrationExample() {
return (
<InlineCode>product.status</InlineCode>
);
}