Skip to main content
This page covers the patterns for working with UX Toolkit components in your application: setting properties, listening to events, and linking behavior between components.
Note
Studio is the canonical component reference. Studio is built directly from the web components’ source code and is always up-to-date. For the full list of properties, attributes, and events for each component, browse the component in Studio. The patterns on this page apply to every component.
For a one-line summary of each available component, see the Components in UX Toolkit section on the About UX Toolkit page.

Working with component props

UX Toolkit components are native HTML web components. You configure them using HTML attributes in the markup, just like any standard HTML element.
A few conventions to know:
  • Attribute names use kebab-case in HTML (e.g., card-token, show-title).
  • In native webview integrations, you pass the same properties via postMessage() as componentProps, but converted to lower camelCase (e.g., cardToken, showTitle). See Working within Native Webviews.
  • Required vs. optional props vary by component. Refer to each component’s Properties/Attributes section in Studio.
You can also set or update properties dynamically from JavaScript:

Listening to component events

A custom UI component event is emitted whenever a noteworthy action or behavior occurs within that component. You can develop your application to listen for and respond to whatever events matter to your use cases. The pattern is the same as listening to any DOM event — addEventListener on the component element, with the event name and a callback that receives the event detail:
For the list of events emitted by each component, see the Events section of that component in Studio.

Linking behavior between UI components

You can link the behavior between two UI components by adding event listeners for specific events. Example 1: Selecting a card from a list updates the card detail view. In the example below, an event listener listens for mqCardListActionHook and, when a card is selected, sets the selected card’s token on the mq-card component:
Example 2: Opening a transaction detail in a modal from a transaction list. In the following example, an event listener listens for mqTransactionListHook. If the requested operation is to view a transaction, a <div> element is created to contain the transaction component. Your application can then display the transaction details in a modal, including the Report a problem button for disputable transactions:

React example using onEvent handlers

In a React application, you can attach event listeners using a ref and useEffect. Note that React’s synthetic event system does not bridge to web component custom events automatically — you must use the underlying DOM event listener.
Tip
If you’re using TypeScript with React, you may need to declare the UX Toolkit custom elements in a .d.ts file so JSX recognizes them.