Knit UI
GitHub

Playground

Loading playground…

true
true
false
Playground
<YearLevel
  year="2024-01-01"
  size="md"
  withNext
  withPrevious
  fullWidth={false}
  previousLabel="Previous year"
  nextLabel="Next year"
  levelControlAriaLabel="Year"
/>

Examples

Default

The default year level (header + the month grid).

Loading example…

DefaultSourceStorybook

Custom Label

A function yearLabelFormat overrides the default YYYY label.

Loading example…

Custom LabelSourceStorybook

Bounded

Bounded — minDate/maxDate auto-disable the prev/next controls at the edges.

Loading example…

BoundedSourceStorybook

Full Width

Full-width level — the header and grid fill the container.

Loading example…

Full WidthSourceStorybook

Styled Parts

Per-slot styles sugar — round the header controls and recolor the label.

Loading example…

Styled PartsSourceStorybook

Sizes

Every size from the shared xxs…xxl cell-metrics ladder.

Loading example…

SizesSourceStorybook

Props

PropTypeDefaultDescription
year requiredstring2024-01-01A date within the displayed year (`YYYY-MM-DD`).
disabled systemboolean | undefined——
fullWidth systemboolean | undefinedfalseTake the full width of the container.
getMonthControlProps((date: DateStringValue) => Partial<PickerControlProps>) | undefined—Passes props down to each month `PickerControl`, keyed by date (wins over `styles.control`).
hasNextLevelboolean | undefinedtrueWhether the level button can zoom out to the next level.
headerControlsOrderCalendarHeaderControlName[] | undefined['previous', 'level', 'next']Order in which the controls are rendered.
levelControlAriaLabelstring | undefinedYearLevel control `aria-label`.
localestring | undefined—dayjs locale; falls back to the value defined in `DatesProvider`.
maxDatestring | Date | undefined—Maximum possible date in `YYYY-MM-DD` format or a `Date` object.
minDatestring | Date | undefined—Minimum possible date in `YYYY-MM-DD` format or a `Date` object.
monthsListFormatstring | undefined'MMM'dayjs format for the month labels.
nextDisabledboolean | undefinedfalseDisables the next control.
nextIconReactNode—Replace the next-button icon.
nextLabelstring | undefinedNext yearNext button `aria-label`.
onLevelClick(() => void) | undefined—Called when the level button is pressed.
onNext(() => void) | undefined—Called when the next button is pressed.
onPrevious(() => void) | undefined—Called when the previous button is pressed.
previousDisabledboolean | undefinedfalseDisables the previous control.
previousIconReactNode—Replace the previous-button icon.
previousLabelstring | undefinedPrevious yearPrevious button `aria-label`.
shadow system"xs" | "sm" | "md" | "lg" | "xl" | "xxs" | "xxl" | undefined——
size systemCalendarSize | undefined
xxs · xs · sm · md · lg · xl · xxl
'md'Width/font of the header controls and month cells.
styles systemSlotStyles<YearLevelStyles> | undefined—Per-slot style sugar — props spread onto the matching part (header + grid).
theme systemThemeName | null | undefined—Applies a theme to this element
withCellSpacingboolean | undefinedtrueSeparate controls/rows with spacing.
withNextboolean | undefinedtrueRender the next control.
withPreviousboolean | undefinedtrueRender the previous control.
yearLabelFormatDateLabelFormat | undefined'YYYY'dayjs format for the year label, or a function returning it.

Style slots

Every part of YearLevel can be styled through the styles prop. Explicit props on the component always win over slot styles.

SlotTargets
headerProps for the header bar (CalendarHeader root slot).
headerControlProps for each header prev/next control (CalendarHeader control slot).
headerIconProps for the header chevron glyphs (CalendarHeader icon slot).
headerLevelProps for the header level (label) control (CalendarHeader level slot).
headerLevelLabelProps for the header level label text (CalendarHeader levelLabel slot).
monthsProps for the MonthsList grid root (.List) — style props only; year is owned.
rootProps for the level root column (.Frame).
Accessibility & DOM props (2)
PropType
keyKey | null | undefined
refRef<TamaguiElement> | undefined

Plus 498 inherited style props from Box — the full Tamagui/React Native style surface, including token shorthands like p, mx, bg and c. See Tokens for the scales they accept, or the full list.

Edit this page on GitHub