@dynamic-labs-sdk/react-ui is a library of prebuilt React components that run on top of the JavaScript SDK and its React hooks. It gives you complete screens for connecting an external wallet and for paying a Flow payment, so you can add those experiences without building every screen yourself. The rest of the SDK stays headless, and you can still build any screen from the Building UI guides instead.
The package is for React web apps. It renders DOM elements and depends on react-dom, so it does not work in React Native.
What the package includes
The package has two entry points. Import from the one that matches what you are building.
The widgets are the main components. Each one runs a complete task, calls the SDK for you, and reports the result through a callback:
The main entry point also exports the views the connect wallet widget is built from (
WalletList, WalletChainList, ProviderList, and WalletAccountBalances, which lists a wallet account’s token balances), plus smaller components such as Badge, Button, Checkbox, CopyField, Panel, QRCode, SearchBar, Select, and TokenMark. Use them when you want the same look in screens you build yourself.
Prerequisites
- A React web app set up with
@dynamic-labs-sdk/clientand@dynamic-labs-sdk/react-hooks, as described in the React quickstart. The components read SDK state through the hooks, so they must render insideQueryClientProviderandDynamicProvider. - A chain extension for each chain whose wallets you want to show, as described in Adding extensions.
Install the package
@dynamic-labs-sdk packages. The SDK checks the versions at startup and throws a VersionMismatchError when they differ. The package supports React 18 and 19.
Import the stylesheet
Import one stylesheet once, at the root of your app. The stylesheets are plain CSS, so your bundler needs no extra configuration.Wrap your app in DynamicUiProvider
DynamicUiProvider renders a wrapper element with the dyn-root class and sets up the animation and text context the components need. A component rendered outside it has no styles. Mount it once, inside DynamicProvider:
dynamicClient is the client your app creates at startup, as in the React quickstart.
For the Flow widgets, import flow.css instead of index.css and add the dyn-flow-root class to the provider, because the Flow styles apply only inside an element that has it:
Change the text
Every widget ships with English default text. Pass atext dictionary to DynamicUiProvider to replace any of it. The dictionary is keyed by the component’s slot name, then by the text key:
{wallet} placeholder, which the widget replaces with the wallet’s display name. A slot or key that the component does not read is a TypeScript error, so a typo cannot fall back silently to the default text. Text keys lists every slot and key with its default. You can also wrap part of the tree in TextProvider to change the text in one place only. Nested dictionaries merge, and the innermost value wins.
Change the styles
The components are styled to work without changes, and you can adjust them with ordinary CSS:- Design tokens. Colors, type, spacing, and sizes are CSS custom properties named
--dyn-*, declared on.dyn-rootrather than on:root, so they never leak into the rest of your page. Override one on the provider’s class to change it everywhere, such as--dyn-color-inkfor text color or--dyn-size-widget-max-widthfor the widget width. - Your rules win. The package puts all of its rules in CSS cascade layers named
dynanddyn-flow. Any rule you write outside a layer takes precedence over them, so you never need!important. - Stable selectors. Each element carries a
data-slotattribute, such asdata-slot="dyn-connect-wallet-option-widget". Target these attributes rather than generated class names. - Your own classes. Every widget accepts a
classNamefor its root element, andDynamicUiProvideradds itsclassNameafterdyn-root.
Related
Connect wallet widget
Let users choose and connect an external wallet.
Flow payment widget
Run a complete Flow payment from a flow ID.
Text keys
Every piece of text you can replace, with its default.
React hooks
The hooks the components are built on.
Building UI guides
Build any screen yourself with the SDK.