本文へ移動
日本語
「空き時間グリッド」は Pro に含まれます。解除するとプレビューが表示されます。

仕組み

The rows are plain grids of cells; the meeting window is one absolutely positioned element over them, its width and position computed from the cell count in container query units, so it moves with a transform and nothing is measured on resize. Pressing anywhere on the rows moves the window there and keeps dragging; while dragging it hops cell by cell with a short glide, so the snap feels like detents. A touch waits a few pixels to tell a sideways drag from a vertical scroll, and a tap moves the window. The ink pill on the axis rides the window's start and the hour labels beneath it step aside. When everyone is free, the window ring, the button and the status line turn green and the check draws itself.

向いている場面

  • Finding a meeting time for a handful of people, especially across time zones.
  • Booking flows where a few resources (rooms, staff, vehicles) each have known free slots on the same day.
  • A compact widget beside a calendar or inside a scheduling assistant.

向かない場面

  • Many people or many days at once: use a full calendar or a heat map.
  • Picking a single time with no one else involved: a time picker is simpler.
  • When availability is unknown and people have to vote: use a poll.

使い方

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

const team = [
  // free: [start, end] in hours on the organiser's clock; offset: hours to their local time
  { id: 'ana', name: 'Ana', note: 'Velmora', free: [[9, 12], [13, 17]] },
  { id: 'leo', name: 'Leo', note: 'Port Aster', offset: 1, free: [[9, 11], [12, 16]] },
  { id: 'maya', name: 'Maya', note: 'Kestrel Bay', offset: -5, free: [[13, 15]] },
]

export function FindATime({ onBook }) {
  const [start, setStart] = useState(10)
  return (
    <AvailabilityGrid
      title="Team sync"
      subtitle="Thu · 1 h"
      people={team}
      from={8}
      to={18}
      step={0.5}
      duration={1}
      value={start}
      onChange={setStart}
      onConfirm={(from, to) => onBook(from, to)}
    />
  )
}

プロパティ

プロパティ型既定値説明
people{ id, name, free, offset?, note?, initials?, color? }[]—One row each. free lists [startHour, endHour] ranges on the shared axis (13.5 is 13:30); offset is added to show their local time beside the name; note goes on the line below (a city, for example); color 1–8 or a CSS colour tints the avatar, otherwise it is neutral.
from / tonumber8 / 18First and last hour on the axis.
stepnumber0.5Cell size and snap in hours: 0.5 for half hours, 1 for whole hours (at least 0.25).
durationnumber1Meeting length in hours: the width of the window, rounded to whole steps.
value / defaultValue / onChangenumber / number / (start) => void- / from + 2 steps / -Controlled or uncontrolled start hour of the window, and a callback with the snapped start when it moves.
onConfirm(start, end) => void—Shows the primary button in the footer; called with the window's start and end hours.
title / subtitle / iconReactNode—Title row: the title, a muted qualifier after it, and an icon in a tinted square.
showNextbooleantrueThe round button in the title row that jumps to the next time that works for everyone (disabled when there is none).
color1–8 | string1Hue of the free cells: chart palette index or any CSS colour.
formatTime / formatTick(hours) => string24-hour clockFormats times in the footer, pill and rows, and the axis labels.
labelsobject—Replaces built-in text: window, range, free, all, value, next, freeAt, busyAt, schedule. Shallow-merged over the English defaults.
replayKeyany—Change it to play the entrance again.
...restHTMLAttributes—Other attributes go to the root <section>.

アクセシビリティ

  • The window is a role="slider" with aria-valuetext that reads the time range and how many people are free.
  • Arrow keys move by one step, Page Up and Page Down by an hour, Home and End jump to the ends.
  • Each person's row has hidden text saying whether they are free for the current window; the footer status is a polite live region.
  • The jump button has an accessible name and is disabled when no time works for everyone.
  • The focus ring shows for the keyboard and hides after pointer use.
  • Reduced motion shows the final state without the entrance, the glide or the drawn check.

モーション

Entrance: cells rise column by column (16ms apart, rows 50ms apart) over 520ms, avatars pop with a light spring, the window settles in after 480ms and the status badges pop last. Moving: the window and pill glide 300ms ease-out (120ms while dragging); cells change colour in 240ms; the status line crossfades and the check draws in 360ms; a soft green ring pulses once when the time works for everyone.

プロジェクトに追加

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

AvailabilityGrid.jsxavailability-grid.csstokens.cssREADME.md

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

フォーム入力
「図形のブール演算」は Pro に含まれます。解除するとプレビューが表示されます。
「カスケード選択」は Pro に含まれます。解除するとプレビューが表示されます。