ShadKit 是一个 SwiftUI 版本的 shadcn/ui 和 Vercel AI Elements 的移植库,精确地从官方注册表 JSON 中复制组件,无外部依赖,支持 macOS 14+ 和 iOS 17+。

Stars

15

7 天增长

暂无数据

Fork 数

1

开放 Issue

0

开源协议

MIT

最近更新

2026-07-30

AI 仓库情报摘要
FR-AI / ANALYSIS

为什么值得关注

它并非根据截图而是直接从注册表源文件移植组件,保证了类级别的忠实度;并且提供了一整套 AI 对话运行时,支持流式输出、工具调用和多种输入框模板,全部使用纯 SwiftUI 实现。

适合谁使用

  • 使用 SwiftUI 构建原生 macOS/iOS 界面的开发者
  • 希望在 SwiftUI 中使用 shadcn/ui 设计系统的开发者
  • 需要 Swift 原生 `useChat` 替代方案的 AI 聊天界面开发者
  • 在 SwiftUI 中构建节点图编辑器或画布 UI 的开发者

典型使用场景

  • 构建支持流式响应和工具调用的 AI 聊天界面
  • 创建遵循 shadcn 设计令牌和组件的 macOS/iOS 应用
  • 开发用于可视化编程或数据流的交互式节点图编辑器
  • 在演示或测试应用中展示 AI UI 组件

项目优势

  • 零外部依赖——纯 SwiftUI,不需要 UIKit 或 AppKit 桥接
  • 精确移植自 shadcn 和 AI SDK 官方注册表,保留了准确的样式细节(如 Tailwind 类细节、暗色模式覆盖)
  • 205 个单元测试重点覆盖高风险区域,如色彩空间转换、协议边界和流式处理边缘情况
  • 包含完整的 `AIChat` 运行时,支持流式输出、增量合并、工具结果原地更新以及用于预览/测试的模拟传输

使用前须知

  • Markdown 渲染不支持表格,语法高亮仅使用紧凑的词法标记器,并非每种语言的完整语法
  • 弹出框、下拉菜单、选择框等覆盖层在主题根节点处渲染,无法逃逸主题根节点之上有裁剪的祖先容器
  • 画布节点图缺少拖拽手柄创建连线、子流程、NodeResizer 以及撤销/重做功能

README 快速开始

ShadKit

A SwiftUI port of shadcn/ui and Vercel AI Elements, built to match the originals rather than approximate them. No dependencies — pure SwiftUI, macOS 14+ / iOS 17+.

Components were ported from the actual registry sources (ui.shadcn.com/r/styles/new-york-v4/*.json and registry.ai-sdk.dev), not from screenshots, so class-for-class details — the has-[>svg]:px-3 padding shift on buttons, dark:bg-input/30 on inputs, the ten-spoke loader's per-spoke opacity — carry across.

Products

LibraryContents
ShadcnUIDesign tokens + the shadcn primitives
AIElementsUIThe AI Elements set, plus a useChat-shaped runtime
CanvasUINode-graph canvas, ReactFlow-shaped
AIElementsGalleryA browsable showcase of everything
.package(url: "https://github.com/jasonkneen/ShadKit", from: "0.1.0")

Design tokens

shadcn publishes its tokens in OKLCH. OKLCH converts to sRGB via OKLab, so a theme can be pasted in verbatim:

OKLCH(css: "oklch(0.145 0 0)")          // #0A0A0A
OKLCH(0.577, 0.245, 27.325).hexString   // #E7000B

Apply a theme once near the root. Components below read the resolved palette for the current appearance:

ContentView()
    .shadcnSurface()                 // theme + the `background` token
    .shadcnTheme(myTheme)            // theme only

Custom themes are the same shape as a shadcn :root block — see ShadcnPaletteSpec. Space.x4 maps Tailwind's spacing scale to points (p-416), and theme.radius derives the whole radius scale from one --radius.

AI controls

AIConversation(streamToken: chat.streamToken) {
    ForEach(chat.messages) { AIMessageView(message: $0) }
}

AIReasoning(content: thinking, isStreaming: true)
AITool(name: "search_codebase", state: .outputAvailable) {
    AIToolInput(json: input)
    AIToolOutput(output: output)
}
AIResponse(markdown)                 // streaming-safe markdown
AICodeBlock(code: swift, language: "swift")

useChat parity

AIChat is the Swift counterpart to the AI SDK's useChat — same message shape (UIMessage / UIMessagePart), same ChatStatus, same verbs.

@StateObject private var chat = AIChat(transport: MyTransport())

AIChatbot(chat: chat, suggestions: ["Explain this repo"]) { text, status in
    AIPrompt

项目描述

SwiftUI port of shadcn/ui and Vercel AI Elements — design tokens, AI chat components, node canvas, diff viewer. No dependencies.

相关仓库与替代方案

根据分类、Topic 和编程语言匹配的相似项目。

yetone
精选
yetone GitHub avatar

kill-ai-slop

Kill AI Slop is a multilingual field guide and agent skill that catalogues 33 common AI-generated design tells with interactive before-after demos, and provides a tool to scan and fix web projects.

AI 与机器学习AI 智能体
805
Blaizzy
精选
Blaizzy GitHub avatar

nativ

Nativ is a native macOS app that lets you run AI models locally on Apple silicon, offering chat, model management, performance analytics, and an OpenAI/Anthropic-compatible API server.

AI 与机器学习AI 视觉与语音
985
uzairansaruzi
精选
uzairansaruzi GitHub avatar

hermex

Hermex is a native SwiftUI iPhone app that lets you control a self-hosted Hermes AI agent directly from your phone, with no subscriptions, tracking, or third-party relay.

AI 与机器学习大语言模型
941