Skip to main content

Menu

Use a menu to display a list of actions in a popover. Actions can open a modal, trigger an event, or link to an external page.

string

A label to describe the purpose of the menu that is announced by screen readers.

string

A unique identifier for the element.

Was this section helpful?

Anchor to children button propertiesChildren button properties

The Menu component exclusively accepts Button elements with restricted props as its children. The tone prop will always be set to monochrome by default.

string

A label that describes the purpose or contents of the Button. It will be read to users using assistive technologies such as screen readers.

Use this when using only an icon or the button text is not enough context for users using assistive technologies.

((event: <typeof buttonTagName>) => void) | null

Callback when the button is activated. This will be called before the action indicated by type.

'--auto' | '--show' | '--hide' | '--toggle' | '--copy'
Default: '--auto'

Sets the action the commandFor should take when this clickable is activated.

See the documentation of particular components for the actions they support.

  • --auto: a default action for the target component.
  • --show: shows the target component.
  • --hide: hides the target component.
  • --toggle: toggles the target component.
  • --copy: copies the target ClipboardItem.
string

ID of a component that should respond to activations (e.g. clicks) on this component.

See command for how to control the behavior of the target.

boolean
Default: false

Disables the button, disallowing any interaction.

string

The URL to link to.

  • If set, it will navigate to the location specified by href after executing the onClick callback.
  • If a commandFor is set, the command will be executed instead of the navigation.
string

A unique identifier for the element.

boolean
Default: false

Replaces content with a loading indicator.

'auto' | '_self' | '_blank'
Default: 'auto'

Specifies where to display the linked URL

'auto' | 'neutral' | 'critical'
Default: 'auto'

Sets the tone of the Button, based on the intention of the information being conveyed.

'button' | 'submit'
Default: 'button'

The behavior of the button.

  • 'submit' - Used to indicate the component acts as a submit button, meaning it submits the closest form.
  • 'button' - Used to indicate the component acts as a button, meaning it has no default action.
  • 'reset' - Used to indicate the component acts as a reset button, meaning it resets the closest form (returning fields to their default values).

This property is ignored if the component supports href or commandFor/command and one of them is set.

Was this section helpful?

Basic Menu

Preact

import '@shopify/ui-extensions/preact';
import {render} from 'preact';

export default async () => {
render(<Extension />, document.body);
};

function Extension() {
return (
<>
<s-button commandFor="order-actions-menu">Manage</s-button>
<s-menu
id="order-actions-menu"
accessibilityLabel="List of order actions"
>
<s-button onClick={() => console.log('Submit problem')}>
Submit problem
</s-button>
<s-button href="https://shopify.com">Request return</s-button>
<s-button tone="critical">Cancel order</s-button>
</s-menu>
</>
);
}

Preview

An example of a Menu component shows three actions: Submit problem, Request return, and Cancel order.

Consolidate actions into one menu

  • Use the menu component in the upper-right corner of full-page extensions, to be consistent with the Order status page.
  • Use menus to consolidate page-level actions, instead of adding multiple buttons around the page.

The “Don’t do” example shows 3 separate action buttons on a subscription page. The “Do” example shows the same 3 actions consolidated into one menu.

Content guidelines

When writing button labels:

  • Aim for 2 words (verb and noun).
  • Lead with a strong verb that encourages action.
  • Avoid unnecessary words and articles such as “the,” “an,” or “a.”
  • Use sentence case.

A button that follows the content guidelines says “Skip order”. A button that does not meet the content guidelines says “Skip this order”.

Was this section helpful?