@delightstack/components

中文文档
2.2.0发布于 2026/11/12MITTypeScriptES Module构建来源已验证近 30 天下载 2702

Delightstack Svelte 5 component library — accessible actions, forms, media, navigation, feedback, and display components.

原始使用文档
文档目录10 节
  1. Installation
  2. Usage
  3. Conventions
  4. Components
  5. Theming
  6. Optional peer dependencies
  7. TypeScript
  8. Testing
  9. AI coding agents
  10. License

@delightstack/components

A polished, opinionated Svelte 5 component library focused on delightful user experiences — 50+ accessible, themeable components built on runes, with motion and micro-interactions designed in from the start.

Docs: docs.thedelight.co · Live demo: docs.thedelight.co/demo

Installation

pnpm add @delightstack/components @delightstack/styles

Import the design tokens once at the root of your app (e.g. src/routes/+layout.svelte):

import '@delightstack/styles';

Requires Svelte ^5.36.0. Works with SvelteKit and standalone Vite + Svelte projects.

Usage

All components are available from a single import — unused ones are tree-shaken:

<script>
    import { Button, Input, BottomSheet } from '@delightstack/components';

    let name = $state('');
    let open = $state(false);

    async function save() {
        await fetch('/api/user', { method: 'POST', body: JSON.stringify({ name }) });
    }
</script>

<Input label="Name" bind:value={name} />
<!-- Promise-returning callbacks show a loading state automatically -->
<Button onclick={save}>Save</Button>
<Button outline onclick={() => (open = true)}>Filters</Button>

<BottomSheet bind:open snap_points={[0.5, 0.92]}>
    <p>Slide me around.</p>
</BottomSheet>

Conventions

  • Props are snake_case, callbacks are camelCase — snap_points, full_width vs onclick, onchange. The visual distinction between data and behavior is intentional.
  • Callback props, not dispatched events. Callbacks that return a Promise put the component into a loading state until they settle.
  • Two-way binding with bind:value, plus component-specific bindables like bind:open, bind:snap, and bind:page.
  • Svelte 5 snippets for named content areas ({#snippet header()}…{/snippet}).

Components

CategoryComponents
ActionsButton, ButtonGroup, Modal, Alert, Popover, ContextMenu, Portal, CommandPalette, ThemeToggle
DisplayAccordion, Avatar, AvatarGroup, Calendar, Chart, Code, Comparison, Counter, Expand, List, ListItem, QR, SplitPane, Stat, Table, Timeline, Tree, Typewriter
FeedbackCallout, Confetti, Progress, Toaster (toast())
FormCheckbox, Fieldset, FileUpload, Form, Input, Radio, RadioGroup, Range, Rating, Select, Toggle
MediaCarousel, Gallery, Image, Panorama, PDF, Video
NavigationBottomSheet, Breadcrumbs, Pagination, Steps, Tabs

Every component has a docs page with live examples and full Props / Events / CSS Variables / Accessibility tables: docs.thedelight.co/components/overview.

Theming

Components read every color, size, and motion value from CSS custom properties shipped by @delightstack/styles, with light and dark values built in. Re-theme by overriding the brand seed or any individual token:

:root {
    /* Re-derives the whole palette from one brand color */
    --color-primary: #2563eb;

    /* …or override individual semantic tokens outright */
    --color-action: light-dark(#2563eb, #3b82f6);
    --radius-md: 0.5rem;
}

See the Theming and Design Tokens guides.

Optional peer dependencies

A few media components dynamically import heavier libraries — install them only if you use the component, and import these two from their dedicated subpaths:

ComponentPeer dependencyImport from
Panoramathree@delightstack/components/panorama
PDFpdfjs-dist@delightstack/components/pdf
Videohls.js (only for HLS sources)@delightstack/components

In Vite dev, add the ones you use to optimizeDeps.include so they are not stubbed as absent optional dependencies.

TypeScript

Types are included — no @types/* packages needed. Data-structure types ship from the main entry point:

import type { SelectOption, TableColumn, TreeNode, CalendarEvent } from '@delightstack/components';

The package also ships its full .svelte sources in dist/, so editors (and AI agents) get JSDoc descriptions for every prop.

Testing

Most of the package's logic lives in pure modules exported alongside the components — diff-model.ts, selection.ts — and those carry the bulk of the tests: no runes, no DOM, nothing to mount, and rules that can be asserted line by line.

There is no DOM test environment here. When a behaviour genuinely belongs to the component and not to its model, render it on the server and assert the markup:

import { render } from 'svelte/server';
import DiffViewer from './DiffViewer.svelte';

const html = render(DiffViewer, { props: { hunks } }).body;

DiffViewer.test.ts is the precedent — it checks which way a move's arrows point, which is a question about where two rows sit relative to each other on the page and so has no answer in the model. Reach for this only for that kind of case; if the assertion can be made against a pure model instead, make it there.

AI coding agents

Set up Claude Code, Cursor, Codex, and friends to use this library correctly in one command from your project root:

pnpm exec delightstack-agents

This installs a ready-made skill (.claude/skills/delightstack/SKILL.md) and points your AGENTS.md at it. Docs are also published as plain markdown — append .md to any docs page URL, or start from docs.thedelight.co/llms.txt. See the AI Agents guide.

License

MIT

版本与发布记录

@delightstack/components 共发布 34 个版本,首次发布于 2026/06/29;过去 12 个月发布了 34 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.2.0latest2026/11/12今天
2.1.42026/11/12今天
2.1.32026/11/11今天
2.1.22026/11/111 天前
2.1.12026/11/101 天前
2.1.02026/11/102 天前

关于 @delightstack/components 的常见问题

@delightstack/components 是什么?

Delightstack Svelte 5 component library — accessible actions, forms, media, navigation, feedback, and display components.

如何安装 @delightstack/components?

在项目目录运行 npm install @delightstack/components,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:svelte(^5.36.0)、@delightstack/styles(^1.3.1)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。它还提供命令行工具 delightstack-agents,可以用 npx delightstack-agents 直接运行。

@delightstack/components 支持 TypeScript 吗?

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

@delightstack/components 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@delightstack/components 可以商用吗?

@delightstack/components 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@delightstack/components 的下载量有多少?

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

@delightstack/components 还在维护吗?

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