<script> block and pass its output to the class attribute. Use $$props.class to forward any extra classes passed by the consumer.
Installation
Button component
A complete Svelte button component using CVA with scoped CSS:button.svelte
In Svelte, set default variant values directly on the exported props rather than in
defaultVariants. This follows Svelte’s idiomatic prop pattern where exported props default to undefined. The $$Props interface uses Omit<VariantProps<typeof button>, 'disabled'> to avoid conflicting with Svelte’s native HTMLButtonAttributes disabled type.Forwarding class from the consumer
To support consumers passing extra classes via class="...", use $$props.class when calling the CVA function:
{...$$props} first and then explicitly setting class ensures the CVA-generated class string takes precedence over the raw class prop in $$props.
Consuming the component
App.svelte
