shadcn-svelte について
Bits UIとTailwind CSSを基盤とする、Svelte 5およびSvelteKit向けのshadcn/ui移植コンポーネントライブラリです。アクセシブルなUIコンポーネントに加え、セットアップ、フォーム、テーマ、利用方法のドキュメントを提供します。
主な機能
- 01Svelte 5とSvelteKit向けコンポーネント
- 02アクセシブルなUIコンポーネント
- 03Bits UIとTailwind CSS
- 04CLIによるコンポーネント導入
- 05フォームとテーマのガイド
活用シーン
- 01SvelteKitのインターフェースを構築
- 02ダイアログ、ボタン、カードを追加
- 03バリデーション付きフォームを実装
- 04テーマとダークモードを設定
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ antstanley/ shadcn-svelte-skill --skill shadcn-svelteインストール後、Claude Code で/shadcn-svelteを入力して読み込まれたか確認します。
同梱ファイル
SKILL.md と一緒にインストールされる参考資料やスクリプト。
references/about.mdchangelog.mdcli.mdcomponents-json.mdreferences/components/accordion.mdalert-dialog.mdalert.mdaspect-ratio.mdavatar.mdbadge.mdbreadcrumb.mdbutton-group.mdbutton.mdcalendar.mdcard.mdcarousel.mdchart.mdcheckbox.mdcollapsible.mdcombobox.mdcommand.mdcontext-menu.mddata-table.mddate-picker.mddialog.mddrawer.mddropdown-menu.mdempty.mdfield.mdform.md詳細
shadcn-svelte
shadcn/ui を Svelte 5 / SvelteKit 向けに移植したもので、Bits UI と Tailwind CSS を使って、美しくデザインされたアクセシブルなコンポーネントを提供します。
クイックスタート
インストール
# SvelteKit
pnpm dlx shadcn-svelte@latest init
# Add components
pnpm dlx shadcn-svelte@latest add button card dialog
基本的な使い方
コンポーネントは名前空間インポートを使います。
<script lang="ts">
import * as Card from "$lib/components/ui/card/index.js";
import { Button } from "$lib/components/ui/button/index.js";
</script>
<Card.Root>
<Card.Header>
<Card.Title>Title</Card.Title>
<Card.Description>Description</Card.Description>
</Card.Header>
<Card.Content>Content here</Card.Content>
<Card.Footer>
<Button>Action</Button>
</Card.Footer>
</Card.Root>
主なパターン
コンポーネントのインポートパターン
import * as Dialog from "$lib/components/ui/dialog/index.js";
import { Button } from "$lib/components/ui/button/index.js";
import { Input } from "$lib/components/ui/input/index.js";
フォームの実装
フォームには Superforms と Formsnap を使います。
<script lang="ts">
import * as Form from "$lib/components/ui/form/index.js";
import { superForm } from "sveltekit-superforms";
let { data } = $props();
const form = superForm(data.form);
</script>
<form method="POST" use:form.enhance>
<Form.Field {form} name="email">
<Form.Control>
{#snippet children({ props })}
<Input {...props} type="email" />
{/snippet}
</Form.Control>
<Form.FieldErrors />
</Form.Field>
</form>
ダークモード
<script lang="ts">
import { ModeWatcher } from "mode-watcher";
</script>
<ModeWatcher />
{@render children()}
mode-watcher の toggleMode()、setMode("dark")、または resetMode() で切り替えます。
リファレンスドキュメント
詳細なドキュメントは references/ にまとめられています。
- 概要:
about.md、cli.md、components-json.md、theming.md - インストール:
installation/sveltekit.md、installation/astro.md、installation/vite.md - コンポーネント:
components/[name].md— 59 件のコンポーネントガイド - ダークモード:
dark-mode/svelte.md、dark-mode/astro.md - 移行:
migration/svelte-5.md、migration/tailwind-v4.md - レジストリ:
registry/getting-started.md— カスタムレジストリの作成
コンポーネントのドキュメントを探す
コンポーネントのドキュメントを確認するには、references/components/[component-name].md を参照してください。
- Button →
references/components/button.md - Dialog →
references/components/dialog.md - Data Table →
references/components/data-table.md
よくあるタスク
| タスク | リファレンス |
|---|---|
| コンポーネントを追加する | pnpm dlx shadcn-svelte@latest add [name] |
| フォームのバリデーション | references/components/form.md |
| データテーブル | references/components/data-table.md |
| テーマ/カラー | references/theming.md |
| ダークモード | references/dark-mode/svelte.md |
| カスタムレジストリ | references/registry/getting-started.md |
コメント
Markdown 対応