Skip to content

How do I pass min and max value for DatePicker? #407

Closed Answered by Spaxterr
Spaxterr asked this question in Q&A
Discussion options

You must be logged in to vote

I ended up solving it using parseDate from @internationalized/date, but I'm open to suggestions if there are other recommended methods

<script lang="ts">
import { DatePicker } from 'bits-ui';
import { type CalendarDate, parseDate } from '@internationalized/date';

export let value: string | undefined = undefined;
export let min: string | undefined = undefined;
export let max: string | undefined = undefined;

let minDate: CalendarDate | undefined = undefined;
let maxDate: CalendarDate | undefined = undefined;
let dateValue: CalendarDate | undefined = value ? parseDate(value) : undefined;

$: if (min) minDate = parseDate(min);
$: if (max) maxDate = parseDate(max);
</script>

<DatePicker.Root 

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Spaxterr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant