Year Range Picker
Select a range of years.
Demos
Size
2026 – 2037
Usage
vue
<script setup lang="ts">
import { Accordion } from '~/components/ui/accordion'
const items = [
{ value: 'source', label: 'Do I own the source?', content: 'Yes. Copy and adapt the files.' },
]
</script>
<template>
<Accordion :items="items" />
</template>
Installation
Complete the shared installation. Copy YearRangePicker.vue and index.ts into app/components/ui/year-range-picker/.
app/components/ui/year-range-picker/YearRangePicker.vue
<script setup lang="ts">
import { AlertDialog as Primitive } from 'akaza-ui'
import { computed, useAttrs, useTemplateRef } from 'vue'
import { cn } from '../../../utils/ui'
import uiConfig from '../ui.config'
import {
alertDialogVariants,
resolveAlertDialogVariants,
type AlertDialogProps,
type AlertDialogSlots,
} from './index'
defineOptions({ inheritAttrs: false })
// Preserve Akaza defaults when optional props, including Boolean aliases, are omitted.
const props = withDefaults(defineProps<AlertDialogProps>(), {
as: undefined,
teleport: undefined,
transition: undefined,
duration: undefined,
title: undefined,
ariaLabel: undefined,
description: undefined,
ui: undefined,
modelValue: undefined,
})
defineSlots<AlertDialogSlots>()
const attrs = useAttrs()
const styles = computed(() => alertDialogVariants(resolveAlertDialogVariants(props, uiConfig)))
const mergedUi = computed(() => {
const overrides = props.ui as Record<string, string | undefined> | undefined
return Object.fromEntries(
Object.entries(styles.value).map(([part, style]) => [
part,
cn(style(), overrides?.[part], part === 'content' ? props.class : undefined),
]),
)
})
const primitiveProps = computed(() => {
const { class: _class, ui: _ui, width: _width, ...native } = props
return native
})
const primitive = useTemplateRef<InstanceType<typeof Primitive>>('primitive')
defineExpose({
get open() {
return primitive.value!.open
},
get close() {
return primitive.value!.close
},
get toggle() {
return primitive.value!.toggle
},
get titleId() {
return primitive.value!.titleId
},
get descriptionId() {
return primitive.value!.descriptionId
},
})
</script>
<template>
<component
:is="Primitive"
ref="primitive"
v-bind="{ ...primitiveProps, ...attrs }"
:ui="mergedUi"
>
<template v-for="(_, name) in $slots" #[name]="scope"
><slot :name="name as keyof AlertDialogSlots" v-bind="scope ?? {}"
/></template>
</component>
</template>
API
Variants and defaults
| Prop | Values | Default |
|---|---|---|
size | xs, sm, md, lg, xl | sm |
Models
| Model | Type | Default | Description |
|---|---|---|---|
v-model | CalendarDateRange | {} | Optional start and end years normalized to January 1. |
v-model:placeholder | CalendarDateValue | selected start or today | First visible year. |
See Range selection for preview fills and primary-colored endpoints.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
rangeColor | "secondary" | "accent" | "secondary" | Preview and committed middle fill; endpoints use primary. |
locale | string | "en-US" | Locale used for labels. |
dir | "ltr" | "rtl" | "ltr" | Reading direction. |
calendarLabel | string | "Year range picker" | Accessible root label. |
columns | number | 3 | Visual grid columns. |
yearsPerPage | number | 12 | Visible years and paging distance. |
allowNonContiguousRanges | boolean | false | Allows blocked interior years. |
maximumYears | number | — | Maximum inclusive range length. |
fixedDate | "start" | "end" | — | Keeps one endpoint fixed. |
disabled | boolean | false | Disables paging and selection. |
readOnly | boolean | false | Allows navigation but blocks selection. |
initialFocus | boolean | false | Focuses selected/current year on mount. |
minValue / maxValue | CalendarDateValue | — | Selection and paging boundaries. |
isYearDisabled | (date) => boolean | — | Marks years disabled. |
isYearUnavailable | (date) => boolean | — | Marks years unavailable. |
nextPage / prevPage | (placeholder) => CalendarDateValue | page arithmetic | Custom page calculations. |
ui | YearRangePickerUi | — | Classes for generated parts. |
Slots
| Slot | Props | Description |
|---|---|---|
previous | disabled | Previous control content. |
heading | label, items | Visible year-range heading. |
next | disabled | Next control content. |
year | date, label, selected, rangeStart, rangeEnd, inRange, highlighted, disabled, unavailable, focused | Year content and range state. |
footer | value, placeholder | Optional content after grid. |
Events
| Event | Payload | Description |
|---|---|---|
update:modelValue | CalendarDateRange | Fires after accepted range changes. |
update:placeholder | CalendarDateValue | Fires after accepted page changes. |
value-change | (range, details) | Cancelable range change. |
placeholder-change | (date, details) | Cancelable page change. |
Keyboard
| Key | Behavior |
|---|---|
| Arrow keys | Move by one year or one visual row. Horizontal movement reverses in RTL. |
Home / End | Moves to row boundary. |
PageUp / PageDown | Moves one page. |
Shift + PageUp / Shift + PageDown | Moves ten pages. |
Enter / Space | Sets range start or completes range end. |
Pointer hover and keyboard focus preview a pending range. Touch input selects each endpoint.