logo-icon
STW UI

DatePicker

DatePicker is used to select or input a date.

Usage

svelte
import { DatePicker } from 'stwui';
// OR
import DatePicker from 'stwui/date-picker'; // for tree shaking

Basic

With Label

With day limit (min: 11/21/2024)

With Leading

With Trailing

With Error

You're doing it wrong!

Disabled

With Time

With Time (24 hour)

With Time And Step

With Action

With user input

With user input (with time)

Mobile

Mobile With Actions

Mobile With Time

Localization

By default, the locale is en-US. However, there are several other locales available through Dayjs. To use other languages, you can simply import the locale and assign it globally. Once you import the locale, you can call dayjs.locale() with the key of the imported locale to change the global locale. The list of supported locales can be found here.


typescript
import dayjs from 'dayjs';
import 'dayjs/locale/de';

dayjs.locale('de');

DatePicker Props

name string nanoid()
error string | undefined
placeholder string | undefined
value Date | null null
min Date | undefined
max Date | undefined
format string (dayjs format) MMMM D, YYYY | MMMM D, YYYY @ h:mm A
locale Locale {}
visible boolean false
closeOnSelect boolean true
disabled boolean false
showTime boolean false
mobile boolean false
allowUserInput boolean false

DatePicker Slots

label <Input.Label slot="label" />
leading <Input.Leading slot="leading" />
trailing <Input.Trailing slot="trailing" />

DatePicker.Label Slots

default

DatePicker.Leading Props

data string (IconData)
viewBox string 0 0 24 24
size string 24px
width string 24px
height string 24px
color string currentColor
stroke string | undefined
fill string currentColor

DatePicker.Trailing Props

data string (IconData)
viewBox string 0 0 24 24
size string 24px
width string 24px
height string 24px
color string currentColor
stroke string | undefined
fill string currentColor

DatePicker Class Identifiers

stwui-datepicker-wrapper
stwui-datepicker-trigger
stwui-datepicker-input
stwui-datepicker-clear-wrapper
stwui-datepicker-leading-wrapper
stwui-datepicker-trailing-wrapper
stwui-datepicker-error-icon
stwui-datepicker-error
stwui-datepicker-calendar-wrapper
stwui-datepicker-previous-year
stwui-datepicker-previous-month
stwui-datepicker-current-month-wrapper
stwui-datepicker-next-month
stwui-datepicker-next-year
stwui-datepicker-actions-wrapper
stwui-datepicker-apply-clear-wrapper
stwui-datepicker-timepicker-wrapper
stwui-datepicker-label