@spicenet-io/spiceflow-ui
v3.3.65
Published
Spiceflow UI SDK
Readme
SpiceFlow UI SDK
A React component library for building DeFi swap interfaces with multi-chain support.
Installation
npm install @spicenet-io/spiceflow-uiUsage
import { SwapWidget, SpiceFlowProvider } from "@spicenet-io/spiceflow-ui";
import "@spicenet-io/spiceflow-ui/styles.css";
function App() {
return (
<SpiceFlowProvider
provider="privy"
privyAppId="your-privy-app-id"
dynamicEnvironmentId="your-env-id"
paraApiKey="your-para-api-key"
paraAppName="your-app-name"
>
<SwapWidget
swapBatches={swapBatches}
supportedChains={[1, 137, 42161]}
showSlippageSettings={true}
enableFlipSwap={true}
theme="dark"
/>
</SpiceFlowProvider>
);
}Components
- SwapWidget - Main swap interface component
- AssetSelector - Token selection component
- SpiceDeposit - Deposit modal component
- StatusDisplay - Transaction status display
- ProviderLogin - Wallet connection component
- DebugWidget - Development debugging component
- Button, Input, Modal - UI primitives
Development
Fee-Charging Intent Flows
SpiceSupplyandSpicePayare fee-charging intent-execution flows and must surface fee estimation before enabling submission.SpiceLockModalis also a fee-charging intent-execution flow and must surface fee estimation before enabling submission.SpiceDepositandSpiceWithdraware treated as non-fee actions and should not use the fee-estimation gating UX.- Rule of thumb: every intent-execution flow other than deposit/withdraw should assume fees apply and should gate CTA enablement on successful fee estimation.
Building the Library
bun run buildType Checking
bun run typecheckLinting
bun run lint
bun run lint:fixComponent Playground
This repository includes a lightweight React playground app for viewing and testing all components without the complexity of Storybook.
Running the Playground
Install dependencies (if not already done):
bun install --frozen-lockfileNavigate to the playground directory:
cd playgroundInstall playground dependencies:
bun install --frozen-lockfileStart the development server:
bun run devThe playground will open automatically at
http://localhost:3000
Using the Playground
- Left Sidebar: Browse available components
- Main Area: View the selected component with different example variants
- Example Tabs: Switch between different states/examples for each component
Adding a New Component Example
To add a new example variant for a component:
- Open
playground/src/ComponentRegistry.tsx - Find the component's entry in the
examplesobject - Add a new entry to the array:
{ label: 'Your Example Name', render: () => <YourComponent {...props} />, }
The playground will automatically pick up the new example and display it as a tab.
License
MIT
