Skip to content

Day Picker

Week-strip date picker: prev/next week arrows and seven rounded day pills (weekday + number) with task-load dots (red when full); the selected day fills periwinkle.

soft-flat/ui/day-picker
Open ↗

Source

"use client";

import { useId, useState } from "react";
import { ChevronLeft, ChevronRight } from "lucide-react";
import { cn } from "@/lib/utils";

export interface DayPickerProps {
  label?: string;
  /** ISO date (yyyy-mm-dd) of the week start (Monday). */
  weekStart?: string;
  value?: string;
  defaultValue?: string;
  onValueChange?: (iso: string) => void;
  /** Number of tasks per ISO day, shown as dots. */
  load?: Record<string, number>;
  className?: string;
}

function addDays(iso: string, n: number) {
  const d = new Date(`${iso}T12:00:00`);
  d.setDate(d.getDate() + n);
  return d.toISOString().slice(0, 10);
}

/** Week strip date picker: prev/next week arrows and 7 rounded day pills (weekday + number) with load dots; the selected day fills periwinkle. Radio semantics. */
export function DayPicker({
  label = "Due date",
  weekStart = "2026-10-05",
  value,
  defaultValue = "2026-10-08",
  onValueChange,
  load = { "2026-10-05": 2, "2026-10-06": 1, "2026-10-07": 4, "2026-10-08": 1, "2026-10-09": 3 },
  className,
}: DayPickerProps) {
  const id = useId();
  const [start, setStart] = useState(weekStart);
  const [inner, setInner] = useState(defaultValue);
  const selected = value ?? inner;
  const days = Array.from({ length: 7 }, (_, i) => addDays(start, i));
  const fmt = (iso: string, o: Intl.DateTimeFormatOptions) => new Date(`${iso}T12:00:00`).toLocaleDateString("en-US", o);

  return (
    <div className={cn("rounded-da-lg bg-da-surface p-4 shadow-da-sm", className)}>
      <div className="flex items-center justify-between">
        <p id={id} className="font-da-display text-lg font-extrabold">
          {label} <span className="text-sm font-medium text-da-muted-fg">· {fmt(start, { month: "long", year: "numeric" })}</span>
        </p>
        <div className="flex gap-1">
          <button
            type="button"
            aria-label="Previous week"
            onClick={() => setStart(addDays(start, -7))}
            className="da-focus grid size-9 place-items-center rounded-full bg-da-surface-2 hover:bg-da-muted"
          >
            <ChevronLeft aria-hidden className="size-4" />
          </button>
          <button
            type="button"
            aria-label="Next week"
            onClick={() => setStart(addDays(start, 7))}
            className="da-focus grid size-9 place-items-center rounded-full bg-da-surface-2 hover:bg-da-muted"
          >
            <ChevronRight aria-hidden className="size-4" />
          </button>
        </div>
      </div>
      <div role="radiogroup" aria-labelledby={id} className="mt-4 grid grid-cols-7 gap-1.5">
        {days.map((d) => {
          const on = d === selected;
          const n = load[d] ?? 0;
          return (
            <button
              key={d}
              type="button"
              role="radio"
              aria-checked={on}
              aria-label={`${fmt(d, { weekday: "long", month: "long", day: "numeric" })}${n ? `, ${n} tasks` : ""}`}
              onClick={() => {
                setInner(d);
                onValueChange?.(d);
              }}
              className={cn(
                "da-focus flex flex-col items-center gap-1 rounded-da-md py-2.5 transition-[background-color,scale] duration-(--da-duration) ease-da-emphasized",
                on ? "scale-105 bg-da-primary text-da-primary-fg shadow-da-sm" : "hover:bg-da-surface-2",
              )}
            >
              <span className={cn("text-[11px] font-semibold uppercase", !on && "text-da-muted-fg")}>{fmt(d, { weekday: "short" }).slice(0, 2)}</span>
              <span className="font-da-display text-lg font-extrabold">{fmt(d, { day: "numeric" })}</span>
              <span aria-hidden className="flex h-1.5 gap-0.5">
                {Array.from({ length: Math.min(n, 4) }, (_, k) => (
                  <span key={k} className={cn("size-1.5 rounded-full", on ? "bg-da-primary-fg" : n >= 4 ? "bg-da-danger" : "bg-da-primary")} />
                ))}
              </span>
            </button>
          );
        })}
      </div>
    </div>
  );
}

export default DayPicker;

modules/soft-flat/ui/day-picker/index.tsx

Props

PropTypeDefaultDescription
labelstring—Label.
weekStartstring—ISO Monday.
value / defaultValuestring—ISO date.
onValueChange(iso: string) => void—Handler.
loadRecord<string, number>—Tasks per day.

Other input variants in Soft Flat

Input in other art directions

Input

Labelled text field with hint, error state, leading icon, suffix slot and two sizes. The field presses into its shadow on focus; errors switch to a red stroke with an explicit message.

BrutalistInput

Number Stepper

Numeric input flanked by chunky yellow − / + buttons (disabled at bounds), big display-font value, optional unit suffix; clamps typed values to min/max.

BrutalistInput

OTP Input

One-time-code input: ruled digit squares (split 3+3 for six digits) that turn yellow and press in on focus; auto-advance, backspace and arrow navigation, paste of the full code, completion callback and error state.

BrutalistInput

Textarea

Labelled multi-line field with a live character counter chip that turns orange near the limit, hint and error states; presses into its shadow on focus.

BrutalistInput

Combobox

Autocomplete select: a glass pill input that filters a frosted listbox as you type, with arrow-key highlight, Enter to choose, Escape to close, hints and a check on the selection.

GlassInput

Input

Frosted text field with label, hint, error state, leading icon, trailing slot (button, kbd, unit), rounded or pill shape and two sizes. Focus brightens the glass and adds a soft violet halo.

GlassInput

Range Slider

Glass slider on Radix Slider: frosted track, primary→accent range, glowing gradient thumbs with value bubbles on hover/focus and tick labels; single value or range.

GlassInput

Tag Input

Glass chip input: type and press Enter or comma to add gradient chips, Backspace removes the last, × removes one; quick-add suggestion chips and a max counter.

GlassInput

Input

Hairline text field with label (auto "Optional" marker), hint, error with icon, leading icon, text prefix, trailing slot (unit, kbd) and indigo focus ring. Two sizes.

MinimalInput

Search Input

Search field with leading icon, “/” keycap hint that focuses the field, clear button (Escape clears too) and a loading spinner state. Two sizes, controlled or uncontrolled.

MinimalInput

Select Menu

Labelled select built on Radix Select: bordered trigger with chevrons, portalled popover with optional icons, descriptions, groups, separators, disabled items and a check on the selected one.

MinimalInput

Switch Field

Settings row with label and description on the left and a Radix Switch on the right; plain (for divided lists) or bordered card that highlights when on. Disabled state.

MinimalInput

Checkbox Group

Settings checkboxes as ruled rows: square ink check boxes (native inputs), label and muted description; the whole row is clickable.

Mono CleanInput

Input

Underline field: mono uppercase label, a borderless input on a single bottom hairline that turns ink (2px) on focus, optional prefix, hint or red error.

Mono CleanInput

Search Input

Search field with live results: hairline-bordered input with icon and ⌘K hint; matches appear in a ruled list below with the query highlighted and a mono kind label; empty state included.

Mono CleanInput

Select Field

Native select styled as an underline field with a mono label and a custom chevron — reliable on every device and screen reader.

Mono CleanInput

Currency Input

Amount field with currency symbol prefix and an attached currency select; formats with thousands separators on blur, right-aligned mono digits.

Neo CorporateInput

File Upload

Receipt/document dropzone: dashed bordered area with upload icon, click-or-drag, file list with size, per-file size validation errors and remove buttons.

Neo CorporateInput

Input

Form field: label (with optional marker), bordered 40px input with leading/trailing adornments, blue focus ring, hint text or red error with aria-invalid.

Neo CorporateInput

Select Field

Labelled Radix Select styled as a bordered field: grouped options (e.g. GL accounts) with group headings, check on the selected item, portalled popover with data-da.

Neo CorporateInput

Chip Select

Multi-select as soft pill checkboxes: unselected sand pills, selected sage pills with a check that pops in; native checkboxes in a fieldset.

Organic SoftInput

Input

Soft filled text field: rounded sand-filled input that turns cream with a sage ring on focus, optional leading icon and trailing unit, hint or gentle clay error message.

Organic SoftInput

Target Slider

Reduction target picker: a thick rounded sage range (0–60%) with tick labels and a “science-aligned” marker, showing the resulting tonnes and a gentle verdict.

Organic SoftInput

Textarea

Soft note field: rounded sand textarea that auto-grows (field-sizing), with a live character counter that turns clay near the limit.

Organic SoftInput