Modal

An overlaying window to take focus away from the current context.

Preview
Code

Basic Example

<script>
	import { Modal, ModalBackdrop, ModalContent, ModalDescription, ModalTitle, ModalTrigger } from 'lithesome';
</script>

<Modal>
	<ModalTrigger>Click me</ModalTrigger>

	<ModalBackdrop />
	<ModalContent>
		<ModalTitle>Modal Title</ModalTitle>
		<ModalDescription>Modal Description</ModalDescription>
	</ModalContent>
</Modal>

API Reference

<Modal />

PropertyTypeDescription
closeOnBackdropClick boolean

Allows the backdrop to close the modal if the user clicks on it.

children Snippet<[ S extends Record<string, any> ? S : never ]>

The default snippet to render.

StateTypeDescription
visiblebooleanTrue if the contents are visible.

<ModalTrigger />

PropertyTypeDescription
ref E

The reference to the underlying element.

children Snippet<[ S extends Record<string, any> ? S : never ]>

The default snippet to render.

custom Snippet<[ S extends Record<string, any> ? { props: P; state: S; } : { props: P; } ]>

Snippet to be used when wanting a custom implementation. This will tell Lithesome not the render the default element and any state along with it.

StateTypeDescription
visiblebooleanTrue if the contents are visible.

<ModalBackdrop />

PropertyTypeDescription
ref E

The reference to the underlying element.

children Snippet<[ S extends Record<string, any> ? S : never ]>

The default snippet to render.

custom Snippet<[ S extends Record<string, any> ? { props: P; state: S; } : { props: P; } ]>

Snippet to be used when wanting a custom implementation. This will tell Lithesome not the render the default element and any state along with it.

StateTypeDescription
visiblebooleanTrue if the contents are visible.

<ModalContent />

PropertyTypeDescription
ref E

The reference to the underlying element.

children Snippet<[ S extends Record<string, any> ? S : never ]>

The default snippet to render.

custom Snippet<[ S extends Record<string, any> ? { props: P; state: S; } : { props: P; } ]>

Snippet to be used when wanting a custom implementation. This will tell Lithesome not the render the default element and any state along with it.

StateTypeDescription
visiblebooleanTrue if the contents are visible.

<ModalTitle />

PropertyTypeDescription
ref E

The reference to the underlying element.

children Snippet<[ S extends Record<string, any> ? S : never ]>

The default snippet to render.

custom Snippet<[ S extends Record<string, any> ? { props: P; state: S; } : { props: P; } ]>

Snippet to be used when wanting a custom implementation. This will tell Lithesome not the render the default element and any state along with it.

<ModalDescription />

PropertyTypeDescription
ref E

The reference to the underlying element.

children Snippet<[ S extends Record<string, any> ? S : never ]>

The default snippet to render.

custom Snippet<[ S extends Record<string, any> ? { props: P; state: S; } : { props: P; } ]>

Snippet to be used when wanting a custom implementation. This will tell Lithesome not the render the default element and any state along with it.