Date Field

Native date input styled to match the design system. Install Date Field from the VLLNT UI registry with the shadcn CLI.

Report a bug

Native date input styled to match the design system. Part of the form family in VLLNT UI, it ships as a machine-readable registry entry — copy the source directly into your app with the shadcn CLI and own it, no runtime dependency on a component library.

Preview

Switch between light and dark to inspect the embedded Storybook preview.

Installation

Add Date Field to your project with the shadcn CLI. The source lands in your codebase, ready to adapt:

pnpm dlx shadcn@latest add https://ui.vllnt.ai/r/date-field.json

Source

"use client"; import * as React from "react"; import { CalendarDays } from "lucide-react"; import { cn } from "../../lib/utils"; /** Native date input styled to match the design system. */ export type DateFieldProps = Omit< React.ComponentPropsWithoutRef<"input">, "defaultValue" | "onChange" | "type" | "value" > & { defaultValue?: string; onValueChange?: (value: string) => void; value?: string; }; const DateField = ({ className, defaultValue = "", onValueChange, ref, value, ...props }: DateFieldProps & { ref?: React.Ref<HTMLInputElement> }) => { const [internalValue, setInternalValue] = React.useState(defaultValue); const currentValue = value ?? internalValue; return ( <div className="relative w-full"> <CalendarDays className="pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground" /> <input {...props} className={cn( "flex h-10 w-full rounded-md border border-input bg-background py-2 pl-9 pr-3 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm [&::-webkit-calendar-picker-indicator]:opacity-60", className, )} onChange={(event) => { if (value === undefined) { setInternalValue(event.target.value); } onValueChange?.(event.target.value); }} ref={ref} type="date" value={currentValue} /> </div> ); }; DateField.displayName = "DateField"; export { DateField };

Stories

Explore every variant and state in the interactive Storybook:

Preview

Switch between light and dark to inspect the embedded Storybook preview.

Dependencies

  • @vllnt/ui@^0.3.0