@archetypeai/ds-ui-svelte-labs

中文文档
0.21.0发布于 2026/10/30MITTypeScriptES Module零依赖近 30 天下载 2310

Archetype AI Design System Labs Primitives (experimental 0.x tier composing @archetypeai/ds-ui-svelte-console)

原始使用文档
文档目录9 节
  1. Install
  2. Per-subpath peer dependencies
  3. Tailwind v4 setup (mandatory)
  4. TypeScript setup
  5. Usage
  6. Per-primitive subpaths
  7. Logo (primitives/logo)
  8. VideoPlayer (primitives/video-player)
  9. Extending console primitives

@archetypeai/ds-ui-svelte-labs

Labs primitives of the Archetype AI design system - the experimental 0.x tier built on top of the frozen @archetypeai/ds-ui-svelte-console base. Svelte 5 primitives styled with Tailwind v4 and tailwind-variants, wired to the @archetypeai/ds-lib-tokens theme, composing console primitives (Button, Card, Badge) where they need stable building blocks. TypeScript source ships as .svelte files (no precompilation) so consumers get full type-checking and IDE go-to-definition.

Labs is versioned 0.x: breaking changes are in-contract between minor versions. Components that prove themselves graduate toward console; console itself never changes to accommodate labs.

Like console, the labs flavor ships two ways from the same source:

  • npm package (this document's default) - how apps consume primitives: they stay in node_modules, imported per-subpath, updated by version bump. The package is the source of truth.
  • shadcn-svelte registry - how primitives get modified or extended: pull a primitive's editable source into your app, change it, then port the change back into the package.

Install

npm i @archetypeai/ds-ui-svelte-labs @archetypeai/ds-ui-svelte-console

Then install the peer dependencies shared by all subpaths:

npm i svelte tailwindcss bits-ui tailwind-variants tailwind-merge clsx @lucide/svelte @archetypeai/ds-lib-tokens

Per-subpath peer dependencies

The chart-family subpaths additionally require heavy visualization peers that the other subpaths never load (they are declared as optional peers, so npm does not auto-install them):

SubpathExtra peers
primitives/chartlayerchart
primitives/scatter-chartlayerchart, d3-scale
primitives/sensor-chartlayerchart, d3-scale, d3-shape
npm i [email protected] d3-scale d3-shape

layerchart is pinned to an exact 2.0 pre-release - prerelease versions break APIs between builds, so install the pinned version (labs is 0.x - churn here is in-contract).

Tailwind v4 setup (mandatory)

Tailwind v4 does not scan node_modules by default. Without the @source directives below, every class in this package is purged at consumer build time and components render unstyled.

In your consumer's app.css, in this order:

@import 'tailwindcss';
@import '@archetypeai/ds-lib-tokens/theme.css';
@source "../node_modules/@archetypeai/ds-ui-svelte-console/dist";
@source "../node_modules/@archetypeai/ds-ui-svelte-labs/dist";

Order matters:

  • tailwindcss registers the engine.
  • @archetypeai/ds-lib-tokens/theme.css declares the CSS variables that component classes consume.
  • The two @source directives make Tailwind scan both packages - labs components compose console primitives, so both dists must be scanned.

Adjust the @source paths if your app.css lives elsewhere - they must resolve to each package's dist/ directory.

TypeScript setup

In your consumer's tsconfig.json (or jsconfig.json), set:

{
  "compilerOptions": {
    "moduleResolution": "bundler"
  }
}

"node16" and "nodenext" also work. Without one of these, the types condition in this package's exports map is bypassed, types fall back to the default JS file, and editor features degrade.

Usage

Each primitive lives at its own subpath. There is no barrel import { Logo } from '@archetypeai/ds-ui-svelte-labs' - subpaths keep layerchart and the d3 packages out of bundles for consumers who never touch the chart primitives.

<script lang="ts">
  import Logo from '@archetypeai/ds-ui-svelte-labs/primitives/logo'
  import Menubar from '@archetypeai/ds-ui-svelte-labs/primitives/menubar'
  import Slider from '@archetypeai/ds-ui-svelte-labs/primitives/slider'

  let volume = $state(50)
</script>

<Menubar />
<Logo size="lg" />
<Logo variant="compact" />
<Slider type="single" bind:value={volume} max={100} />

Per-primitive subpaths

PrimitiveImport path
AspectRatio@archetypeai/ds-ui-svelte-labs/primitives/aspect-ratio
Chart@archetypeai/ds-ui-svelte-labs/primitives/chart
Kbd@archetypeai/ds-ui-svelte-labs/primitives/kbd
Logo@archetypeai/ds-ui-svelte-labs/primitives/logo
Menubar@archetypeai/ds-ui-svelte-labs/primitives/menubar
ScatterChart@archetypeai/ds-ui-svelte-labs/primitives/scatter-chart
SensorChart@archetypeai/ds-ui-svelte-labs/primitives/sensor-chart
Slider@archetypeai/ds-ui-svelte-labs/primitives/slider
Switch@archetypeai/ds-ui-svelte-labs/primitives/switch
Toggle@archetypeai/ds-ui-svelte-labs/primitives/toggle
VideoPlayer@archetypeai/ds-ui-svelte-labs/primitives/video-player

Class-merging and element-ref type helpers re-export from console at @archetypeai/ds-ui-svelte-labs/primitives/utils (a single cn/twMerge instance exists in the tree), alongside the labs domain helpers (healthTier, formatMMSS, clamp).

Two artwork forms behind one component. variant="default" is the horizontal wordmark (~5.4:1); variant="compact" is the stacked social/avatar lockup (~1.6:1) - use it where a wordmark will not fit, such as square tiles, avatars, narrow sidebars and splash marks.

Both forms honour the same size scale - sm | default | lg maps to h-4 | h-6 | h-8 - and take their width from w-auto, so swapping variants changes the rendered width, never the height. Because of that, compact reads small at sm; prefer default or lg, or override with class.

<Logo />                              <!-- wordmark, h-6 -->
<Logo variant="compact" size="lg" />  <!-- stacked lockup, h-8 -->
<Logo variant="compact" class="h-16 w-auto" />

Both forms are single inline SVGs coloured by currentColor (text-foreground by default), so they invert with the theme and accept any text-* override. The accessible name is "Archetype AI" for both; pass aria-label / role to override when the mark sits next to a text logotype and would otherwise double-announce.

VideoPlayer (primitives/video-player)

The seek track doubles as a timeline. markers are named windows in seconds (not fractions of the duration), drawn as focusable dots; clicking one expands it into a range pill, seeks to its start and starts playback. One is expanded at a time, bind:activeMarker is its index, and scrubbing by hand or clicking the video surface collapses it. While one is expanded the others step out of the way entirely, pointer events included.

<VideoPlayer
  src={clip}
  bind:time
  bind:duration
  bind:activeMarker
  markers={[{ start: 12, end: 18, label: 'Approach' }]}
  highlights={brushedWindows}
  controlsVisibility="always"
  onMarkerHover={(index) => (hovered = index)}
/>

controlsVisibility="always" is required whenever markers must stay clickable during playback: the default "auto" fades the control bar, and the markers with it, 2.5s in. For linked brushing, highlights tints regions another view is pointing at, and onMarkerHover reports the marker under the cursor or the keyboard focus.

Two traps when src changes, both invisible from the type signature:

  • A new src remounts the player, and Svelte's media bindings write your bound values into the fresh element — so reset time = 0 and paused = true yourself, or a stale position becomes the next clip's start.
  • bind:duration holds the previous clip's value until loadedmetadata. Reseed it from a known length if marker geometry has to be right on the first frame; while duration is 0 every marker collapses onto the left edge.

Marker seeking also needs an origin that serves HTTP Range requests — against one that doesn't, seeks silently do nothing. Serve the clip from a blob URL instead.

Extending console primitives

Labs adapts console primitives without ever changing console, using this escape-hatch ladder (in order):

  1. class prop overrides on the console component
  2. data-slot attribute selectors in consumer CSS
  3. tv({ extend }) on console's exported variant clusters
  4. (rare) a labs wrapper component

This document is the source for the package README (copied by prepack); the full design-system docs live in the repository's readme.

版本与发布记录

@archetypeai/ds-ui-svelte-labs 共发布 21 个版本,首次发布于 2026/06/12;过去 12 个月发布了 21 个版本。

版本发布日期距今
0.21.0latest2026/10/308 天前
0.20.02026/10/2315 天前
0.19.02026/10/1622 天前
0.18.12026/10/081 个月前
0.18.02026/10/031 个月前
0.17.02026/09/181 个月前

关于 @archetypeai/ds-ui-svelte-labs 的常见问题

@archetypeai/ds-ui-svelte-labs 是什么?

Archetype AI Design System Labs Primitives (experimental 0.x tier composing @archetypeai/ds-ui-svelte-console)

如何安装 @archetypeai/ds-ui-svelte-labs?

在项目目录运行 npm install @archetypeai/ds-ui-svelte-labs,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:clsx(^2.0.0)、svelte(^5.0.0)、bits-ui(^2.0.0)、tailwindcss(^4.0.0)、@lucide/svelte(>=0.500.0 <2.0.0)、tailwind-merge(^3.0.0)、tailwind-variants(^3.0.0)、@archetypeai/ds-lib-tokens(>=0.3.0 <1.0.0)、@archetypeai/ds-ui-svelte-console(>=0.7.1 <1.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@archetypeai/ds-ui-svelte-labs 支持 TypeScript 吗?

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

@archetypeai/ds-ui-svelte-labs 支持 ESM 还是 CommonJS?

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

@archetypeai/ds-ui-svelte-labs 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@archetypeai/ds-ui-svelte-labs 可以商用吗?

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

@archetypeai/ds-ui-svelte-labs 的下载量有多少?

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

@archetypeai/ds-ui-svelte-labs 还在维护吗?

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