Components

Canvas

A themed native canvas primitive.

Props

Native attributes and event handlers are forwarded to the underlying canvas element unless handled by the component.

PropTypeDefaultDescription
children Snippet undefined Content snippet rendered by the component.
class string '' Tailwind classes merged with the theme and variants.
element HTMLCanvasElement | null null Bindable reference to the underlying DOM element.
inTransition TransitionProps undefined Overrides the opening transition.
isVisible boolean true Bindable visibility state.
outTransition TransitionProps undefined Overrides the closing transition.
theme Theme global theme Optional local theme override.
transition TransitionProps [noopTransition, {}] A Svelte transition function and its options.
variants string[] [] Local variant names or theme references such as button.base.

Default usage

Import Canvas from sveltewind/components. This example shows its default styling in a usable context.

Canvas drawing area.
+page.svelte
Loading...

Bind element to access the drawing context. Width and height attributes control bitmap resolution; CSS controls display size.

Examples

Theme variants

Every variant available for Canvas in the built-in themes is shown below.

bordered — Apply the bordered variant.

Canvas drawing area.
+page.svelte
Loading...

responsive — Apply the responsive variant.

Canvas drawing area.
+page.svelte
Loading...

rounded — Apply the rounded variant.

Canvas drawing area.
+page.svelte
Loading...

Class overrides

Apply rounded-xl border-2 border-primary-500/50 shadow-md locally.

Canvas drawing area.
+page.svelte
Loading...

Props and behavior

Change width, height while retaining the default component styling.

Canvas drawing area.
+page.svelte
Loading...

Content and values

Provide different aria-label values.

Canvas drawing area.
+page.svelte
Loading...