AI summary by TwinMind

How was this not in the browser before???

Theo - t3․gg

16m 30s

Popover API Introduction

  • Popover API just landed in Baseline 2024, replacing need for JavaScript solutions like Popper
  • Popper was tooltip/popover positioning engine for hover tooltips, scroll-aware positioning
  • Common problem: overflow property conflicts when element has scrollable content
    • Setting overflow-y automatically affects overflow-x behavior
    • Tool tips get clipped or cause horizontal scrolling issues
    • CSS overflow behaviors: if x=hidden, y also becomes hidden regardless of settings

JavaScript Solutions vs Native Browser Support

  • Popper solved positioning via JavaScript, adjusting positions and rendering at different layers
  • NPM trends show Popper has half of React's installs, more common than Vue
  • Demonstrates how critical this functionality is for web development
  • Popover API provides native browser behaviors, eliminating need for JavaScript libraries

Core Popover API Features

  • Top layer promotion: Popovers appear above rest of page, no Z-index management needed
    • Top layer sits above related document in browser viewport
    • Each document has one associated top layer
    • Solves Z-index: 10,000 problem permanently
  • Light dismiss functionality: Clicking outside popover automatically closes it and returns focus
  • Default focus management: Opening popover makes next tab stop inside popover
  • Accessible keyboard bindings: Escape key or double toggling closes popover and returns focus
  • Accessible component design: Semantic connection between popover element and trigger

Basic Implementation

  • Simple HTML attributes approach:
    • Set popover attribute on element that will be popover
    • Add unique ID to popover element
    • Set button's popover-target to value of popover element's ID
  • React compatibility issue: Use popover="true" (string) instead of boolean
  • Includes built-in animations with CSS pseudo-classes for open/closed states

Popover Types and Behaviors

  • Auto popover (default): popover or popover="auto"
    • Enables light dismiss behaviors
    • Automatically closes other popovers when opened
  • Manual popover: popover="manual"
    • Requires explicit close button
    • Doesn't close other popovers
    • No light dismiss - must use close button
    • Uses popover-target-action="hide" for close functionality
  • Hint popover: popover="hint" (discussed but not yet implemented)
    • Would enable popovers that don't close other popovers
    • Still allows light dismiss
    • Useful for tooltips and ephemeral interfaces

Popover vs Modal Dialog Comparison

  • Dialog element:
    • Opens with dialog.showModal(), closes with dialog.close()
    • Makes rest of page inert
    • No light dismiss support
    • Style open state with :open attribute
    • Represents interactive component blocking page interactions
    • Has problematic default margins and behaviors
  • Popover element:
    • Declarative invoker opening/closing
    • Does not make rest of page inert
    • Supports light dismiss by default
    • Style open state with :popover-open pseudo-class
    • No inherent semantics (more flexible)
  • Future: invoke-target property being prototyped for declarative dialog toggles

Browser Compatibility Issues

  • Supported in latest Chrome, Edge, Firefox, and Safari
  • Animation support inconsistent across browsers:
    • Chrome/Arc: Full animation support
    • Firefox: Mixed results - some demos work, others don't
    • Safari: Poor animation support, missing icons in some demos
  • Cross-browser implementation differences causing rendering issues
  • Polyfilling likely needed for consistent behavior across browsers

CSS Anchor Positioning Integration

  • Coming feature to complement Popover API
  • Allows specifying which element to anchor popover to
  • Properties: position-anchor, top: anchor(bottom), etc.
  • Supports left/center/right and top/center/bottom anchoring
  • Browser automatically keeps menus in view when scrolling
  • Will eliminate need for tools like Popper/Floating UI once fully implemented
  • Not yet available in Chrome but coming soon

Technical Implementation Examples

  • HTML structure uses declarative attributes for popover behavior
  • CSS pseudo-classes for styling different states
  • Menu systems can be built entirely in HTML without JavaScript
  • Close buttons use popover-target-action="hide" with target ID specification

TwinMind

Get summaries like this for your own meetings

TwinMind takes notes in the background during meetings, lectures, and calls, then writes the summary for you.

Free plan to get started

No bot joins your calls

Phone, desktop & Chrome apps

Your next meeting, summarized like this

TwinMind listens in the background and turns meetings, lectures, and calls into searchable notes you can chat with. Start free.

Available on phone, desktop & Chrome

Your next meeting, summarized like this

TwinMind listens in the background and turns meetings, lectures, and calls into searchable notes you can chat with. Start free.

Available on phone, desktop & Chrome

Your next meeting, summarized like this

TwinMind listens in the background and turns meetings, lectures, and calls into searchable notes you can chat with. Start free.

Available on phone, desktop & Chrome