仕組み
Seven equal day cells on a grid, each with the weekday, the date and up to three dots. The ink pill is one element under the cells moved with transform: translateX(index × (cell + gap)) and a light overshoot, and the chosen day's text turns to the surface colour as it arrives. Changing day or week is derived during render, so the very first frame already holds the old page beside the new one: the week rows slide by their own width, the agenda pages by 32px with a fade, and the month name rises in. A touch swipe drags the row with resistance (the translate property, separate from the slide) and turns the week past 44px. Dates are 'YYYY-MM-DD' strings handled as UTC midnights, so daylight saving never moves a day.
向いている場面
- Picking a day close to today: bills, bookings, classes, deliveries, shifts.
- A day view in a mobile app where the week is the natural unit and the details sit right below.
- Showing at a glance which days have something on them.
向かない場面
- Picking a date far away or a range: use a date picker or date range picker.
- Dense schedules with many items per day: use a full calendar or a time grid.
使い方
import { useState } from 'react'
import { WeekStrip } from './WeekStrip.jsx'
const events = {
'2026-11-26': [{ id: 'b1', title: 'Car insurance', detail: '$86.10', tone: 2 }],
'2026-11-28': [{ id: 'b2', title: 'Internet', detail: '$49.00', tone: 7 }],
}
export function BillsWeek() {
const [day, setDay] = useState('2026-11-26')
return (
<WeekStrip
value={day}
onChange={setDay}
events={events}
weekStartsOn={1}
locale="en-US"
label="Bills by day"
/>
)
}プロパティ
| プロパティ | 型 | 既定値 | 説明 |
|---|---|---|---|
value / defaultValue / onChange | string | Date / string | Date / (iso) => void | - / today / - | The chosen day, controlled or uncontrolled, as 'YYYY-MM-DD' (a Date is accepted). onChange receives the new day as 'YYYY-MM-DD'. |
events | { [iso]: { id?, title, detail?, tone?, color? }[] } | — | What is on each day. Up to three dots show per day, coloured by tone (chart colour 1–8) or color; the default agenda lists title and detail. |
renderAgenda | (iso, events) => ReactNode | null | — | Draws the agenda for the chosen day. It slides in from the side you moved toward. Pass null to show the strip alone. |
today | string | Date | the current day | The day marked as today (accent number, aria-current="date"). |
weekStartsOn | 0 | 1 | 1 | 0 starts weeks on Sunday, 1 on Monday. |
locale / weekdayFormat | string / 'narrow' | 'short' | 'long' | 'en' / 'short' | Language of the month and weekday names (Intl), and how long the weekday name is. |
showHeader / showDots | boolean / boolean | true / true | Show the month with previous and next week buttons; show the dots. |
label | string | 'Week' | Accessible name of the row of days (the tab list). |
labels | object | — | Replaces built-in text: previous, next, empty, day(date, count). Shallow-merged over the English defaults. |
...rest | HTMLAttributes | — | Other attributes go to the root <div>. |
アクセシビリティ
- The days are a tablist of tab buttons with aria-selected and a roving tabindex; the agenda is the tabpanel labelled by the chosen day.
- Left and Right move one day (crossing into the next week), Home and End go to the ends of the week, PageUp and PageDown turn the week; focus follows the selection.
- Each day is named in full with its item count, for example “Thursday, November 26, 2 items”; today has aria-current="date".
- The previous and next week buttons are 32px (40px on touch screens) and named through labels; the month name is announced politely when it changes.
- The leaving page is aria-hidden and inert, so it is never read or focused.
- Reduced motion swaps days and weeks at once and the pill jumps.
モーション
Pill: transform 420ms cubic-bezier(0.3, 1.25, 0.5, 1); the chosen day's text inverts over 240ms after 60ms. Week: both rows slide by their width plus 16px over 360ms ease-out. Agenda: the old page fades 20px the other way in 160ms, and the new one follows 70ms later, entering from 32px with a fade over 360ms. Swipe: the row follows the finger at 45% up to 72px and eases back in 240ms.
プロジェクトに追加
プロンプトを Codex または Claude Code に貼り付けます。エージェントが公開ソースを読み、書き込む内容を示したうえで、既存のコンポーネントの隣に追加します。
WeekStrip.jsxweek-strip.csstokens.cssREADME.md
2 つのファイルを一緒に導入します。スタイルは tokens.css の変数を読み、予備の値も持つため、単体でも表示できます。