本文へ移動
日本語
「ボトムシート」は Pro に含まれます。解除するとプレビューが表示されます。

仕組み

Position is the distance of the panel top below the highest snap point, written to transform every frame while dragging, so React never re-renders. At rest the panel height equals the snap height; during a gesture it is stretched to full height and compensated with translateY, then shrunk once settled. The footer stays pinned to the visible bottom. On release the last 100ms of velocity decides a one-step flick, and the snap curve is built from that velocity so motion continues smoothly. Only the handle area drags; content keeps native scrolling. The backdrop dims and lightly blurs the page behind (override with --ds-sheet-backdrop); the panel is a borderless card with 28px top corners and a soft upward shadow, and the footer has no divider.

向いている場面

  • Mobile choices that keep people on the current page: payment method, options, coupons.
  • Action menus such as share and more.
  • Detail panels over a map or list: half open to peek, pull up for everything.

向かない場面

  • Desktop: use a centered dialog or a side drawer; a bottom sheet is too far from the eyes on large screens.
  • Dangerous confirmations that must be handled, such as deleting an account: use a centered dialog that is harder to dismiss by mistake.
  • Long content that needs its own browsing: open a new page.

使い方

import { useState } from 'react'
import { BottomSheet } from './BottomSheet.jsx'

export function BuyButton() {
  const [open, setOpen] = useState(false)
  return (
    <>
      <button onClick={() => setOpen(true)}>Buy now</button>
      <BottomSheet
        open={open}
        onClose={() => setOpen(false)}
        title="Choose payment method"
        snapPoints={[0.8, 0.96]}
        footer={<button onClick={() => setOpen(false)}>Pay $25.60</button>}
      >
        <PaymentMethodList />
      </BottomSheet>
    </>
  )
}

プロパティ

プロパティ型既定値説明
openboolean—Whether the sheet is open.
onClose() => void—Requests closing (pull down, backdrop click, Esc). You set open to false; if you do not, the sheet springs back.
titleReactNode—Title, also the dialog's accessible name (aria-labelledby).
footerReactNode—Action area pinned to the bottom, visible at every snap height.
snapPointsnumber[][0.5, 0.9]Snap points as fractions of the container height. A single value means a fixed height.
defaultSnapnumber0Index (low to high) of the snap point to open at.
onSnapChange(index: number) => void—Called when the snap point changes.
closeThresholdnumber0.25Releasing after pulling down more than the lowest snap height times this fraction closes the sheet.
velocityThresholdnumber0.5Release speed (px/ms) above which a drag counts as a flick.
dismissiblebooleantrueWhether pulling down, a backdrop click and Esc can close it. When false, pulling down also resists.
containedbooleanfalseConfines the sheet to the nearest positioned ancestor (absolute). By default it is portaled to the body and fills the viewport.
initialFocusRefRefObject<HTMLElement>—Element to focus first after opening. Defaults to the panel itself.
labelsobject—Replaces built-in text (lowerSheet, raiseSheet), the handle button's names. Shallow-merged over the English defaults.
childrenReactNode—Content; it scrolls inside the content area when too tall.
...restHTMLAttributes<HTMLDivElement>—Other attributes go to the panel (the role=dialog element), such as aria-label and className.

アクセシビリティ

  • The panel is role="dialog" with aria-modal="true" and its title linked by aria-labelledby.
  • Focus moves into the panel (or initialFocusRef) on open, Tab cycles inside it, and focus returns to the opener on close.
  • While open, siblings are inert: unreadable, unreachable by Tab and not clickable; outside contained mode, page scrolling is locked.
  • Esc closes; the handle is a real button: Enter and Space switch snap points, Up and Down move one step, and the hit area is 44px.
  • Reduced motion makes opening, closing and snapping jump into place while dragging still follows the finger.

モーション

Open 300ms ease-out, close 200ms ease-in, handle snap 320ms ease-in-out. Release snaps take 200 to 400ms by distance on a curve built from the release velocity. The dimmed, blurred backdrop follows the same curve. Reduced motion jumps into place.

プロジェクトに追加

Pro メンバーはプロンプトをコピーし、コーディングエージェントが無料コンポーネントと同じ手順でソースを導入します。

BottomSheet.jsxbottom-sheet.csstokens.cssREADME.md

2 つのファイルを一緒に導入します。スタイルは tokens.css の変数を読み、予備の値も持つため、単体でも表示できます。

オーバーレイ