• Start

  • Blogg

  • Kom igång

  • Riktlinjer

  • Komponenter

  • Changelog

  • Tillgänglighet

  • Statistik

  • Inställningar

Komponenter

Komponenter

​
​

Inga resultat hittade, prova med andra sökvillkor.

Date Picker

Date Picker

8.2.17

The Date Picker is a text field enhanced by a panel that lets the user select a date in a calendar month format.

Demo
Props
Installation
Länkar
Best practices
Tillgänglighet
Tangentbordsinteraktioner
Change log
Statistik

Demo

Props

Se fullständing dokumentation(öppnas i ny flik)
NamnTypBeskrivning

customAttribute

{ attribute: string; value: string | number }Used for tests. Clickable and requested subcomponents will be suffixed with "-[ComponentName]".

customTranslation

DeepPartialCustom translations for screen reader texts.

disabled

booleanDisables the DatePicker component.

disableFuture

booleanDisables future dates locally. Set to false and use maxDate to align with a specific timezone.

disablePast

booleanDisables past dates locally. Set to false and use minDate to align with a specific timezone.

disablePortal

booleanKeeps the calendar within the DOM hierarchy of the parent component if true.

errorHelperText

stringCustom error text that triggers an error state, overriding the default validation message.

fullWidth

booleanExpands the input field to fill the width of its parent container.

hasActionButtons

booleanDisplays Cancel and Ok buttons; onAccept triggers only on Ok.

hasWeekNumbers

booleanShows week numbers adjacent to dates when set to true.

helperText

stringAdditional descriptive text shown below the input field.

id *

stringID for the input field, enhancing accessibility by linking label and helperText.

isLoading

booleanDisplays a loading skeleton instead of the DatePicker when true.

journeyDirection

"outward" | "return"Describes the journey direction, aiding screen reader interpretation.

label *

stringText label for the DatePicker, visible to users.

lang *

"sv" | "en"Language used for localization and date formatting.

maxDate

stringDisables all dates after this date, expected in 'yyyy-MM-dd' format.

minDate

stringDisables all dates before this date, expected in 'yyyy-MM-dd' format.

onAccept

(date: string) => voidFunction called when the input value passes validation.

onChange

(event: ChangeEvent) => voidFunction called when the input field value changes.

onError

(reason: "minDateError" | "invalidDateError" | "maxDateError", value: string) => voidFunction called when a new validation error occurs.

secondaryView

"month" | "year"Allows selection of month or year directly if set.

timeZone

stringTimezone setting for the DatePicker, defaults to "Europe/Stockholm".

value *

stringThe current date value of the DatePicker, in 'yyyy-MM-dd' format.

zIndexCalendar

numberZ-index for calendar popper/drawer.

Installation

Kodexempel
npm install @sj-ab/component-library.ui.date-picker

Länkar

  • Storybook

  • Figma

  • Bit.cloud

Best practices

Adaptive design

Adaptive design

Tillgänglighet

Date Picker är en av våra viktigaste komponenter. Den måste fungera i många olika situationer: på dator, på mobilen, med mus, med tangentbord, med touch, med skärmläsare (mobil och dator) och med textförstoring.

Semantik

Date Picker kombinerar komponenterna Date Calendar och Date Field, som i sin tur bygger på motsvarande tredjepartskomponenter från MUI X.

Date Picker följer till största del designmönstret Date Picker Dialog från WAI-ARIA Authoring Practices Guide.

Date Picker Dialog Example

Responsivitet

På stora skärmar kan användaren antingen skriva in ett datum manuellt i ett Date Field, eller öppna kalendern i en Popover.

På små skärmar öppnar kalendern en Bottom Sheet med en Date Calendar. Textfält saknas i nuläget på liten skärm.

Tangentbordsstyrning

Kalendern kan styras med tangentbord både i mobil och desktopversion. På desktop kan användaren också skriva in ett ISO-formaterat datum i textfältet, t.ex. "2024-06-20".

När kalendern har fokus så kan användaren gå med piltangenterna. Vänster och höger för att gå mellan dagar, upp och ner för att gå mellan veckor.

WAI-ARIA

Kalendern är byggd som ett WAI-ARIA grid, med row, rowgroup, column, rowgroup och griditem.

Den valda dagen indikeras automatiskt med attributet aria-selected="true"

Inaktiva dagar indikeras med aria-disabled="true".

Tangentbordsinteraktioner

  • Enter / Piltangenter
    Välj ett datum i kalender

Change log

  • Attempts to rectify weird bit errors.

    8.2.2
  • Fix broken DatePicker loading state

    8.2.0
  • Upgrade to React 19

    8.1.0
  • Fix date field height om mobile

    8.0.5

Statistik

  • Importer av Date Picker

    40
  • Repos med Date Picker

    65%
  • Senaste installerade version av Date Picker

    8.2.15
  • Äldsta installerade version av Date Picker

    2.0.3