Hi team,
I’m facing an issue while trying to add a copy button inside an <s-text-field> using the accessory slot. Here’s the code I’m using:
<s-text-field
value={i18n.translate(`${i18nPrefix}.manualLocationSnippet`)}
disabled
>
<div style={{ display: "contents" }} slot="accessory">
<s-button
variant="tertiary"
icon="clipboard"
type="button"
onClick={onCopy}
/>
</div>
</s-text-field>
Problems I’m seeing:
- The button appears visually misaligned on hover.
- The
onClickfunction on<s-button>is not triggering. - I’m using Shopify Polaris Web Components.
Visual References:
-
Code snippet in UI:

-
Button hover misalignment:

If anyone has an alternative way to:
- Show a copy-to-clipboard button inside a
<s-text-field>(as a suffix or in theaccessoryslot), - Or a workaround to get the button functional and aligned properly,
please share your approach. Any help would be appreciated!
Thanks in advance!