ui icon indicating copy to clipboard operation
ui copied to clipboard

Date Picker missing styles for captionLayout="dropdown" | "dropdown-buttons"

Open mirashif opened this issue 2 years ago • 4 comments

image

Pass fromYear, toYear to get the above result.

<Calendar
  mode="single"
  selected={field.value}
  onSelect={field.onChange}
  disabled={date =>
    date > new Date() || date < new Date('1900-01-01')
  }
  initialFocus
  captionLayout="dropdown-buttons"
  fromYear={1900}
  toYear={new Date().getFullYear()}
/>

mirashif avatar May 31 '23 11:05 mirashif

Hey :v: Relative to : https://github.com/shadcn/ui/pull/320 ?

I was also looking for this for Birthdate picker.

I adjusted some styles so that it's correct and functional while waiting for the captionLayout="dropdown-buttons" mode to be styled (I do not change the style of the dropdowns). image

styles.css (global)

.rdp [aria-hidden="true"]{
    @apply hidden;
}

.rdp-vhidden{
    @apply hidden;
}

Calendar.tsx (shadcn one):

<DayPicker
     ...
     classNames={{
        ...
        month: 'space-y-4',
-       caption: 'flex justify-center pt-1 relative items-center',
-       caption_label: 'text-sm font-medium',
+       caption: 'flex justify-between pt-1 relative items-center gap-2 px-2',
+       caption_label: 'text-sm font-medium capitalize',
+       caption_dropdowns: 'flex justify-center gap-2',
-       nav_button_previous: 'absolute left-1',
-       nav_button_next: 'absolute right-1',
        ...
    }}
>

Thisisjuke avatar Jun 06 '23 10:06 Thisisjuke

This was unfortunate to see this obvious issue. In scenarios like DOB, the calendar is near impossible to use.

apudiu avatar Oct 24 '23 16:10 apudiu

Same issue here. @Thisisjuke solution works pretty well for me

agusgarcia3007 avatar Feb 14 '24 01:02 agusgarcia3007

Yes, this is an issue and should be resolved ASAP. Thank you for a temporary fix @Thisisjuke

Hey ✌️ Relative to : #320 ?

I was also looking for this for Birthdate picker.

I adjusted some styles so that it's correct and functional while waiting for the captionLayout="dropdown-buttons" mode to be styled (I do not change the style of the dropdowns). image

styles.css (global)

.rdp [aria-hidden="true"]{
    @apply hidden;
}

.rdp-vhidden{
    @apply hidden;
}

Calendar.tsx (shadcn one):

<DayPicker
     ...
     classNames={{
        ...
        month: 'space-y-4',
-       caption: 'flex justify-center pt-1 relative items-center',
-       caption_label: 'text-sm font-medium',
+       caption: 'flex justify-between pt-1 relative items-center gap-2 px-2',
+       caption_label: 'text-sm font-medium capitalize',
+       caption_dropdowns: 'flex justify-center gap-2',
-       nav_button_previous: 'absolute left-1',
-       nav_button_next: 'absolute right-1',
        ...
    }}
>

tmahir99 avatar Mar 11 '24 13:03 tmahir99

This issue has been automatically closed because it received no activity for a while. If you think it was closed by accident, please leave a comment. Thank you.

shadcn avatar Jun 30 '24 23:06 shadcn