一键导入
component-builder
// Create UI components using tailwind-variants for type-safe styling. Use when creating or editing components in src/lib/ui/.
// Create UI components using tailwind-variants for type-safe styling. Use when creating or editing components in src/lib/ui/.
Patterns for building list and detail pages with forms, filters, and data fetching
Create SvelteKit components using Remote Functions for type-safe client-server communication. Use when building components that need to fetch data, submit forms, or execute server commands. Remote Functions work at the component level, not page level.
Create admin dashboard pages with tables, forms, and actions
Create Playwright E2E tests using Page Object Model pattern with database isolation
Demonstrates progressive disclosure by linking to reference files. Use this pattern when your skill has detailed content that should load on-demand.
A minimal example skill demonstrating the required structure. Use this as a template when creating new skills.
| name | component-builder |
| description | Create UI components using tailwind-variants for type-safe styling. Use when creating or editing components in src/lib/ui/. |
This skill documents the tailwind-variants pattern used for UI components in this project. All UI components should follow this pattern for consistency and type safety.
Use this skill when:
src/lib/ui/Every component needs two files:
componentName.variants.ts - Variant definitionsComponentName.svelte - The componentsrc/lib/ui/Button.svelte and src/lib/ui/button.variants.tssrc/lib/ui/Tag.svelte and src/lib/ui/tag.variants.tssrc/lib/ui/ContentCard.svelte and src/lib/ui/contentCard.variants.ts// componentName.variants.ts
import { tv, type VariantProps } from 'tailwind-variants'
export const componentVariants = tv({
base: 'common-classes-for-all-variants',
variants: {
variant: {
primary: 'classes-for-primary',
secondary: 'classes-for-secondary'
},
size: {
sm: 'text-sm px-2',
md: 'text-base px-4',
lg: 'text-lg px-6'
}
},
defaultVariants: {
variant: 'primary',
size: 'md'
}
})
// Export types for each variant dimension
export type ComponentVariant = VariantProps<typeof componentVariants>['variant']
export type ComponentSize = VariantProps<typeof componentVariants>['size']
<script lang="ts">
import type { ClassValue } from 'svelte/elements'
import { componentVariants, type ComponentVariant, type ComponentSize } from './componentName.variants'
type Props = {
variant?: ComponentVariant
size?: ComponentSize
class?: ClassValue
}
let { variant, size, class: className, ...rest }: Props = $props()
</script>
<div class={[componentVariants({ variant, size }), className]} {...rest}>
<!-- content -->
</div>
For on/off states like active, disabled, error:
variants: {
active: {
true: 'bg-svelte-100 border-svelte-300',
false: ''
},
error: {
true: 'border-red-300 bg-red-50',
false: 'border-transparent'
}
}
Apply styles only when specific combinations match:
compoundVariants: [
{
active: true,
removable: false,
class: 'hover:bg-svelte-200'
}
]
Always use array syntax to allow consumer overrides:
<div class={[componentVariants({ variant, size }), className]}>
For copy-paste templates, see TEMPLATES.md.