Create a new Svelte 5 component following project patterns (shadcn-svelte, Tailwind, runes). Use for UI features.
Create a new Svelte 5 component: $ARGUMENTS
src/lib/components/ for similar patternssrc/lib/components/ui/ — reuse base components$props()<script lang="ts">
import { Button } from '$lib/components/ui/button';
import type { ComponentProps } from '$lib/types';
interface Props {
title: string;
variant?: 'default' | 'destructive';
disabled?: boolean;
onaction?: (id: string) => void;
}
let { title, variant = 'default', disabled = false, onaction }: Props = $props();
let loading = $state(false);
const derivedClass = $derived(
variant === 'destructive' ? 'border-red-500' : 'border-border'
);
async function handleClick() {
loading = true;
try {
onaction?.('some-id');
} finally {
loading = false;
}
}
</script>
<div class="rounded-lg border {derivedClass} p-4">
<h3 class="text-sm font-medium">{title}</h3>
<Button {disabled} onclick={handleClick}>
{#if loading}
Loading...
{:else}
Action
{/if}
</Button>
</div>
$state(), $derived(), $effect() — NOT old Svelte 4 syntax ($:, let x = ...)$props() — NOT export letonclick — NOT on:click{#snippet} — NOT <slot>*.svelte.ts files if neededButton, Card, Dialog, etc.)lucide-svelte