Svelte Components

spences10/svelte-skills-kit/plugins/svelte-skills/skills/svelte-components

作者 spences102a9d88379bf62cee464a16db852edda7790a58f5無授權條款收錄於 2026年10月9日更新於 2026年10月9日

Svelte component patterns. Use for web components, component libraries (Bits UI, Ark UI, Melt UI), form patterns, or third-party integration.

AI 產生的概覽

關於 Svelte 元件模式的參考指南,涵蓋元件庫、Web Components 與表單處理。

功能
提供建構 Svelte 元件的快速參考說明,涵蓋 Bits UI、Ark UI、Melt UI 等無樣式元件庫、自訂元素設定以及表單模式。它指向三個參考檔案,分別涉及元件庫設定、Web Components 與進階表單處理。產出的是指引內容與程式碼片段,而非產生的檔案。
適用情境
適用於處理 Svelte 元件時,尤其是整合元件庫、建構自訂元素或處理表單模式。適合在 Svelte 前端開發過程中快速查閱。
執行需求
不需要指令碼或特殊工具,僅為說明與參考文件。套用這些模式時需具備 Svelte 專案環境。

Svelte Components

Quick Start

Component libraries: Bits UI (headless) | Ark UI | Melt UI (primitives)

Form trick: Use form attribute when form can't wrap inputs:

svelte
<form id="my-form" action="/submit"><!-- outside table --></form><table>	<tr>		<td><input form="my-form" name="email" /></td>		<td><button form="my-form">Submit</button></td>	</tr></table>

Web Components

javascript
// svelte.config.jsexport default {	compilerOptions: {		customElement: true,	},};
svelte
<!-- MyButton.svelte --><svelte:options customElement="my-button" />
<button><slot /></button>

Reference Files

  • component-libraries.md [blocked] - Bits UI, Ark UI setup
  • web-components.md [blocked] - Building custom elements
  • form-patterns.md [blocked] - Advanced form handling

Notes

  • Bits UI 1.0: flexible, unstyled, accessible components for Svelte
  • Form defaultValue attribute enables easy form resets
  • Use snippets to wrap rich HTML in custom select options
  • Last verified: 2025-01-14
<!-- PROGRESSIVE DISCLOSURE GUIDELINES: - Keep this file ~50 lines total (max ~150 lines) - Use 1-2 code blocks only (recommend 1) - Keep description <200 chars for Level 1 efficiency - Move detailed docs to references/ for Level 3 loading - This is Level 2 - quick reference ONLY, not a manual -->

來源與署名

來源:spences10/svelte-skills-kit位於plugins/svelte-skills/skills/svelte-components提交2a9d883

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架