Why This Matters
Building DeFi UIs from scratch means weeks of work: integrating wallet connections, managing chain switching, building deposit/withdraw flows, displaying positions and P&L. Our React widgets handle all of this out of the box.Widget Builder Studio
Build and customize widgets visually with our AI-powered widget builder:Widget Builder Studio
Create, customize, and preview widgets with natural language. Export production-ready code.
What It Does
Pre-built React components that connect to the Compass API. Users can browse yield opportunities, deposit funds, track positions, and withdraw—all within your app’s UI. You bring your own wallet provider (RainbowKit, Privy, etc.) and we handle the DeFi complexity.Installation
Quick Start
There are three parts to setting up the widgets:- Client-side providers - Wrap your app with wallet and Compass providers
- Server-side API route - Handle secure API calls and gas sponsorship
- Add widgets - Drop in the widget components
Step 1: Client-side Providers
Create a providers file that connects your wallet to the widgets:Step 2: Server-side API Route
The widgets make API calls through your server to keep your API key secure. Create a catch-all API route:Step 3: Environment Variables
Get a free WalletConnect Project ID at cloud.walletconnect.com. You can restrict which domains can use your project ID in the dashboard.
Step 4: Add Layout and Widgets
Step 5: Configure Tailwind (if using)
If you’re using Tailwind CSS, add the widgets package to your content config:Available Widgets
CompassEarnWidget
The complete earn experience in a single component. Includes tabbed navigation between Vaults, Aave, Pendle, and Swap.| Prop | Type | Default | Description |
|---|---|---|---|
defaultTab | ’vaults’ | ‘aave’ | ‘pendle’ | ‘swap' | 'vaults’ | Initial active tab |
onTabChange | function | undefined | Callback when tab changes |
SwapWidget
Token swap interface with real-time quotes and gas-sponsored execution.| Prop | Type | Default | Description |
|---|---|---|---|
defaultFromToken | string | ’ETH’ | Default input token |
defaultToToken | string | ’USDC’ | Default output token |
allowedTokens | string[] | [‘USDC’, ‘ETH’, ‘WETH’, ‘WBTC’, ‘DAI’, ‘USDT’] | Tokens available for swap |
showReverseButton | boolean | true | Show button to reverse token pair |
showSettings | boolean | false | Show settings (slippage, etc.) |
onSwapSuccess | function | undefined | Callback after successful swap |
onSwapError | function | undefined | Callback on swap error |
VaultsList
Displays ERC-4626 yield vaults with APY, TVL, and user positions.| Prop | Type | Default | Description |
|---|---|---|---|
showApy | boolean | true | Show APY metrics |
apyPeriods | string[] | [‘7d’, ‘30d’, ‘90d’] | Which APY periods to display |
showTvl | boolean | true | Show total value locked |
showUserPosition | boolean | true | Show user’s current position |
showPnL | boolean | true | Show profit/loss summary |
showHistory | boolean | true | Show transaction history |
showSearch | boolean | true | Enable search functionality |
showSort | boolean | true | Enable sorting options |
actionMode | ’modal’ | ‘inline' | 'modal’ | How to show deposit/withdraw form |
defaultSort | string | ’apy_7d’ | Default sort option |
assetFilter | string[] | undefined | Filter by asset symbols |
onVaultSelect | function | undefined | Callback when vault is clicked |
onDeposit | function | undefined | Callback after successful deposit |
onWithdraw | function | undefined | Callback after successful withdraw |
AaveMarketsList
Displays Aave V3 lending markets with supply APY and user positions.PendleMarketsList
Displays Pendle fixed-yield markets with APY, expiry dates, and TVL.Wallet Adapter
TheCompassProvider accepts a wallet prop to connect your wallet library. This allows the widgets to:
- Display the connected wallet address
- Request transaction signatures
- Switch chains when needed
Using with Privy
Theming
The widgets support three theming approaches:- Preset name - Use a built-in theme:
theme="compass-dark" - Preset with overrides - Start from a preset and customize:
theme={{ preset: 'compass-dark', overrides: {...} }} - Complete custom theme - Provide a full theme object
Built-in Theme Presets
| Preset | Description |
|---|---|
compass-dark | Default dark theme with indigo/purple accents and glassmorphism |
compass-light | Light theme with indigo primary and subtle shadows |
minimal-dark | Flat dark design with white/gray primary, sharp corners, no shadows |
minimal-light | Flat light design with black/gray primary, sharp corners |
high-contrast-dark | Accessible dark theme with blue primary, bold borders, larger text |
high-contrast-light | Accessible light theme with bold colors and larger text |
Custom Theme Overrides
Customize any theme property by providing a preset with overrides:Colors
Brand Colors (colors.brand)
| Property | Description |
|---|---|
primary | Primary brand color for buttons, links, and accents |
primaryHover | Hover state for primary color |
primaryMuted | Muted/subtle variant of primary (for backgrounds, badges) |
primaryText | Text color on primary-colored backgrounds |
secondary | Secondary accent color |
secondaryHover | Hover state for secondary color |
Background Colors (colors.backgrounds)
| Property | Description |
|---|---|
background | Main page/widget background |
surface | Card and panel backgrounds |
surfaceHover | Hover state for surfaces |
overlay | Modal and overlay backdrop color |
Text Colors (colors.text)
| Property | Description |
|---|---|
text | Primary text color |
textSecondary | Secondary/muted text |
textTertiary | Tertiary/disabled text |
Border Colors (colors.borders)
| Property | Description |
|---|---|
border | Default border color |
borderHover | Border hover state |
borderFocus | Focus ring color for inputs |
Semantic Colors (colors.semantic)
Each semantic color has a DEFAULT (main color) and muted (background/subtle) variant:
| Property | Description |
|---|---|
success.DEFAULT | Success/positive state color |
success.muted | Success background/subtle color |
warning.DEFAULT | Warning/caution state color |
warning.muted | Warning background/subtle color |
error.DEFAULT | Error/negative state color |
error.muted | Error background/subtle color |
info.DEFAULT | Info/neutral state color |
info.muted | Info background/subtle color |
Typography
Customize fonts and text styles across five scales.Font Families (typography)
| Property | Description |
|---|---|
fontFamily | Primary font stack for all text |
fontFamilyMono | Monospace font for code and numbers |
Text Scales
Each scale (heading, subheading, body, caption, label) supports:
| Property | Description |
|---|---|
fontSize | Font size (e.g., '1.5rem') |
lineHeight | Line height (e.g., '1.4') |
fontWeight | Font weight (e.g., '600') |
letterSpacing | Letter spacing (e.g., '-0.02em') - optional |
Spacing
Control padding and spacing throughout the widgets.| Property | Description |
|---|---|
unit | Base spacing unit (e.g., '4px') |
containerPadding | Outer container padding |
cardPadding | Padding inside cards and panels |
inputPadding | Padding inside input fields and buttons |
Shape
Control border radius and border widths.Border Radius (shape.borderRadius)
A scale of radius values used throughout the widgets:
| Property | Description |
|---|---|
none | No radius (e.g., '0') |
sm | Small radius for subtle rounding |
md | Medium radius for inputs and buttons |
lg | Large radius for cards |
xl | Extra large radius for modals |
full | Fully rounded (e.g., '9999px') |
Border Width (shape.borderWidth)
| Property | Description |
|---|---|
borderWidth | Default border width (e.g., '1px') |
Effects
Control shadows, blur effects, and transition timing.Shadows (effects.shadow)
| Property | Description |
|---|---|
sm | Subtle shadow for hover states |
md | Medium shadow for cards |
lg | Large shadow for modals and dropdowns |
Blur (effects.blur)
| Property | Description |
|---|---|
sm | Subtle blur for overlays |
md | Medium blur for glassmorphism |
lg | Heavy blur for backgrounds |
Transitions (effects.transition)
| Property | Description |
|---|---|
fast | Quick interactions (150ms) |
normal | Standard transitions (200ms) |
slow | Deliberate animations (300ms) |
Full Theme Example
Here’s a complete example showing all customizable properties:Supported Chains
The widgets support these chains:| Chain | ID |
|---|---|
| Ethereum | ethereum |
| Base | base |
| Arbitrum | arbitrum |
Gas Sponsorship
To sponsor gas for your users, you need:- A gas sponsor private key with ETH on each chain
- RPC URLs configured in the API route handler
gasSponsorPrivateKey is configured. See Gas Sponsorship for more details.