Ir al contenido
Español
Bloque de tiempo viene con Pro. La vista previa aparece al desbloquearlo.

Cómo funciona

A time ruler in a soft panel: hour labels, a tick every step and dashed hour lines behind a lane. The block is a rounded gradient fill translated inside a rounded clip that starts at the start time, so its end stays round while it grows; the handle sits on the end, placed in container query units so it needs no measuring. Pressing anywhere on the lane moves the end there, dragging follows the pointer with transitions switched off, and the handle is a real slider for the keyboard.

Úsalo para

  • Showing one booked slot on today's timeline: a meeting, a focus block, a class, a delivery window.
  • Letting people extend or shorten a booking in place, in fixed steps.
  • A dashboard tile where the duration is the headline number.

Busca otra opción cuando

  • Several overlapping events: use a day calendar or schedule view.
  • Picking both start and end from scratch: use a time range picker with inputs.
  • Ranges longer than a day.

Uso

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

export function ReviewSlot() {
  const [end, setEnd] = useState(12 * 60) // minutes from midnight
  return (
    <TimeBlock
      title="Design review"
      subtitle="Today"
      onOpen={() => {}}
      start={10 * 60 + 30}
      end={end}
      onChange={setEnd}
      from={9 * 60}
      to={13 * 60}
      color={[3, 7]}
    />
  )
}

Propiedades

PropiedadTipoPor defectoQué hace
startnumber600Start time in minutes from midnight (630 is 10:30). Changing it replays the entrance.
end / defaultEnd / onChangenumber / number / (end: number) => void—End time in minutes. Pass end and onChange to control it, or defaultEnd to let the card keep it. Changes from outside slide the block; drags follow the pointer.
from / tonumber—Ruler range in minutes. By default from the hour before the start to at least four hours later.
step / minDurationnumber15 / stepSnap step in minutes, also the tick spacing and the arrow-key step; the shortest allowed block.
editablebooleantrueLets people drag the end handle or press on the ruler. false shows the block read-only.
title / subtitle / iconReactNode—Card header: a tinted icon tile, a 15px title and a quieter subtitle after it.
onOpen / action() => void / ReactNode—onOpen adds a chevron button at the end of the header. action replaces it with any node.
captionstring | (start: string, end: string) => string—Line above the duration. By default the formatted range, such as 10:30 – 12:00.
colornumber | string | [number | string, number | string][3, 7]Block gradient. A pair blends the first colour into the second; one colour runs from its tint to itself. Numbers 1–8 pick --ds-chart-N.
formatTime / formatTick / formatDuration(minutes: number) => string'10:30' / formatTime / '1h 30m'Formats for times (caption, tooltip), hour labels on the ruler and the duration. Digits in the duration show at hero size and words at unit size, in any language.
labelsobject—Replaces built-in text: open, handle (the slider name), range(start, end), value(end, duration) for the slider value text.
replayKeystring | number—Change it to play the entrance again.
className / style / ...restHTMLAttributes—Passed to the card root, which fills its container width.

Accesibilidad

  • The handle is a slider with a name, min, max and a value text such as "12:00 PM, 1h 30m".
  • Left and Down shorten by one step, Right and Up lengthen, Page Up and Page Down move an hour, Home and End jump to the shortest and the latest end.
  • Keyboard focus shows a ring on the grip and the end-time tooltip; pointer focus does not.
  • The caption and duration are real text; the ruler and block are hidden from screen readers.
  • With editable false the slider is removed and the block is read-only. Reduced motion shows the final block at once and the duration does not count.

Movimiento

Entrance waits until 30% of the card is visible. Ticks rise 14ms apart and hour labels fade 50ms apart; from 160ms the block grows from its start over 900ms on cubic-bezier(0.22, 1, 0.36, 1) while the handle rides its end and the duration counts up. Changes of end from outside slide over 900ms; dragging has no transition. The tooltip fades and lifts in 160ms.

Añádelo a tu proyecto

Los miembros Pro copian un prompt y su agente de programación instala el código, igual que con los gratuitos.

TimeBlock.jsxtime-block.csstokens.cssREADME.md

Los dos archivos se instalan juntos. La hoja de estilos lee las variables de tokens.css y lleva valores de reserva, así que también funciona sola.

Gráficos
Trilateración viene con Pro. La vista previa aparece al desbloquearlo.