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>) | undefinedPasses 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 | undefineddayjs locale; falls back to the value defined in `DatesProvider`.
maxDatestring | Date | undefinedMaximum possible date in `YYYY-MM-DD` format or a `Date` object.
minDatestring | Date | undefinedMinimum 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.
nextIconReactNodeReplace the next-button icon.
nextLabelstring | undefinedNext yearNext button `aria-label`.
onLevelClick(() => void) | undefinedCalled when the level button is pressed.
onNext(() => void) | undefinedCalled when the next button is pressed.
onPrevious(() => void) | undefinedCalled when the previous button is pressed.
previousDisabledboolean | undefinedfalseDisables the previous control.
previousIconReactNodeReplace 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> | undefinedPer-slot style sugar — props spread onto the matching part (header + grid).
theme systemThemeName | null | undefinedApplies 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.

SlotUsage
headerstyles={{ header: { … } }}
headerControlstyles={{ headerControl: { … } }}
headerIconstyles={{ headerIcon: { … } }}
headerLevelstyles={{ headerLevel: { … } }}
headerLevelLabelstyles={{ headerLevelLabel: { … } }}
monthsstyles={{ months: { … } }}
rootstyles={{ root: { … } }}
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.