Skip to content

Types

Every type the package exports, printed from the source. The prop tables link here whenever a prop is typed as one of them, so variant?: ButtonVariant is one click away from the six strings it allows.

You rarely need to import any of these. Props are inferred, and the union types exist so your editor can finish the string for you. Import them when you are passing values around: a SelectOption[] coming out of a load function, or your own wrapper component that forwards a variant.

Component types

AlertVariant

components/feedback/Alert.svelte
export type AlertVariant = 'neutral' | 'accent' | 'success' | 'warning' | 'danger' | 'info';

BadgeVariant

components/primitives/Badge.svelte
export type BadgeVariant =
	'neutral' | 'accent' | 'success' | 'warning' | 'danger' | 'info' | 'outline';

ButtonSize

components/primitives/Button.svelte
export type ButtonSize = 'sm' | 'md' | 'lg' | 'icon' | 'icon-sm';

ButtonVariant

components/primitives/Button.svelte
export type ButtonVariant = 'solid' | 'soft' | 'outline' | 'ghost' | 'link' | 'danger';

Command

components/overlays/CommandPalette.svelte
export interface Command {
	id: string;
	label: string;
	/** Commands with the same group are listed under one heading. */
	group?: string;
	/** Shown on the right, usually a shortcut. */
	hint?: string;
	/** Extra words that should find this command. */
	keywords?: string[];
	icon?: Snippet;
	disabled?: boolean;
	onselect: () => void;
}

Crumb

components/navigation/Breadcrumb.svelte
export interface Crumb {
	label: string;
	href?: string;
}

SegmentedOption

components/forms/SegmentedControl.svelte
export interface SegmentedOption {
	value: string;
	label: string;
	disabled?: boolean;
}

SelectOption

components/forms/Select.svelte
export interface SelectOption {
	value: string;
	label: string;
	disabled?: boolean;
}

TabsVariant

components/navigation/Tabs.svelte
export type TabsVariant = 'line' | 'pill';

TerminalLine

components/effects/Terminal.svelte
export interface TerminalLine {
	/** `command` lines are typed after the prompt; `output` lines appear whole. */
	kind?: 'command' | 'output';
	text: string;
	tone?: 'default' | 'muted' | 'success' | 'accent' | 'warning' | 'danger';
	/** Pause before this line, in milliseconds. Overrides `lineDelay`. */
	delay?: number;
}

TriggerAttrs

components/overlays/Popover.svelte
export interface TriggerAttrs {
	onclick: (event: MouseEvent) => void;
	'aria-expanded': boolean;
	'aria-haspopup': 'dialog' | 'menu';
}

Theme and toasts

Accent

state/theme.svelte.ts
export type Accent = (typeof accents)[number] | (string & {});

export const accents = ['plum', 'cobalt', 'pine', 'ember', 'gold', 'ink'] as const;

ThemeMode

state/theme.svelte.ts
export type ThemeMode = 'light' | 'dark' | 'system';

Toast

state/toast.svelte.ts
export interface Toast extends ToastOptions {
	id: string;
	title: string;
	variant: ToastVariant;
	duration: number;
}

export interface ToastOptions {
	title?: string;
	description?: string;
	variant?: ToastVariant;
	/** Milliseconds before it dismisses itself. `0` keeps it until dismissed. */
	duration?: number;
	action?: { label: string; onclick: () => void };
}

export type ToastVariant = 'default' | 'success' | 'warning' | 'danger' | 'info';

ToastOptions

state/toast.svelte.ts
export interface ToastOptions {
	title?: string;
	description?: string;
	variant?: ToastVariant;
	/** Milliseconds before it dismisses itself. `0` keeps it until dismissed. */
	duration?: number;
	action?: { label: string; onclick: () => void };
}

export type ToastVariant = 'default' | 'success' | 'warning' | 'danger' | 'info';

ToastVariant

state/toast.svelte.ts
export type ToastVariant = 'default' | 'success' | 'warning' | 'danger' | 'info';

Actions

ClickOutsideParams

actions/clickOutside.ts
export type ClickOutsideParams =
	| Handler
	| {
			handler: Handler;
			/** Presses inside these elements do not count as outside. */
			ignore?: (HTMLElement | null | undefined)[];
	  };

type Handler = (event: PointerEvent) => void;

Helpers

AnchorParams

utils/anchor.ts
export interface AnchorParams {
	/** The element the panel should sit next to. */
	to: HTMLElement | null | undefined;
	placement?: Placement;
	/** Gap between anchor and panel, in pixels. */
	offset?: number;
	/** Minimum distance to the viewport edge. */
	padding?: number;
}

export type Placement =
	'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'right';

ClassValue

utils/cn.ts

Re-exported unchanged from clsx.

export type { ClassValue } from 'clsx';

ConfettiOptions

utils/confetti.ts
export interface ConfettiOptions {
	/** Where the burst starts: an element's centre, or a point in viewport pixels. */
	origin?: HTMLElement | { x: number; y: number };
	/** Number of pieces. */
	count?: number;
	/** Width of the cone, in degrees. */
	spread?: number;
	/** Middle of the cone, in degrees: -90 is straight up, 0 is to the right. */
	angle?: number;
	/** Launch speed; around 10 clears a button, 16 clears the screen. */
	velocity?: number;
	/** How hard the pieces fall. Below 1 they hang about, above 1 they drop. */
	gravity?: number;
	/** Size of the pieces, as a multiplier. */
	scale?: number;
	/** CSS colours. Defaults to the theme's accent and status colours. */
	colors?: string[];
	/** Milliseconds until every piece has faded. */
	duration?: number;
}

Placement

utils/anchor.ts
export type Placement =
	'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'right';

cock. Yes, it stands for core component kit. We checked twice.