Skip to content

Modal

The modal component.

Importing

ts
import "@tapsioss/web-components/modal";
ts
import { Modal } from "@tapsioss/react-components/Modal";

Component Usage

html
<tapsi-modal></tapsi-modal>
tsx
<Modal />

Properties

NameDescriptionTypeDefault Value
openIndicates whether the modal is open or not.booleanfalse
headingSets the title of the modal.string""
descriptionSets the description text for the modal.string""
alignmentDetermines the alignment of the modal's content."start" | "center""start"

Slots

NameDescription
imageThe slot for imagery element.
action-barThe slot for actionbar element.

TIP

You can use slot names as variables:

ts
import { Slots } from "@tapsioss/web-components/modal";

console.log(Slots.IMAGE); // "image"
console.log(Slots.ACTION_BAR); // "action-bar"
ts
import { ModalSlots } from "@tapsioss/react-components";

console.log(ModalSlots.IMAGE); // "image"
console.log(ModalSlots.ACTION_BAR); // "action-bar"

Events

NameDescriptionType
showFires when the modal should be visible. (Cancelable)ShowEvent
hideFires when the modal should be hidden. (Cancelable)HideEvent

TIP

You can import custom event names:

ts
import { 
  ShowEvent,
  HideEvent
} from "@tapsioss/web-components/modal";

element.addEventListener(ShowEvent.type, handleTapsiModalShow);
element.addEventListener(HideEvent.type, handleTapsiModalHide);
tsx
import { 
  ModalShowEvent,
  ModalHideEvent
} from "@tapsioss/react-components";


// ...

<Modal
  onShowEvent={(e: ModalShowEvent) => {...}}
  onHideEvent={(e: ModalHideEvent) => {...}}
/>