Forms

Date range picker.

A start and an end, kept in the same context.

LIVE PREVIEWTry it. It works.

Install the source

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/date-range.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.

An explicit reporting period

Start and end dates remain visible while completing a range.

Loads this example when you need it.

Keyboard

  • Enter selects start and end dates.
  • Escape returns focus to the range trigger.

States covered

  • Complete range
  • Partial range
  • Cleared

Install this complete example and its component dependencies.

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/example-basic-date-range.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 {DateRangePicker,UIProvider,type DateRange} from '@bld8/ui';
import '@bld8/ui/styles.css';
export default function DateRangeExample(){const [range,setRange]=useState<DateRange|null>({from:new Date(2026,10,11),to:new Date(2026,10,18)});return <UIProvider><DateRangePicker label="Example reporting period" name="reportingPeriod" value={range} onValueChange={setRange} defaultMonth={new Date(2026,10,1)}/><p>{range?.from?.toLocaleDateString('en-AU')??'Choose a start'} – {range?.to?.toLocaleDateString('en-AU')??'Choose an end'}</p></UIProvider>;}

A date range that waits for confirmation

Calendar choices, presets and typed dates stay in a draft until Apply. Cancel, Escape and outside dismissal preserve the committed form value.

Keyboard

  • Type a start and end date as YYYY-MM-DD. Enter applies a complete valid draft.
  • Tab through presets and the calendar, then use Apply range or Cancel.
  • Escape cancels a popup draft and returns to the start field.

States covered

  • Explicit draft
  • Bounded presets
  • Invalid or reversed range
  • Native form reset
  • Optional clear

Install this complete example and its component dependencies.

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/example-date-range-presets.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,Checkbox,DateRangePicker,parseDateValue,UIProvider} from '@bld8/ui';
const range=(from:string,to:string)=>({from:parseDateValue(from)!,to:parseDateValue(to)!});
const presets=[{id:'first',label:'First week',value:range('2026-11-02','2026-11-06')},{id:'second',label:'Second week',value:range('2026-11-09','2026-11-13')},{id:'unavailable',label:'Unavailable week',value:range('2027-01-04','2027-01-08')}];
export default function DateRangePresets(){
  const [changes,setChanges]=useState(0),[required,setRequired]=useState(true),[status,setStatus]=useState('No range submitted.');
  return <UIProvider><form style={{display:'grid',gap:16}} onReset={()=>setStatus('Range reset requested.')} onSubmit={event=>{event.preventDefault();const data=new FormData(event.currentTarget);setStatus('Reporting period: '+data.get('period.from')+' to '+data.get('period.to'));}}>
    <DateRangePicker label="Reporting period" name="period" editable commitMode="explicit" required={required} defaultValue={range('2026-11-02','2026-11-06')} minDate={parseDateValue('2026-11-01')!} maxDate={parseDateValue('2026-12-31')!} presets={presets} onValueChange={()=>setChanges(count=>count+1)} hint="Changes reach the form only after Apply. The dates are date-only values."/>
    <Checkbox label="Require reporting period" checked={required} onCheckedChange={setRequired}/>
    <div style={{display:'flex',gap:8,flexWrap:'wrap'}}><Button type="submit">Read reporting period</Button><Button type="reset" variant="secondary">Reset reporting period</Button></div>
    <p data-date-changes>Changes: {changes}</p><p role="status">{status}</p>
  </form></UIProvider>;
}

Quick reference

React / TypeScript
<DateRangePicker label="Reporting period" name="period"
  value={range} onValueChange={setRange}
  minDate={new Date(2026,9,5)} />

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

DateRange/null with compatible immediate calendar callbacks by default. Opt into editable keyboard endpoints and commitMode explicit for a separate draft, range presets and Apply/Cancel. Apply commits one complete valid bounded range; Cancel, Escape and outside dismissal discard un-applied changes. Native editable form validation, reset and external form ownership share the single-date contract; canonical form names are name.from and name.to. Presets are supplied by the host, not a scheduling service.

DateRangePicker

DateRangePicker public properties
PropTypeDefault
labelRequiredstring—
clearableboolean | undefinedtrue
commitMode"immediate" | "explicit" | undefined

Immediate keeps legacy selection callbacks. Explicit commits only Apply and discards drafts on dismissal.

'immediate'
defaultMonthDate | undefined—
defaultValueDateRange | 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: DateRange | null) => void) | undefined—
placeholderstring | undefined'Choose a date range'
presetsreadonly DateRangePreset[] | undefined[]
readOnlyboolean | undefinedfalse
requiredboolean | undefinedfalse
startMonthDate | undefined

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

—
textInputRefsreadonly [Ref<HTMLInputElement> | undefined, Ref<HTMLInputElement> | undefined] | undefined—
unavailableDatesreadonly Date[] | undefined

Exact local civil dates. Invalid entries are ignored.

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

DateRangePreset

DateRangePreset public properties
PropTypeDefault
idRequiredstring—
labelRequiredstring—
valueRequiredDateRange | null—

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.