Desktop components

Modals

Desktop modals in Puppertino are compact alert dialogs for pointer-driven interfaces: a translucent glass body, 260px width, 34px radius, and pill actions arranged either as a vertical stack or a horizontal pair.

When to use them

Use them for short confirmation moments, destructive warnings, and small decision points. Avoid them for large forms, long reading flows, or anything that needs a lot of scrolling.

Preview

Desktop modals use two layouts. Stacked handles three actions. Split handles two.

Variants

Two alert layouts are available:

Anatomy

ClassRole
.p-modal-backgroundShared backdrop layer for all modals on the page.
.p-modalBase modal hook used by the JS manager.
.p-desktop-modalDesktop alert shell. Centers the modal and handles the open transition.
.p-desktop-modal__surfaceGlass surface. Radius 34, keyline, inner top and bottom highlight, and shadow.
.p-desktop-modal__bodyTitle and description group.
.p-desktop-modal__actionsAction row or stack.
.p-desktop-modal__actionShared pill button styling for alert actions.
.p-desktop-modal__action--primaryFilled affirmative action.
.p-desktop-modal__action--secondaryNeutral cancel action.
.p-desktop-modal__action--destructiveDestructive action with red tint.

Usage

The trigger uses data-p-open-modal with the selector of the modal you want to open. Add data-p-close-on-outside="true" if clicking the backdrop should dismiss it, and add data-p-cancel to any action that should close the active modal automatically.

<button class="p-button p-button-primary" data-p-open-modal="#example-modal">
  Open Alert
</button>

<div class="p-modal-background">
  <div
    class="p-modal p-desktop-modal p-desktop-modal--split"
    id="example-modal"
    data-p-close-on-outside="true"
    role="dialog"
    aria-modal="true"
    aria-hidden="true"
    aria-labelledby="example-modal-title"
  >
    <div class="p-desktop-modal__surface">
      <div class="p-desktop-modal__body">
        <h2 class="p-desktop-modal__title" id="example-modal-title">
          Save this message as a draft?
        </h2>
        <p class="p-desktop-modal__description">
          This message has not been sent and<br />
          contains unsaved changes. You can save<br />
          it as a draft to work on later.
        </p>
      </div>
      <div class="p-desktop-modal__actions">
        <button class="p-desktop-modal__action p-desktop-modal__action--secondary" data-p-cancel>
          Cancel
        </button>
        <button class="p-desktop-modal__action p-desktop-modal__action--primary">
          Save
        </button>
      </div>
    </div>
  </div>
</div>

Action layout

Use the stacked variant when you need three clear outcomes. Order the actions primary first, destructive second, and cancel last.

<div class="p-desktop-modal__actions">
  <button class="p-desktop-modal__action p-desktop-modal__action--primary">Save</button>
  <button class="p-desktop-modal__action p-desktop-modal__action--destructive">Don’t Save</button>
  <button class="p-desktop-modal__action p-desktop-modal__action--secondary" data-p-cancel>Cancel</button>
</div>

Use the split variant when the choice is binary.

<div class="p-desktop-modal__actions">
  <button class="p-desktop-modal__action p-desktop-modal__action--secondary" data-p-cancel>Cancel</button>
  <button class="p-desktop-modal__action p-desktop-modal__action--primary">Save</button>
</div>

JavaScript API

The modal manager initializes automatically when src/js/modals.js is loaded.

PuppertinoModalManager.openModal("#example-modal");
PuppertinoModalManager.closeActiveModal();
PuppertinoModalManager.closeModal("#example-modal");
PuppertinoModalManager.isModalOpen("#example-modal");

Surface

The alert is one glass surface with a keyline, an inner highlight and a soft shadow.

PartValue
Fillrgba(247, 247, 247, 0.73) over a 30px blur
Keyline0.5px dark, just outside the edge
HighlightBright 1px line inside the top and bottom edges, fading into a soft glow about 8px deep. The sides get the keyline only.
Shadow0 18px 48px at 25%
Radius34px, a plain arc

Spacing inside the alert is fixed.

PartValue
Body inset20px from the top, 16px from the sides and bottom
Message to first action16px
Stacked actions28px tall, 6px apart
Side-by-side actions32px tall, 8px apart

The primary action is the control accent, Cancel is a quiet fill, and destructive uses the vibrant red because it sits on glass.

PartLightDark
Primary#0088FF#0091FF
CancelBlack at 10%White at 8.5%
Destructive#F52F32 at 23% behind a #E11B1E label#FF4747 at 23% behind a #FF4747 label

Any .p-button you place inside the alert is vibrant too (see Buttons).

Dark mode

The surface turns into a near-black glass, rgba(26, 26, 26, 0.9), with a darker keyline and a dimmer inner highlight (white at 20%). The shadow deepens to 45%.

Accessibility

Notes

Copied