React SDK Components
π¨ Themingβ
How Theming Worksβ
All UI components in @onflow/react-sdk are styled using Tailwind CSS utility classes. The kit supports both light and dark themes out of the box, using Tailwind's dark: variant for dark mode styling.
You can customize the look and feel of the kit by providing a custom theme to the FlowProvider via the theme prop. This allows you to override default colors and styles to better match your app's branding.
_17import { FlowProvider } from "@onflow/react-sdk"_17_17<FlowProvider_17 config={...}_17 theme={{_17 colors: {_17 primary: {_17 background: "bg-blue-600 dark:bg-blue-400",_17 text: "text-white dark:text-blue-900",_17 hover: "hover:bg-blue-700 dark:hover:bg-blue-300",_17 },_17 // ...other color overrides_17 }_17 }}_17>_17 <App />_17</FlowProvider>
π Dark Modeβ
How Dark Mode Worksβ
Dark mode is fully controlled by the parent app using the darkMode prop on FlowProvider. The kit does not manage dark mode state internallyβthis gives you full control and ensures the kit always matches your app's theme.
darkMode={false}(default): Forces all kit components to use light mode styles.darkMode={true}: Forces all kit components to use dark mode styles.- You can dynamically change the
darkModeprop to switch themes at runtime.
Example:
_10function App() {_10 // Parent app manages dark mode state_10 const [isDark, setIsDark] = useState(false)_10_10 return (_10 <FlowProvider config={...} darkMode={isDark}>_10 <MyFlowComponents />_10 </FlowProvider>_10 )_10}
Accessing Dark Mode State in Components:
You can use the useDarkMode hook to check the current mode inside your components:
_10import { useDarkMode } from "@onflow/react-sdk"_10_10function MyComponent() {_10 // useDarkMode only returns the current state, no setter_10 const { isDark } = useDarkMode()_10 return <div>{isDark ? "Dark mode" : "Light mode"}</div>_10}
Notesβ
- The kit does not automatically follow system preferences or save user choices. You are responsible for managing and passing the correct
darkModevalue. - All kit components will automatically apply the correct Tailwind
dark:classes based on thedarkModeprop. - For best results, ensure your app's global theme and the kit's
darkModeprop are always in sync.
Componentsβ
Connectβ
A drop-in wallet connection component with UI for copy address, logout, and balance display.
Props:
variant?: ButtonProps["variant"]β Optional button style variant (default:"primary")onConnect?: () => voidβ Callback triggered after successful authenticationonDisconnect?: () => voidβ Callback triggered after logoutbalanceType?: "cadence" | "evm" | "combined"β Specifies which balance to display (default:"cadence"). Options:"cadence": Shows the FLOW token balance from the Cadence side"evm": Shows the FLOW token balance from the Flow EVM side"combined": Shows the total combined FLOW token balance from both sides
_10import { Connect } from "@onflow/react-sdk"_10_10<Connect_10 onConnect={() => console.log("Connected!")}_10 onDisconnect={() => console.log("Logged out")}_10/>
Live Demoβ
TransactionButtonβ
Button component for executing Flow transactions with built-in loading states and global transaction management.
Props:
transaction: Parameters<typeof mutate>[0]β Flow transaction object to execute when clickedlabel?: stringβ Optional custom button label (default:"Execute Transaction")mutation?: UseMutationOptions<string, Error, Parameters<typeof mutate>[0]>β Optional TanStack React Query mutation options...buttonPropsβ All otherButtonPropsexceptonClickandchildren(includesvariant,disabled,className, etc.)
_23import { TransactionButton } from "@onflow/react-sdk"_23_23const myTransaction = {_23 cadence: `_23 transaction() {_23 prepare(acct: &Account) {_23 log("Hello from ", acct.address)_23 }_23 }_23 `,_23 args: (arg, t) => [],_23 limit: 100,_23}_23_23<TransactionButton_23 transaction={myTransaction}_23 label="Say Hello"_23 variant="primary"_23 mutation={{_23 onSuccess: (txId) => console.log("Transaction sent:", txId),_23 onError: (error) => console.error("Transaction failed:", error),_23 }}_23/>
Live Demoβ
TransactionDialogβ
Dialog component for real-time transaction status updates.
Props:
open: booleanβ Whether the dialog is openonOpenChange: (open: boolean) => voidβ Callback to open/close dialogtxId?: stringβ Optional Flow transaction ID or scheduled transaction ID to trackonSuccess?: () => voidβ Optional callback when transaction is successfulpendingTitle?: stringβ Optional custom pending state titlependingDescription?: stringβ Optional custom pending state descriptionsuccessTitle?: stringβ Optional custom success state titlesuccessDescription?: stringβ Optional custom success state descriptioncloseOnSuccess?: booleanβ Iftrue, closes the dialog automatically after success
_11import { TransactionDialog } from "@onflow/react-sdk"_11_11_11<TransactionDialog_11 open={isOpen}_11 onOpenChange={setIsOpen}_11 txId="6afa38b7bd1a23c6cc01a4ea2e51ed376f16761f9d06eca0577f674a9edc0716"_11 pendingTitle="Sending..."_11 successTitle="All done!"_11 closeOnSuccess_11/>
Live Demoβ
TransactionLinkβ
Link to the block explorer with the appropriate network scoped to transaction ID or scheduled transaction ID.
Props:
txId: stringβ The transaction ID or scheduled transaction ID to link tovariant?: ButtonProps["variant"]β Optional button variant (defaults to"link")
_10import { TransactionLink } from "@onflow/react-sdk"_10_10<TransactionLink txId="your-tx-id" />