Time Field
Champ d'heure natif stylise pour correspondre au design system. Installez Time Field depuis le registre VLLNT UI avec la CLI shadcn.
Champ d'heure natif stylise pour correspondre au design system. Fait partie de la famille form dans VLLNT UI, il est publie comme entree de registre lisible par machine — copiez la source directement dans votre application avec la CLI shadcn et possedez-la, sans dependance d'execution a une bibliotheque de composants.
Apercu
Basculez entre clair et sombre pour inspecter l'apercu Storybook integre.
Installation
Ajoutez Time Field a votre projet avec la CLI shadcn. La source arrive dans votre code, prete a etre adaptee :
pnpm dlx shadcn@latest add https://ui.vllnt.ai/r/time-field.jsonSource
"use client";
import * as React from "react";
import { Clock } from "lucide-react";
import { cn } from "../../lib/utils";
/** Native time input styled to match the design system. */
export type TimeFieldProps = Omit<
React.ComponentPropsWithoutRef<"input">,
"defaultValue" | "onChange" | "type" | "value"
> & {
defaultValue?: string;
onValueChange?: (value: string) => void;
value?: string;
};
const TimeField = ({
className,
defaultValue = "",
onValueChange,
ref,
value,
...props
}: TimeFieldProps & { ref?: React.Ref<HTMLInputElement> }) => {
const [internalValue, setInternalValue] = React.useState(defaultValue);
const currentValue = value ?? internalValue;
return (
<div className="relative w-full">
<Clock 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="time"
value={currentValue}
/>
</div>
);
};
TimeField.displayName = "TimeField";
export { TimeField };
Stories
Explorez chaque variante et etat dans le Storybook interactif :
Apercu
Basculez entre clair et sombre pour inspecter l'apercu Storybook integre.