Utility

Modals

High priority dialogs and modals using a dynamic queue system.

typescript
import { Modal, modalStore } from '@skeletonlabs/skeleton';
import type { ModalSettings, ModalComponent } from '@skeletonlabs/skeleton';
Source Page Source WAI-ARIA

Demo

Modal Store

When you wish to trigger a modal, import the modalStore, which acts as the modal queue.

typescript
import { modalStore } from '@skeletonlabs/skeleton';

Trigger

The title, body, and image are available to all modals.

Close

Trigger the close() method to remove the first modal in the modal queue.

typescript
modalStore.close();

Clear

Trigger the clear() method completely empty the modal queue.

typescript
modalStore.clear();

Modal Settings

These additional settings are available to all modals.

typescript
const d: ModalSettings = {

	// Provide abitrary classes to the backdrop and modal elements:
	backdropClasses: '!bg-green-500',
	modalClasses: '!bg-red-500',

	// Provide arbitrary metadata to your modal instance:
	meta: { foo: 'bar', fizz: 'buzz', fn: myCustomFunction }

};

Component Modals

Advanced

To create custom modals, generate a new component, then pass this to the Modal system.

See the additional information below to learn how to use custom component modals.

Import and use the modalStore. All provide data is available within your component via $modalStore[0].

Accessibility

Skeleton does not provide a means to disable the backdrop's click to close feature, as this would be harmful to accessability. View the ARIA APG guidelines to learn more about modal accessability.