Forms

Date picker.

A date field with a calendar, clear action and useful feedback.

LIVE PREVIEWTry it. It works.

Install the source

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/date-picker.json

Registry setup · Examples · API and behavior · Open the playground

COMPLETE EXAMPLES

Use it in context.

Each example includes its imports, data and state. The preview runs that same source. Include the stylesheet once in your application.

A labelled date field

The host keeps the Date value and the picker owns its popup navigation.

Loads this example when you need it.

Keyboard

  • Enter opens the calendar.
  • Escape closes it and restores the trigger.

States covered

  • Selected
  • Cleared

Install this complete example and its component dependencies.

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/example-basic-date-picker.json
Complete source
React / TypeScript
/*!
MIT License

Copyright (c) 2026 Jaison

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
'use client';
import {useState} from 'react';
import {DatePicker,UIProvider} from '@bld8/ui';
import '@bld8/ui/styles.css';
export default function DateExample(){const [date,setDate]=useState<Date|null>(new Date(2026,10,11));return <UIProvider><DatePicker label="Example next review" name="reviewDate" value={date} onValueChange={setDate} defaultMonth={new Date(2026,10,1)} hint="A calendar date, without a stored time."/><p>{date?date.toLocaleDateString('en-AU'):'No date selected'}</p></UIProvider>;}

A date field with native form ownership

Type an unambiguous date, use the calendar, and submit or reset through an external form. Invalid calendar dates never replace a committed value.

Keyboard

  • Type YYYY-MM-DD; Enter or leaving the field commits a valid date.
  • Alt+ArrowDown opens the calendar. Escape restores the committed text.
  • Tab reaches the calendar and clear actions; native form validation focuses invalid text.

States covered

  • Editable date
  • Required and min/max validation
  • External form
  • Read only
  • Disabled
  • Prevented reset

Install this complete example and its component dependencies.

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/example-date-entry-lifecycle.json
Complete source
React / TypeScript
/*!
MIT License

Copyright (c) 2026 Jaison

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
'use client';
import '@bld8/ui/styles.css';
import {useId,useRef,useState} from 'react';
import {Button,Checkbox,DatePicker,parseDateValue,UIProvider} from '@bld8/ui';
export default function DateEntryLifecycle(){
  const formId=useId(),input=useRef<HTMLInputElement>(null);
  const [changes,setChanges]=useState(0),[status,setStatus]=useState('No date submitted.'),[keepOnReset,setKeepOnReset]=useState(false);
  return <UIProvider><div style={{display:'grid',gap:16}}>
    <DatePicker label="Review date" editable name="reviewDate" form={formId} required defaultValue={parseDateValue('2026-11-12')} minDate={parseDateValue('2026-11-01')!} maxDate={parseDateValue('2026-12-31')!} textInputRef={input} onValueChange={()=>setChanges(count=>count+1)} hint="Use YYYY-MM-DD. Dates stay in the local calendar, without UTC conversion."/>
    <DatePicker label="Locked review date" editable name="lockedDate" form={formId} defaultValue={parseDateValue('2026-11-18')} readOnly/>
    <DatePicker label="Unavailable date" editable name="unavailableDate" form={formId} defaultValue={parseDateValue('2026-11-20')} disabled/>
    <Checkbox label="Keep date on reset" checked={keepOnReset} onCheckedChange={setKeepOnReset}/>
    <form id={formId} onReset={event=>{if(keepOnReset){event.preventDefault();setStatus('Reset prevented.');}else setStatus('Reset requested.');}} onSubmit={event=>{event.preventDefault();const data=new FormData(event.currentTarget);setStatus('Review date: '+data.get('reviewDate')+'; locked: '+data.get('lockedDate')+'; unavailable: '+(data.has('unavailableDate')?'included':'excluded'));}}>
      <div style={{display:'flex',gap:8,flexWrap:'wrap'}}><Button type="submit">Read review date</Button><Button type="reset" variant="secondary">Reset review date</Button><Button variant="ghost" onClick={()=>input.current?.focus()}>Focus review date</Button></div>
    </form><p data-date-changes>Changes: {changes}</p><p role="status">{status}</p>
  </div></UIProvider>;
}

Controlled dates remain host owned

External updates and native reset preserve the controlled value. Native text errors are linked to the actual input.

Keyboard

  • Edit a date and leave the field to report the valid change.
  • Reset leaves the controlled value with the host.
  • External update buttons change or clear the committed date.

States covered

  • Controlled value
  • External update
  • Controlled null
  • Reset

Install this complete example and its component dependencies.

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/example-date-controlled-entry.json
Complete source
React / TypeScript
/*!
MIT License

Copyright (c) 2026 Jaison

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
'use client';
import '@bld8/ui/styles.css';
import {useState} from 'react';
import {Button,DatePicker,formatDateValue,parseDateValue,UIProvider} from '@bld8/ui';
export default function ControlledDateEntry(){
  const [value,setValue]=useState<Date|null>(parseDateValue('2026-11-12')),[status,setStatus]=useState('Controlled date: 2026-11-12');
  return <UIProvider><form style={{display:'grid',gap:16}} onSubmit={event=>{event.preventDefault();setStatus('Controlled submitted: '+new FormData(event.currentTarget).get('controlledDate'));}}>
    <DatePicker label="Controlled review date" editable name="controlledDate" value={value} onValueChange={next=>{setValue(next);setStatus('Controlled date: '+formatDateValue(next));}}/>
    <div style={{display:'flex',gap:8,flexWrap:'wrap'}}><Button onClick={()=>setValue(parseDateValue('2026-11-24'))}>Set controlled date</Button><Button variant="ghost" onClick={()=>setValue(null)}>Clear controlled date</Button><Button variant="secondary" type="reset">Reset controlled date form</Button><Button type="submit">Read controlled date</Button></div><p role="status">{status}</p>
  </form></UIProvider>;
}

Quick reference

React / TypeScript
<DatePicker label="Review date" name="reviewDate"
  value={date} onValueChange={setDate}
  hint="Choose the next review." />

In the workspace or ZIP starter, import components from @bld8/ui and include @bld8/ui/styles.css once. Registry installations use your local bld8/ source path. Wrap overlays in UIProvider.

API & behaviour

Controlled Date/null or uncontrolled defaultValue. The default calendar button preserves its existing ref and interaction. Opt into editable for strict YYYY-MM-DD keyboard entry with native required/format/bounds validation, textInputRef, canonical date-only form values, external form ownership and native reset. Invalid drafts stay visible and never commit an invalid Date. Disabled values are omitted; read-only values remain submitted. Button-only required validation belongs to the host. Date-only helpers use local calendar fields, never UTC conversion.

DatePicker

DatePicker public properties
PropTypeDefault
labelRequiredstring—
clearableboolean | undefinedtrue
defaultMonthDate | undefined—
defaultValueDate | null | undefinednull
density"compact" | "comfortable" | undefined'comfortable'
disabledboolean | undefined—
editableboolean | undefined

Editable fields use strict YYYY-MM-DD text and real native constraint validation.

false
endMonthDate | undefined—
errorstring | undefined—
formstring | undefined—
formatLocalestring | undefined—
hintstring | undefined—
inputRefRef<HTMLButtonElement> | undefined

Keep the existing button ref. In editable mode this is the calendar-opening button.

—
isDateUnavailable((date: Date) => boolean) | undefined

Pure synchronous host policy; no network or zone conversion. Throwing fails closed.

—
labelVisibility"hidden" | "visible" | undefined'visible'
localeDayPickerLocale | undefined—
maxDateDate | undefined—
minDateDate | undefined—
monthDate | undefined

Optional controlled visible month, independent of selection.

—
namestring | undefined—
navigation"buttons" | "dropdowns" | undefined—
numberOfMonths1 | 2 | 3 | undefined—
onBlurFocusEventHandler<HTMLButtonElement> | undefined—
onInputBlurFocusEventHandler<HTMLInputElement> | undefined—
onInputKeyDownKeyboardEventHandler<HTMLInputElement> | undefined—
onMonthChange((month: Date) => void) | undefined—
onValueChange((value: Date | null) => void) | undefined—
placeholderstring | undefined—
readOnlyboolean | undefinedfalse
requiredboolean | undefinedfalse
startMonthDate | undefined

Additional navigation bounds. Day-level minDate/maxDate remain authoritative.

—
textInputRefRef<HTMLInputElement> | undefined—
unavailableDatesreadonly Date[] | undefined

Exact local civil dates. Invalid entries are ignored.

—
valueDate | null | undefined—
weekStartsOn0 | 5 | 1 | 2 | 3 | 4 | 6 | undefined—

Tables come from the public TypeScript declarations. Related types and function parameters are shown alongside their component. A dash means no default is declared at the public function boundary.

Related controls

Notes to self

Test this component with real content, keyboard input and both themes. The example is a starting point; labels, error handling and behaviour still need to fit the application.