Overview
CDP React components provide pre-built, customizable UI elements for common self-custodial wallet and authentication flows, built on top of the CDP Embedded Wallets SDK. This guide will help you get started with@coinbase/cdp-react
components in your application.
Check out the CDP Web SDK reference for comprehensive method signatures, types, and examples.
Prerequisites
The fastest way to get started is to complete the Quickstart. If you already have your own app, you should complete the prerequisites below before proceeding. You will need:- A CDP Portal account and CDP project
- Node.js 22+ installed
- Your local app domain configured in CDP Portal
- A package manager of your choice, with
cdp-react
installed:
1. Setup React provider
Wrap your application with theCDPReactProvider
, providing the necessary context for hooks and components to work correctly with CDP. It also provides access to config data and theming.
Using Next.js? Check out our Next.js integration guide for
"use client"
requirements and common gotchas.main.tsx
or App.tsx
) to include the provider:
2. Render a CDP component
Now you can use the components from the library. Let’s add theAuthButton
component to your application. This component handles both sign-in and sign-out functionality.
@coinbase/cdp-react
, set up the provider, and rendered your first component.
Find all available components and their documentation in the CDP React module reference.
3. Customize theme (optional)
CDP React components come with a comprehensive theming system that allows you to customize the look and feel of all components to match your brand. The theme is built on a small set of core semantic tokens that control foundational styles like colors and typography. These are inherited by more specific component tokens used to style individual UI elements. You can customize the theme by passing atheme
object to the CDPReactProvider
:
The theme configuration uses
Partial<Theme>
, so you only need to include the variables you want to customize. Any variables you don’t specify will use CDP React’s default values.Semantic theme variables
This section lists the core semantic tokens that form the foundation of the theme. You only need to customize these tokens to apply a new theme across your entire application. Each token maps to a primary CSS variable which is then inherited by multiple component-level variables. The table below lists the primary mapping and provides an example of a component variable that inherits from it. For an exhaustive list of all tokens along with their default values, see the Theming page.Theme tokens are rendered as CSS variables under the namespace
cdp-web
(i.e. colors-page-bg-default
becomes --cdp-web-colors-page-bg-default
).Token | Description | CSS variable mapping |
---|---|---|
Backgrounds | ||
colors-bg-default | Default page and input background | --cdp-web-colors-bg-default (inherited by e.g. --cdp-web-colors-page-bg-default ) |
colors-bg-alternate | Alternate backgrounds (e.g. cards) | --cdp-web-colors-bg-alternate (inherited by e.g. --cdp-web-colors-code-bg-default ) |
colors-bg-contrast | A contrast color mixed with other backgrounds to generate default hover and pressed states. | --cdp-web-colors-bg-contrast |
colors-bg-overlay | Overlay UI (e.g. modals). Defaults to 33% opacity of colors-bg-alternate | --cdp-web-colors-bg-overlay |
colors-bg-skeleton | Loading placeholders. Defaults to 10% opacity of colors-fg-default | --cdp-web-colors-bg-skeleton |
colors-bg-primary | Primary brand background (e.g. CTA) | --cdp-web-colors-bg-primary (inherited by e.g. --cdp-web-colors-cta-primary-bg-default ) |
colors-bg-secondary | Secondary background (e.g. secondary CTA) | --cdp-web-colors-bg-secondary (inherited by e.g. --cdp-web-colors-cta-secondary-bg-default ) |
Text | ||
colors-fg-default | Default text color | --cdp-web-colors-fg-default (inherited by e.g. --cdp-web-colors-page-text-default ) |
colors-fg-muted | Muted/placeholder text | --cdp-web-colors-fg-muted (inherited by e.g. --cdp-web-colors-page-text-muted ) |
colors-fg-primary | Primary action text (e.g. links) | --cdp-web-colors-fg-primary (inherited by e.g. --cdp-web-colors-link-primary-text-default ) |
colors-fg-onPrimary | Text on primary backgrounds | --cdp-web-colors-fg-onPrimary (inherited by e.g. --cdp-web-colors-cta-primary-text-default ) |
colors-fg-onSecondary | Text on secondary backgrounds | --cdp-web-colors-fg-onSecondary (inherited by e.g. --cdp-web-colors-cta-secondary-text-default ) |
colors-fg-positive | Success messaging text | --cdp-web-colors-fg-positive (inherited by e.g. --cdp-web-colors-input-successText-default ) |
colors-fg-negative | Error messaging text | --cdp-web-colors-fg-negative (inherited by e.g. --cdp-web-colors-input-errorText-default ) |
colors-fg-warning | Warning messaging text | --cdp-web-colors-fg-warning |
Borders | ||
colors-line-default | Standard borders (e.g. dividers) | --cdp-web-colors-line-default (inherited by e.g. --cdp-web-colors-page-border-default ) |
colors-line-heavy | Higher contrast borders (e.g. inputs) | --cdp-web-colors-line-heavy (inherited by e.g. --cdp-web-colors-input-border-default ) |
colors-line-primary | Primary brand color borders (e.g. for focus/active state) | --cdp-web-colors-line-primary (inherited by e.g. --cdp-web-colors-input-border-focus ) |
colors-line-positive | Success state borders | --cdp-web-colors-line-positive (inherited by e.g. --cdp-web-colors-input-border-success ) |
colors-line-negative | Error borders | --cdp-web-colors-line-negative (inherited by e.g. --cdp-web-colors-input-border-error ) |
Typography | ||
font-family-sans | Sans-serif font family | --cdp-web-font-family-sans |
font-family-mono | Monospace font family | --cdp-web-font-family-mono |
font-size-base | Base font size | --cdp-web-font-size-base |
Smart color defaults
Smart color defaults
Some theme colors automatically derive from other theme values, reducing the need for manual configuration:
colors-bg-overlay
: Automatically uses 33% opacity ofcolors-bg-alternate
colors-bg-skeleton
: Automatically uses 10% opacity ofcolors-fg-default
colors-bg-alternate
and colors-fg-default
, the overlay and skeleton colors will automatically adjust to complement your theme with no additional configuration needed.Customizing a theme variable like
colors-bg-primary
updates all components that inherit from that color without additional CSS overrides.Dynamic themes
For more dynamic theming (e.g., dark/light mode support), you can reference CSS variables in your theme definition:Theme changes are applied instantly across all CDP React components. You don’t need to restart your application or refresh the page to see theme updates.
What to read next
- CDP Web SDK Documentation: Comprehensive API reference for the CDP Web SDK
- Embedded Wallet - React Hooks: Use CDP hooks for custom implementations
- Embedded Wallet - Theming: Explore all semantic and component theme tokens
- Embedded Wallet - Wagmi Integration: Combine CDP components with wagmi
- Embedded Wallet - Next.js: Special considerations for Next.js applications
- Security & Export: Learn about private key export security considerations and implementation