Date Strip
more-shadcn-noair/date-stripFreeComponent
A horizontal strip of dates with optional navigation.
Live preview
live · rendered by the registry
Rendered by more-shadcn-noair on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://more-shadcn.noair.fun/r/date-strip.jsonSource
1<script lang="ts">2 import { cn } from '$UTILS$';3 import { setDateStripContext } from './ctx';4 import { Button } from '$lib/components/ui/button';5 import { ChevronLeft, ChevronRight } from '@lucide/svelte';6 import type { Snippet } from 'svelte';7 import { type DateValue, getLocalTimeZone, today, startOfWeek } from '@internationalized/date';89 let {10 value = $bindable(),11 class: className,12 daysToShow = 5,13 isDateDisabled = () => false,14 onDateChange,15 children16 }: {17 value?: DateValue | undefined;18 class?: string;19 daysToShow?: number;20 isDateDisabled?: (date: DateValue) => boolean;21 onDateChange?: (date: DateValue) => void;22 children: Snippet<[{ date: DateValue }]>;23 } = $props();2425 let startDate = $state(startOfWeek(today(getLocalTimeZone()), 'en-US'));26 let slideDirection = $state<'start' | 'end'>('end');2728 const displayedDates = $derived(29 Array.from({ length: daysToShow }, (_, i) => startDate.add({ days: i }))30 );3132 function handlePrev() {33 slideDirection = 'start';34 startDate = startDate.add({ days: -daysToShow });35 }3637 function handleNext() {38 slideDirection = 'end';39 startDate = startDate.add({ days: daysToShow });40 }4142 setDateStripContext({43 selectedValue: () => value,44 onSelect: (d) => {45 value = d;46 onDateChange?.(d);47 },48 isDateDisabled,49 direction: () => slideDirection50 });51</script>5253<div class={cn('flex items-center gap-2 rounded-xl border bg-card p-1 shadow-sm', className)}>54 <Button variant="ghost" size="icon" class="h-7 w-7 shrink-0" onclick={handlePrev}>55 <ChevronLeft class="h-4 w-4" />56 </Button>5758 <div class="flex flex-1 justify-between gap-1 overflow-hidden">59 {#each displayedDates as date (date.toString())}60 {@render children({ date })}61 {/each}62 </div>6364 <Button variant="ghost" size="icon" class="h-7 w-7 shrink-0" onclick={handleNext}>65 <ChevronRight class="h-4 w-4" />66 </Button>67</div>
What it pulls in
Other registry items
More from more-shadcn-noair
All 43 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Audioaudio | more-shadcn-noair | Components | Free | no deps | |
| Audio Waveaudio-wave | more-shadcn-noair | Components | Free | no deps | |
| Autocompleteautocomplete | more-shadcn-noair | Components | Free | no deps | |
| Bannerbanner | more-shadcn-noair | Components | Free | no deps | |
| Big Calendarbig-calendar | more-shadcn-noair | Components | Free | no deps | |
| Bottom Navigationbottom-nav | more-shadcn-noair | Components | Free | no deps | |
| Canvascanvas | more-shadcn-noair | Components | Free | no deps | |
| Chipchip | more-shadcn-noair | Components | Free | no deps |
