Skip to content
Content Blocks docsv0.8.0Website

Docs / Components

<content-overlay>

A dialog that opens over the page, or inside another element, and keeps keyboard focus inside it while open.

Import it on its own, for a bundler
import '@content-blocks/js/components/content-overlay';

Examples

A dialog

A button whose href points at the overlay opens it. Focus stays inside until it closes.

Open on its own
Read the prophecy The prophecy

Anatomy

Content goes into the component's slots, chosen with the slot attribute on each child.

flowchart LR
  root["#lt;content-overlay#gt;"]:::component
  root --> s0["<b>no slot (default)</b><br/>The default slot"]
  root --> s1["<b>slot=#quot;closeButton#quot;</b><br/>Contents of the overlay close button."]
  root --> s2["<b>slot=#quot;content#quot;</b><br/>Contents that sit inside the overlay."]
  root --> s3["<b>slot=#quot;header#quot;</b><br/>This is adjacent to the close button, usually a header or title for t…"]
  classDef component fill:#141413,color:#faf9f5,stroke:#141413
The slots of <content-overlay>
SlotWhat goes in it
(default)The default slot
slot="closeButton"Contents of the overlay close button.
slot="content"Contents that sit inside the overlay.
slot="header"This is adjacent to the close button, usually a header or title for the overlay.

Properties

Set them as attributes. Those marked responsive take a value per breakpoint, separated by pipes and named or in order: 1|tablet=2 or 1|2. Seeresponsive values.

AttributeTypeDefaultDescription
classesresponsiveString–Classes to add to the component. Use pipes for different classes per breakpoint, by name or in order: classes="stacked|laptop=side-by-side".
close-titleString'Close Overlay'Title attribute value for the close button.
fillresponsiveString'body'What the overlay covers. "body", the default, covers the whole screen. A CSS selector, such as "#hero", covers that element instead: the overlay moves into it when it opens. Use pipes to cover the screen on phones and an element on wider screens: fill="body|#hero".
full-screenresponsiveBoolean'true'Not documented yet
horizontalresponsiveSelect

default · left · center · right

'center'A pipe delimited setting for horizontal alignment. This only applies when fullscreen mode is activated.
labelString–The accessible name of the dialog. Only needed when there is no header slot, which names it otherwise.
openresponsiveBoolean'false'Not documented yet
paddingresponsiveString–Padding around the component, written as CSS padding. Use pipes for different padding per breakpoint, by name or in order: padding="1rem|tablet=2rem 4rem" or padding="1rem|2rem 4rem|3rem 5rem 4rem".
verticalSelect

top · center · bottom

'center'A pipe delimited setting for vertical alignment. This only applies when fullscreen mode is activated.

Events and methods

sequenceDiagram
  participant Page
  participant C as content-overlay
  Page->>C: toggle event
  Page->>C: open event
  Page->>C: close event
  Page->>C: closeOverlay()
  Page->>C: openOverlay()
  C-->>Page: contentOverlayActivated
  C-->>Page: contentOverlayDeactivated
What <content-overlay> listens for and what it tells the page
EventDetailDescription
contentOverlayActivatedHTMLElementNot documented yet
contentOverlayDeactivatedHTMLElementNot documented yet
MethodDescription
closeOverlay() => Promise<void>Not documented yet
openOverlay() => Promise<void>Not documented yet