@dynamic-labs-sdk/droplet

中文文档
1.51.0发布于 2026/11/11TypeScriptESM + CJS近 30 天下载 3198

Dynamic Labs' React component library. Built on Radix UI primitives, Tailwind CSS v4, and an OKLCH-based design token system. Ships with 35+ components, animated icons, dark mode, and a live Storybook.

原始使用文档
文档目录25 节
  1. Installation
  2. Setup
  3. 1. Install and configure Tailwind v4
  4. 2. Import the design tokens stylesheet
  5. 3. Add droplet to Tailwind's @source paths
  6. Usage
  7. Components
  8. UI Primitives
  9. Project Patterns
  10. Animated Icons
  11. Utilities & Hooks
  12. Theming
  13. Quick start: change the brand color
  14. Cascade order matters
  15. What's themeable
  16. Scoping a theme to part of your app
  17. Color space
  18. Design tokens
  19. Color groups
  20. Shadow system
  21. Radius scale
  22. Dark mode
  23. Storybook
  24. Development
  25. Tech stack

@dynamic-labs-sdk/droplet

Dynamic Labs' React component library. Built on Radix UI primitives, Tailwind CSS v4, and an OKLCH-based design token system. Ships with 35+ components, animated icons, dark mode, and a live Storybook.


Installation

npm install @dynamic-labs-sdk/droplet
# or
pnpm add @dynamic-labs-sdk/droplet
# or
yarn add @dynamic-labs-sdk/droplet

Peer dependencies: react >= 18, react-dom >= 18, tailwindcss >= 4. Next.js (>= 14) is optional.


Setup

Droplet ships Tailwind CSS v4 utility classes baked into its compiled output. You must (1) have Tailwind v4 configured in your app, (2) import the design tokens stylesheet, and (3) tell Tailwind to scan droplet's dist/ so its utility classes are emitted into your stylesheet.

1. Install and configure Tailwind v4

If you don't already have Tailwind v4, follow the Tailwind v4 install guide. The @tailwindcss/vite plugin is the simplest path for Vite/Next:

// vite.config.ts
import tailwindcss from '@tailwindcss/vite';
import { defineConfig } from 'vite';

export default defineConfig({
  plugins: [tailwindcss()],
});

2. Import the design tokens stylesheet

Import once at your app root. This provides the full color, shadow, radius, and typography token system and is required for all components to render correctly.

import '@dynamic-labs-sdk/droplet/styles/globals.css';

3. Add droplet to Tailwind's @source paths

Tailwind v4 only scans the consuming project by default, so it will miss the utility classes inside droplet's compiled JS. Add an @source directive to your app's main stylesheet:

/* app.css */
@import 'tailwindcss';
@source "../node_modules/@dynamic-labs-sdk/droplet/dist";

Adjust the relative path to match where your stylesheet lives. Without this step, components will render unstyled.


Usage

import {
  Button,
  Card,
  CardContent,
  CardHeader,
  CardTitle,
  Badge,
} from '@dynamic-labs-sdk/droplet';

export const Example = () => (
  <Card>
    <CardHeader>
      <CardTitle>
        My Feature
        <Badge variant="brand">New</Badge>
      </CardTitle>
    </CardHeader>
    <CardContent>
      <Button>Get started</Button>
    </CardContent>
  </Card>
);

Components

UI Primitives

Thin wrappers over Radix UI primitives with full token-based styling.

ExportDescription
Accordion, AccordionItem, AccordionTrigger, AccordionContentCollapsible content sections
AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogAction, AlertDialogCancel, ...Destructive action confirmation modal
Avatar, AvatarImage, AvatarFallbackUser avatar with initials fallback
BadgeSemantic status/label chip. Variants: default, secondary, outline, destructive, brand, success, warning, process
ButtonPrimary interactive element. Variants: default, secondary, outline, ghost, destructive, link
Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooterComposable card layout
CheckboxAccessible checkbox with draw-on animation
Collapsible, CollapsibleTrigger, CollapsibleContentTogglable content region
Command, CommandInput, CommandList, CommandItem, CommandGroup, ...Headless command palette (cmdk)
Dialog, DialogTrigger, DialogContent, DialogHeader, DialogTitle, DialogBody, DialogFooter, ...Accessible modal dialog
DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, ...Keyboard-navigable dropdown
IconWrapper for HugeIcons with consistent stroke width
InputText input with field shadow system
KbdKeyboard shortcut display (⌘K)
LabelForm label linked to control
Popover, PopoverTrigger, PopoverContent, PopoverAnchorFloating content panel
ProgressProgress bar, determinate and indeterminate
RadioGroup, RadioGroupItemRadio button group with hover dot
ScrollArea, ScrollBarCustom-styled scrollable container
SearchInputInput with leading search icon
Select, SelectTrigger, SelectContent, SelectItem, SelectValue, ...Radix-backed select
SelectableCardCard with embedded checkbox/radio state
SeparatorHorizontal or vertical divider
Sheet, SheetTrigger, SheetContent, SheetHeader, SheetTitle, SheetFooter, ...Side drawer (top / right / bottom / left)
SkeletonShimmer loading placeholder
ToasterToast notifications (Sonner)
SpinnerAnimated loading indicator
SwitchToggle switch with data-slot label integration
Table, TableHeader, TableBody, TableRow, TableHead, TableCell, TableFooter, TableCaptionData table
Tabs, TabsList, TabsTrigger, TabsContentTabbed navigation, underline and pill variants
TextareaMultiline text input
Tooltip, TooltipTrigger, TooltipContent, TooltipProviderHover tooltip
Well, WellRevealInset container for grouped settings

Project Patterns

Higher-level components composed from primitives, designed for dashboard and settings UIs.

ExportDescription
AskAiSheetSide panel for AI assistant integration
AssetIconChain/token icon with fallback initial
CodeBlockSyntax-highlighted code block with copy button
CopyButtonClipboard copy trigger with animated check
DangerZoneDestructive settings section gated by confirmation
DomainListEditable list of allowed domains with add/remove
EmptyStateZero-data placeholder with icon, title, description, CTA
InfoBannerContextual banner. Variants: info, warning, success, danger
MetricCardKPI stat card with value, label, and trend
PageActionsSticky bottom action bar with primary/secondary slots
PageSkeleton, StatCardSkeleton, TableSkeletonPage-level loading skeletons
ProductPageLayoutFull-page scaffold: header, tabs, content, sidebar
SettingsSectionLabeled section wrapper for settings pages
StatusBadgeLive / inactive / pending status indicator
TabNavigationFull-width underline tab navigation for switching related views
ToggleRowLabel + description + switch in a single accessible row
UnsavedChangesBarSticky bottom bar for save/discard with change tracking

Animated Icons

Custom SVG icons with spring physics via Motion. All icons accept standard SVG props plus a className.

import {
  ChevronDownIcon,
  CopyCheckIcon,
  SettingsIcon,
} from '@dynamic-labs-sdk/droplet';

<SettingsIcon className="size-4 text-muted-foreground" />;
ExportDescription
AnimatedIconBase wrapper for building animated icons
ArrowUpRightIconExternal link arrow
ChartBarIncreasingIconAnimated bar chart
ChevronDownIconChevron, rotates on toggle
ChevronRightIconChevron pointing right
CopyIconCopy to clipboard
CopyCheckIconCopy → check transition
DollarSignIconCurrency symbol
DownloadIconDownload arrow
FingerprintIconBiometric fingerprint
HomeIconHome/dashboard
KeyIconAPI key / auth
LayoutPanelTopIconLayout panel
LinkIconHyperlink
MoonIconDark mode
PanelLeftCloseIconCollapse sidebar
PanelLeftOpenIconExpand sidebar
PlusIconAdd / create
RefreshCWIconRefresh / reload
SearchIconSearch magnifier
SettingsIconSettings gear
ShieldCheckIconSecurity / verified
SunIconLight mode
TerminalIconCode / CLI
UsersIconUsers / team
ClaudeLogo, CursorLogo, OpenAILogo, VSCodeLogo, WindsurfLogoMCP tool logos

Utilities & Hooks

ExportDescription
cn(...classes)clsx + tailwind-merge class utility
useUnsavedChanges(hasChanges)Hook for the UnsavedChangesBar — tracks dirty state and wires keyboard shortcuts
IconConfigProviderContext provider for global icon configuration
useIconConfig()Access icon config context

Theming

Droplet's theme is a layer of CSS custom properties. Tailwind utility classes resolve through them (bg-brand-default → var(--brand-default)), and every component reads from the same vars — so you can fully rebrand by redefining the vars in your own stylesheet. No Tailwind config changes, no rebuild, no fork.

Quick start: change the brand color

/* your-theme.css — imported AFTER @dynamic-labs-sdk/droplet/styles/globals.css */

:root {
  --brand-default: oklch(0.67 0.21 30);  /* your light-mode brand */
  --brand-hover: oklch(0.72 0.19 30);
  --brand-accented: oklch(0.58 0.22 30);
  --brand-light: oklch(0.97 0.03 30);
  --ring: oklch(0.67 0.21 30);
  --action: oklch(0.67 0.21 30);
}

.dark {
  --brand-default: oklch(0.6 0.22 30);   /* your dark-mode brand */
  --brand-hover: oklch(0.68 0.19 30);
  --brand-accented: oklch(0.52 0.23 30);
  --brand-light: oklch(0.27 0.07 30);
  --ring: oklch(0.6 0.22 30);
  --action: oklch(0.6 0.22 30);
}
// in your app entry, AFTER the droplet import
import '@dynamic-labs-sdk/droplet/styles/globals.css';
import './your-theme.css';

That's it. Buttons, links, focus rings, text-selection highlights, sidebars — all switch to the new brand.

Cascade order matters

Your theme stylesheet must load after @dynamic-labs-sdk/droplet/styles/globals.css, or the same selectors (:root, .dark) in droplet's stylesheet will win and your overrides will silently do nothing. If you @import in a single CSS file, put droplet's import first:

@import '@dynamic-labs-sdk/droplet/styles/globals.css';
@import './your-theme.css';

What's themeable

Anything in the Design tokens table below — colors, shadows, radii. The most common things to override:

What you want to changeTokens
Brand color (buttons, focus rings, links, selection)--brand-default, --brand-hover, --brand-accented, --brand-light, --ring, --action
Surfaces (page bg, cards, sidebar)--background, --card, --bg-bottom, --bg-default, --sidebar
Text colors--foreground, --muted-foreground, --text-link
Radius scale--radius-sm through --radius-4xl
Selection highlight--selection-bg
Solid button top-highlight--button-highlight
Checkbox / radio hover fills--checkbox-hover-fill, --radio-hover-fill

For semantic colors (success/danger/warning/process), override the matching --<state>-default, --<state>-light, --text-<state> triplet.

Scoping a theme to part of your app

If you only want droplet themed inside a subtree (e.g., a marketing site reusing one component), put the overrides on a wrapper class instead of :root:

.my-theme {
  --brand-default: oklch(0.67 0.21 30);
  /* ... */
}
<div className="my-theme">
  <Button>Themed</Button>
</div>

Color space

Droplet uses OKLCH throughout. If your design system is in hex/rgb, tools like oklch.com or oklch.fyi will convert. You don't have to use OKLCH in your overrides — oklch(), hex, rgb(), and hsl() all interoperate fine — but staying in OKLCH gives you perceptually uniform lightness ramps when you tune hover/accented variants.


Design tokens

All tokens are CSS custom properties defined in globals.css. Tailwind utility classes map directly to them — bg-brand-default resolves to var(--brand-default).

Color groups

GroupTokens
Surfaces--background, --card, --popover, --muted, --accent, --bg-bottom, --bg-default, --bg-accented, --bg-strong, --bg-absolute
Text--foreground, --muted-foreground, --text-disabled, --text-placeholder, --text-link, --text-invert
Brand--brand-default, --brand-hover, --brand-accented, --brand-light, --action
Semantic--success-default/light/text, --danger-default/light/text, --warning-default/light/text, --process-default/light/text
Borders--border, --border-divider, --border-default, --border-hover, --border-strong, --border-focused, --border-selected, --border-danger, --border-success, --border-process, --border-warning
Overlays--overlay-hover, --overlay-pressed, --overlay-selected, --overlay-selected-hover, --overlay-md, --overlay-strong

Shadow system

--shadow-border       /* 1px outline */
--shadow-card         /* card elevation */
--shadow-button       /* button depth */
--shadow-input        /* form field */
--shadow-input-hover  /* field on hover */
--shadow-elevated     /* popovers / dropdowns */
--shadow-card-content /* content area separator */

Radius scale

TokenValue
--radius-sm6px
--radius-md8px
--radius-lg10px
--radius-xl12px
--radius-2xl14px
--radius-3xl16px
--radius-4xl20px

Dark mode

Apply the .dark class to <html> to activate the dark palette. All tokens are redefined under .dark with OKLCH-matched values — brand hue is preserved, only lightness shifts.

document.documentElement.classList.toggle('dark', isDark);

Storybook

Interactive component documentation with live token reference, dark mode toggle, and a11y audit on every story.

# From repo root
pnpm --filter @dynamic-labs-sdk/droplet storybook

# From packages/droplet
pnpm storybook

Runs on http://localhost:4402.


Development

# Run tests
pnpm --filter @dynamic-labs-sdk/droplet test

# Watch mode
pnpm --filter @dynamic-labs-sdk/droplet test:watch

# Build (ESM + CJS + .d.ts)
pnpm --filter @dynamic-labs-sdk/droplet build

# Lint
pnpm --filter @dynamic-labs-sdk/droplet lint

Tech stack

PrimitivesRadix UI
StylingTailwind CSS v4 via @tailwindcss/vite
AnimationsMotion (spring physics)
IconsHugeIcons
Variantsclass-variance-authority
ToastsSonner
Buildtsdown (dual ESM/CJS)
TestsVitest + Testing Library
DocsStorybook 8

版本与发布记录

@dynamic-labs-sdk/droplet 共发布 88 个版本,首次发布于 2026/05/13;过去 12 个月发布了 88 个版本。

版本发布日期距今
1.51.0latest2026/11/112 天前
1.50.02026/11/058 天前
1.49.12026/11/0210 天前
1.49.02026/10/3113 天前
1.48.02026/10/3014 天前
1.47.02026/10/2816 天前

关于 @dynamic-labs-sdk/droplet 的常见问题

@dynamic-labs-sdk/droplet 是什么?

Dynamic Labs' React component library. Built on Radix UI primitives, Tailwind CSS v4, and an OKLCH-based design token system. Ships with 35+ components, animated icons, dark mode, and a live Storybook.

如何安装 @dynamic-labs-sdk/droplet?

在项目目录运行 npm install @dynamic-labs-sdk/droplet,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=18)、react-dom(>=18)、tailwindcss(>=4)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@dynamic-labs-sdk/droplet 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@dynamic-labs-sdk/droplet 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@dynamic-labs-sdk/droplet 可以商用吗?

@dynamic-labs-sdk/droplet 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@dynamic-labs-sdk/droplet 的下载量有多少?

根据 npm 官方下载统计,@dynamic-labs-sdk/droplet 在 2026/10/13 – 2026/11/11 这 30 天内被下载 3,198 次,日均约 107 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dynamic-labs-sdk/droplet 还在维护吗?

最新版本 1.51.0 发布于 2026/11/11(2 天前);至今共发布 88 个版本,其中过去 12 个月发布了 88 个;首次发布于 2026/05/13。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。