Skip to main content

WeekStrip

WeekStrip is one week of days in a row, the compact date picker at the top of booking, schedule, habit and fitness screens. Tap a day to pick it; swipe or use the arrows for the next or previous week. The month and year most of the week falls in sit above it.

It's the Calendar's day cells in a single week, so it follows the design the same way and takes the same markedDates, minDate, maxDate, isDateDisabled, renderDay and styles.

import { WeekStrip } from 'patine-ui';
Loading…
<>
  <WeekStrip value={day} onValueChange={setDay} />
  <Text style={{ textAlign: 'center', color: '#6E685E' }}>{day.toDateString()}</Text>
</>

Try the props​

Props
firstDayOfWeek
weekdayFormat
<WeekStrip
value={day}
onValueChange={setDay}
firstDayOfWeek={0}
weekdayFormat="short"
/>

Example: a habit tracker​

A habit app's week: each day you did it gets a dot, the strip can't go past today, and the button marks or unmarks the day you're looking at.

Loading…
<Box border radius="lg" padding="md" gap="md" style={{ width: '100%', maxWidth: 420 }}>
  <HStack justify="space-between">
    <VStack>
      <Text weight="semibold">Read 20 pages</Text>
      <Text size="sm" color="textSecondary">{streak}-day streak</Text>
    </VStack>
  </HStack>
  <WeekStrip value={day} onValueChange={setDay} markedDates={marked} maxDate={today} />
  <Button
    variant={done.includes(key) ? 'outline' : 'default'}
    startIcon={done.includes(key) ? <Icon name="check" size="sm" color="success" /> : undefined}
    onPress={() => setDone((d) => (d.includes(key) ? d.filter((k) => k !== key) : [...d, key]))}
  >
    {done.includes(key) ? 'Done · tap to undo' : `Mark ${key === toDateKey(today) ? 'today' : day.toLocaleDateString(undefined, { weekday: 'long' })} done`}
  </Button>
</Box>

Marked and disabled days​

markedDates adds dots, a label or a disabled flag to days, keyed by YYYY-MM-DD (toDateKey), as on the calendar. minDate, maxDate and isDateDisabled disable days, and the arrows stop at the weeks holding minDate and maxDate.

Loading…
<WeekStrip
  value={day}
  onValueChange={setDay}
  markedDates={CLASSES}
  minDate={today}
  isDateDisabled={(date) => date.getDay() === 0}
/>

Weeks​

The first day of the week comes from locale (Sunday in the US, Monday in most of Europe), or set firstDayOfWeek: 0 for Sunday to 6 for Saturday. The strip opens on the week of initialWeek, else of value, else of today, and moves to a new value's week when you set one from outside.

onWeekChange fires with the first day of the week after an arrow or a swipe, to load that week's data:

<WeekStrip value={day} onValueChange={setDay} markedDates={marks} onWeekChange={(start) => loadWeek(start)} />

showHeader={false} hides the title and arrows, leaving the days and the swipe. formatTitle(weekStart, locale) changes the title.

Props​

PropTypeDefaultDescription
valueDate | null—Selected day (controlled).
defaultValueDate | null—Initial day when uncontrolled.
onValueChange(date: Date) => void—Fires when a day is tapped.
initialWeekDatethe selected day or todayA day in the week shown first.
onWeekChange(weekStart: Date) => void—Fires with the first day of the week after paging.
firstDayOfWeeknumber (0–6)from locale, else 00 = Sunday … 6 = Saturday.
localestringdeviceWeekday and month names.
minDate / maxDateDate—Days outside are disabled, and paging stops at their weeks.
isDateDisabled(date: Date) => boolean—Disable a day.
markedDatesRecord<string, MarkedDate>—Dots, labels or disabled days, keyed by YYYY-MM-DD.
showHeaderbooleantrueShow the month title and the week arrows.
formatTitle(weekStart: Date, locale?: string) => stringthe month of the week's middle dayTitle text.
showWeekdaysbooleantrueShow the weekday names.
weekdayFormat'short' | 'narrow'from the design: 'narrow' in Material, else 'short'Weekday names: Mon or M.
enableSwipebooleantrueSwipe left or right to change weeks.
renderDay(state: DayState, theme: Theme) => ReactNode—Fully custom day cell, as on the calendar.
renderArrow(direction: 'prev' | 'next', disabled: boolean) => ReactNode—Custom arrows.
dayHeightnumber44Day cell height.
styleStyleProp<ViewStyle>—Container style.
stylesSlotStyles<CalendarSlot>—The calendar slots.
themeDeepPartial<Theme>—Theme override.
design'brand' | 'ios' | 'material' | 'web' | 'native'from PatineProviderThe look to follow, over the provider's: brand, iOS, Material or web, or 'native' for the platform's own.
testIDstring—Test ID.