Svelte Component
Create new Svelte components with best practices, TypeScript support, and testing
Before you use this component
This is a third-party source bundle, not an installation into your account. UI Discovery has checked the available redistribution license evidence; runtime behavior has not been tested. Review all files, use a disposable project first, and do not enable scripts or hooks until you understand their permissions.
Some integrations require separately installed software, API keys or paid services. Credentials and subscriptions are not included. These are Claude Code resources; other clients may require adaptation.
Extract the ZIP into a temporary folder, inspect its entry file and supporting resources, then follow the original instructions. Do not overwrite an existing project configuration blindly. Keep the bundled license and attribution notices.
- Source publisher
- Claude Code Templates
- Creator supplied by source
- Not listed in source
- Pinned source version
- a344359459263d73d8948651c789244093c02e4e
- License evidence
- LICENSE
Source preview
cli-tool/components/commands/svelte/svelte-component.md
---
allowed-tools: Read, Write, Edit
argument-hint: [component-name] [--typescript] [--story]
description: Create new Svelte components with best practices, TypeScript support, and testing
---
# Create Svelte Component
Create new Svelte component: $ARGUMENTS
## Current Svelte Project
- Svelte config: @svelte.config.js or @vite.config.js (if exists)
- Components directory: @src/components/ or @src/lib/ (if exists)
- TypeScript config: @tsconfig.json (detect TypeScript usage)
- Testing setup: @vitest.config.js or @jest.config.js (if exists)
## Task
Create Svelte component with best practices. When creating components:
1. **Gather Requirements**:
- Component name and purpose
- Props interface
- Events to emit
- Slots needed
- State management requirements
- TypeScript preference
2. **Component Structure**:
```svelte
<script lang="ts">
// Imports
// Type definitions
// Props
// State
// Derived values
// Effects
// Functions
</script>
<!-- Markup -->
<style>
/* Scoped styles */
</style>
```
3. **Best Practices**:
- Use proper prop typing with TypeScript/JSDoc
- Implement $bindable props where appropriate
- Create accessible markup by default
- Add proper ARIA attributes
- Use semantic HTML elements
- Include keyboard navigation support
4. **Component Types to Create**:
- **UI Components**: Buttons, Cards, Modals, etc.
- **Form Components**: Inputs with validation, custom form controls
- **Layout Components**: Headers, Sidebars, Grids
- **Data Components**: Tables, Lists, Data visualizations
- **Utility Components**: Portals, Transitions, Error boundaries
5. **Additional Files**:
- Create accompanying test file
- Add Storybook story if applicable
- Create usage documentation
- Export from index file
## Example Usage
User: "Create a Modal component with customizable header, footer slots, and close functionality"
Assistant will:
- Create Modal.svelte with proper structure
- Implement focus trap and keyboard handling
- Add transition effects
- Create Modal.test.js with basic tests
- Provide usage examples
- Suggest accessibility improvementsPreview capped at 60,000 characters. Download the bundle for every original file and notice.
Read the redistribution license
MIT License Copyright (c) 2025 Daniel (San) Ávila Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Bundle SHA-256: 893d6c065dd927500d88c0c05b0582ecc0a73cb1739d4a34ef030b0ff9f7e09c. Files are served as downloads and are never executed by this page.