React adapter

@subfloor/react renders the same markup and hands it to the core. It works in the Next.js App Router and renders closed on the server.

onOpenChange calls: none

React modal

Controlled with useState.

Blocked React modal

Nothing the user does closes it.

React sheet

Uncontrolled, opened by a commandfor button.

React sheet, no swipe

This one is not closed by swiping it down.

Usage

'use client' // only in the component that holds the state
import { Sidepanel, Modal } from '@subfloor/react'
import { useState } from 'react'

export function DeleteProject() {
  const [open, setOpen] = useState(false)
  return (
    <>
      <button onClick={() => setOpen(true)}>Delete project</button>
      <Modal
        title="Delete project?"
        open={open}
        onOpenChange={(next, reason) => setOpen(next)}
        footer={<button onClick={() => setOpen(false)}>Cancel</button>}
      >
        <p>This removes the project and its history.</p>
      </Modal>
    </>
  )
}

Removed while open

A dialog that a route change removes while it is open gives focus back only if focus was lost: to returnFocus when set, else to the button that opened it. If the page has already put focus somewhere else, such as the next thing to do, it stays there. Move focus in a layout effect or with autoFocus: a useEffect runs after the dialog is gone, so focus would visit the opener first.

Removed while open

Background

Content 1. Background text that only exists so there is something to scroll. When an overlay is open, this must stay exactly where it is, whatever the wheel, the keyboard or a finger does.

Content 2. Background text that only exists so there is something to scroll. When an overlay is open, this must stay exactly where it is, whatever the wheel, the keyboard or a finger does.

Content 3. Background text that only exists so there is something to scroll. When an overlay is open, this must stay exactly where it is, whatever the wheel, the keyboard or a finger does.

Content 4. Background text that only exists so there is something to scroll. When an overlay is open, this must stay exactly where it is, whatever the wheel, the keyboard or a finger does.

Content 5. Background text that only exists so there is something to scroll. When an overlay is open, this must stay exactly where it is, whatever the wheel, the keyboard or a finger does.

Content 6. Background text that only exists so there is something to scroll. When an overlay is open, this must stay exactly where it is, whatever the wheel, the keyboard or a finger does.

Content 7. Background text that only exists so there is something to scroll. When an overlay is open, this must stay exactly where it is, whatever the wheel, the keyboard or a finger does.

Content 8. Background text that only exists so there is something to scroll. When an overlay is open, this must stay exactly where it is, whatever the wheel, the keyboard or a finger does.

Content 9. Background text that only exists so there is something to scroll. When an overlay is open, this must stay exactly where it is, whatever the wheel, the keyboard or a finger does.

Content 10. Background text that only exists so there is something to scroll. When an overlay is open, this must stay exactly where it is, whatever the wheel, the keyboard or a finger does.

Content 11. Background text that only exists so there is something to scroll. When an overlay is open, this must stay exactly where it is, whatever the wheel, the keyboard or a finger does.

Content 12. Background text that only exists so there is something to scroll. When an overlay is open, this must stay exactly where it is, whatever the wheel, the keyboard or a finger does.