Colour theme

Modal

  • Regions

Any content as a modal, without the content knowing it is in one. The modal gives it the top layer, a locked page, Esc and focus returned. The content names and closes it with attributes — data-channel="title", "description", "close" — no id, any framework.

An alert

Closed only by an answer.

Delete everything?

astro
<ActionButton intent="destructive" command="show-modal" commandfor="delete">Delete everything</ActionButton>

<Modal id="delete" role="alertdialog" dismiss="none">
  <Card padding="none" style="justify-self: center">
    <div style="padding: var(--size-2xl) var(--site-offset)">
      <Heading text="Delete everything?" data-channel="title" />
      <ActionButton intent="destructive" data-channel="close" value="delete">Delete</ActionButton>
      <ActionButton emphasis="secondary" data-channel="close" value="cancel">Cancel</ActionButton>
    </div>
  </Card>
</Modal>

Long content

The modal scrolls, the page does not. A click beside the content closes it.

Terms

Section 1. Long enough to be taller than the window.

Section 2. Long enough to be taller than the window.

Section 3. Long enough to be taller than the window.

Section 4. Long enough to be taller than the window.

Section 5. Long enough to be taller than the window.

Section 6. Long enough to be taller than the window.

Section 7. Long enough to be taller than the window.

Section 8. Long enough to be taller than the window.

Section 9. Long enough to be taller than the window.

Section 10. Long enough to be taller than the window.

Section 11. Long enough to be taller than the window.

Section 12. Long enough to be taller than the window.

Section 13. Long enough to be taller than the window.

Section 14. Long enough to be taller than the window.

Section 15. Long enough to be taller than the window.

Section 16. Long enough to be taller than the window.

Section 17. Long enough to be taller than the window.

Section 18. Long enough to be taller than the window.

Section 19. Long enough to be taller than the window.

Section 20. Long enough to be taller than the window.

astro
<ActionButton emphasis="secondary" command="show-modal" commandfor="terms-of-use">Read the terms</ActionButton>

<Modal id="terms-of-use" dismiss="any">
  <Card padding="none" style="justify-self: center">
    <div style="padding: var(--size-2xl) var(--site-offset)">
      <Heading text="Terms" data-channel="title" />
      {Array.from({ length: 20 }, (_, i) => <Text text={`Section ${i + 1}. Long enough to be taller than the window.`} />)}
      <ActionButton data-channel="close" value="read">Done</ActionButton>
    </div>
  </Card>
</Modal>

A drawer

The content places itself; the modal has no placement.

Filters

astro
<ActionButton emphasis="secondary" command="show-modal" commandfor="filters">Filters</ActionButton>

<Modal id="filters" dismiss="any">
  <Card padding="none" style="justify-self: end; align-self: stretch; inline-size: 24rem">
    <div style="padding: var(--size-2xl) var(--site-offset)">
      <Heading text="Filters" data-channel="title" />
      <ActionButton emphasis="secondary" data-channel="close" value="done">Done</ActionButton>
    </div>
  </Card>
</Modal>

Its name keeps the content's language

The modal owns no words; its name is the content's title, in the title's language.

Välkommen tillbaka

astro
<ActionButton emphasis="secondary" command="show-modal" commandfor="welcome">Open in Swedish</ActionButton>

<Modal id="welcome">
  <Card padding="none" style="justify-self: center" lang="sv">
    <div style="padding: var(--size-2xl) var(--site-offset)">
      <Heading text="Välkommen tillbaka" data-channel="title" />
      <ActionButton data-channel="close" value="ok">Stäng</ActionButton>
    </div>
  </Card>
</Modal>

Every case, measured, is on the test bench.