terra vidhal

Shift Roster

Component

About

A weekly shift roster with a paint-style shift selector, an editable staff-by-day grid with arrow and Home/End navigation, live coverage bars per shift, understaffing warnings, a detailed cell editor, publish and reset actions.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Shift Roster to your project and fits it to your theme.

Code

How Shift Roster is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

/**
 * PrequelUI Animate — MIT — https://prequeluianimate.terravidhal.me
 */

import {
  ShiftRoster,
  type RosterDay,
  type RosterStaff,
  type ShiftDefinition,
  type ShiftId,
} from "@/components/ui/shift-roster";

const STAFF: RosterStaff[] = [
  { id: "avery", name: "Avery Cole", role: "Floor lead" },
  { id: "jordan", name: "Jordan Pike", role: "Shift lead" },
  { id: "riley", name: "Riley Chen", role: "Cashier" },
  { id: "casey", name: "Casey Moreno", role: "Stock associate" },
  { id: "sam", name: "Sam Rivera", role: "Cashier" },
  { id: "priya", name: "Priya Raman", role: "Floor associate" },
  { id: "noah", name: "Noah Bennett", role: "Stock associate" },
];

const DAYS: RosterDay[] = [
  { id: "mon", label: "Mon", date: "02" },
  { id: "tue", label: "Tue", date: "03" },
  { id: "wed", label: "Wed", date: "04" },
  { id: "thu", label: "Thu", date: "05" },
  { id: "fri", label: "Fri", date: "06" },
  { id: "sat", label: "Sat", date: "07" },
  { id: "sun", label: "Sun", date: "08" },
];

const SHIFTS: ShiftDefinition[] = [
  { id: "morning", label: "Morning", hours: "07–15" },
  { id: "evening", label: "Evening", hours: "15–23" },
  { id: "night", label: "Night", hours: "23–07" },
  { id: "off", label: "Off", hours: "Rest" },
];

const COVERAGE: Record<ShiftId, number> = {
  morning: 2,
  evening: 2,
  night: 1,
  off: 0,
};

const ASSIGNMENTS: Record<string, ShiftId> = {};
DAYS.forEach((day, index) => {
  const pick = (offset: number) => STAFF[(index + offset) % STAFF.length].id;
  ASSIGNMENTS[`${pick(0)}:${day.id}`] = "morning";
  ASSIGNMENTS[`${pick(1)}:${day.id}`] = "morning";
  ASSIGNMENTS[`${pick(2)}:${day.id}`] = "evening";
  ASSIGNMENTS[`${pick(3)}:${day.id}`] = "evening";
  ASSIGNMENTS[`${pick(4)}:${day.id}`] = "night";
  ASSIGNMENTS[`${pick(5)}:${day.id}`] = "off";
  ASSIGNMENTS[`${pick(6)}:${day.id}`] = "off";
});

export default function ShiftRosterDemo() {
  return (
    <main className="flex min-h-screen w-full items-start justify-center bg-gradient-to-b from-muted/40 via-background to-background px-4 py-8 sm:px-6">
      <ShiftRoster
        staff={STAFF}
        days={DAYS}
        shifts={SHIFTS}
        coverage={COVERAGE}
        initialAssignments={ASSIGNMENTS}
        title="Store shift roster"
      />
    </main>
  );
}

Dependencies

More by terra vidhal

View all
  • Project Timeline

    Project Timeline

    30
  • Kanban Board

    Kanban Board

    20
  • Gravity Stars Background

    Gravity Stars Background

    20
  • Booking Calendar

    Booking Calendar

    18
  • Notification Center

    Notification Center

    16
  • Audio Waveform

    Audio Waveform

    16
  • Kpi Counter

    Kpi Counter

    16
  • Topographic Lines

    Topographic Lines

    16

Explore more

Part of PrequelUI Animate — browse the full library on 21st.dev.