Cron Input
Standard five-field cron expression input with plain-English schedule readout and upcoming run times.
- Mon, 2026-11-23 09:00
- Tue, 2026-11-24 09:00
- Wed, 2026-11-25 09:00
- Thu, 2026-11-26 09:00
- Fri, 2026-11-27 09:00
Installation
The CLI also installs the npm packages and registry items it builds on, and reads the style in your components.json to pick the Base UI or Radix build.
Usage
"use client"
import { useState } from "react"
import { CronInput } from "@/components/ui/cron-input"
export function BackupSchedule() {
const [schedule, setSchedule] = useState("0 9 * * 1-5")
return (
<div className="flex flex-col gap-2">
<label htmlFor="cron" className="text-sm font-medium">Backup schedule</label>
<CronInput
value={schedule}
onValueChange={setSchedule}
inputProps={{ id: "cron" }}
/>
</div>
)
}Examples
Basic cron input
A standard five-field cron input with a plain-English schedule readout and next run times.
- Mon, 2026-11-23 09:00
- Tue, 2026-11-24 09:00
- Wed, 2026-11-25 09:00
- Thu, 2026-11-26 09:00
- Fri, 2026-11-27 09:00
Preset schedules
Controlled cron input paired with quick preset buttons for common recurring intervals.
- Sun, 2026-11-22 00:00
- Mon, 2026-11-23 00:00
- Tue, 2026-11-24 00:00
- Wed, 2026-11-25 00:00
- Thu, 2026-11-26 00:00
API reference
CronInput
A standard five-field cron expression input with plain-English schedule readout and upcoming run times.
| Prop | Type | Default |
|---|---|---|
valuestringControlled cron expression value. | string | |
defaultValuestringDefault"* * * * *"Initial value in uncontrolled mode. | string | "* * * * *" |
onValueChange(value: string) => voidFires whenever the cron expression text changes. | (value: string) => void | |
placeholderstringDefault"* * * * *"Placeholder text for the cron input field. | string | "* * * * *" |
showDescriptionbooleanDefaulttrueWhether to display the plain-English schedule readout below the input. | boolean | true |
showNextRunsbooleanDefaulttrueWhether to show the list of upcoming calculated run times. | boolean | true |
nextRunsCountnumberDefault5Number of upcoming run times to calculate and display. | number | 5 |
nextRunsFromDateReference date for upcoming runs calculation. Defaults to current time. | Date | |
formatNextRun(date: Date) => stringCustom date formatting function for upcoming runs. | (date: Date) => string | |
disabledbooleanDefaultfalseWhether the input is disabled. | boolean | false |
readOnlybooleanDefaultfalseWhether the input is read-only. | boolean | false |
inputPropsOmit<React.ComponentProps<"input">, "value" | "defaultValue" | "onChange" | "disabled" | "readOnly">Additional props passed directly to the inner input element. | Omit<React.ComponentProps<"input">, "value" | "defaultValue" | "onChange" | "disabled" | "readOnly"> |
Other props go to the <div>.
parseCron
parseCron(expression: string | undefined | null): ParseCronResultPure logic helper in @/lib/cron-input that parses, validates, and expands a standard 5-field cron expression.
describeCron
describeCron(expression: string | undefined | null): stringPure logic helper in @/lib/cron-input that turns a 5-field cron expression into a plain-English sentence.
getNextRunTimes
getNextRunTimes(expression: string | undefined | null, count?: number, from?: Date): Date[]Pure logic helper in @/lib/cron-input that computes the next N run times starting from a reference date, following POSIX matching rules.