Canvas Design System
Main Site Tokens

Modal

Dialogs, drawers, and bottom sheets for focused interactions. Supports multiple sizes and colored headers.

Basic Modal

<button data-modal-open="my-modal">Open</button>

<?php ws_modal_start(['id' => 'my-modal', 'title' => 'Modal Title']); ?>
    <p>Modal content here</p>
<?php ws_modal_end(); ?>

Sizes

Colored Header

<?php ws_modal_start([
    'id' => 'planner-modal',
    'title' => 'Save Workshop',
    'headerColor' => '#E54D4D'
]); ?>

JavaScript API

// Open a modal
wsModalOpen('my-modal');

// Close a modal
wsModalClose('my-modal');

Parameters

ParameterTypeDefaultDescription
idstringModal identifier (required, used by JS API)
titlestringHeader title text
sizestringdefaultsm | default | lg | full
headerColorstringnullCustom header background color (hex)
closeablebooltrueShow close button and allow ESC/backdrop close
classstring''Additional CSS classes on the dialog

Accessibility

The modal follows the WAI-ARIA Dialog (Modal) pattern.

ARIA Attributes

ElementAttributeValue
.ws-modal (backdrop)aria-hiddentrue when closed
.ws-modal__dialogroledialog
.ws-modal__dialogaria-modaltrue
.ws-modal__dialogaria-labelledbyID of the modal title element
.ws-modal__dialogaria-describedbyID of the modal body (optional)
.ws-modal__closearia-label"Close"

Keyboard Navigation

KeyBehavior
TabCycles focus through focusable elements inside the modal (focus trap)
Shift+TabMoves focus backwards through focusable elements (wraps to last)
EscapeCloses the modal and returns focus to the element that triggered it

Focus Management

Do: On open, focus moves to the first focusable element inside the modal (or the close button). A focus trap keeps Tab cycling within the modal. On close, focus returns to the trigger element that opened it. Background content receives aria-hidden="true" and inert to prevent interaction.
Don't: Don't allow focus to escape the modal while it's open. Don't use autofocus on form fields inside modals — this can disorient screen reader users. Instead, let focus land on the dialog or its first element naturally.