Calendar
Fristående kalenderkomponent
import { Calendar } from '@midas-ds/components'
<Calendar aria-label='Kalender' />
October 2026
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
27 | 28 | 29 | 30 | 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Användning
Kalender kan användas när användaren ska välja ett datum eller visualisera ett valt datum. Normalt sett är DatePicker standardvalet men kalendern kan användas när inputfältet inte behövs, inte ligger i direkt anslutning till kalendern, eller om kalendern inte ska presenteras som en popover.
Calendar
Kalendern accepterar samma props som DatePicker och controlled value sätts med value respektive onChange,
uncontrolled value sätts med defaultValue.
RangeCalendar
Samma props som DateRangePicker, exempel nedan med controlled value:
import { RangeCalendar } from '@midas-ds/components'
import { DateValue } from 'react-aria-components'
export const RangeCalendarExample = () => {
const [selected, setSelected] = React.useState<{
start: DateValue
end: DateValue
} | null>(null)
return (
<>
<RangeCalendar
aria-label='Kalender'
value={selected}
onChange={setSelected}
/>
<pre>
Valda datum:{' '}
{selected &&
`${selected?.start.toString()}
till: ${selected?.end.toString()}`}
</pre>
</>
)
}
October 2026
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
27 | 28 | 29 | 30 | 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Valda datum:
Månads- och årsväljare
Sätt showMonthYearPicker för att visa månad och år som separata dropdown-väljare i headern, istället för statisk text.
Användaren kan då hoppa direkt till en annan månad eller år, utan att behöva bläddra en månad i taget.
Fungerar likadant på både Calendar och RangeCalendar (och därmed även DatePicker/DateRangePicker, som återanvänder dem).
<Calendar
aria-label='Kalender'
showMonthYearPicker
/>
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
27 | 28 | 29 | 30 | 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
API
| Name | Type | Default | Description |
|---|---|---|---|
errorMessage | string | - | |
showMonthYearPicker | boolean | false | Show month/year picker dropdowns in the header instead of the static heading, letting users jump directly to a month/year instead of paging one month at a time. |
className | ClassNameOrFunction<CalendarRenderProps<M>> | 'react-aria-Calendar' | The CSS className for the element. A function may be provided to compute the class based on component state. |
visibleDuration | DateDuration | { months: 1 } | The amount of days that will be displayed at once. This affects how pagination works. |
createCalendar | ((identifier: CalendarIdentifier) => Calendar) | - | A function to create a new
Calendar object for a
given calendar identifier. If not provided, the |
isDisabled | boolean | false | Whether the calendar is disabled. |
autoFocus | boolean | false | Whether to automatically focus the calendar when it mounts. |
value | DateValue | readonly (DateValue | null)[] | null | - | The current value (controlled). |
selectionMode | CalendarSelectionMode | 'single' | Whether single or multiple selection is enabled. |
isDateUnavailable | ((date: DateValue) => boolean) | - | Callback that is called for each date of the calendar. If it returns true, then the date is unavailable. |
minValue | DateValue | null | - | The minimum allowed date that a user may select. |
maxValue | DateValue | null | - | The maximum allowed date that a user may select. |
isReadOnly | boolean | false | Whether the calendar value is immutable. |
focusedValue | DateValue | null | - | Controls the currently focused date within the calendar. |
defaultFocusedValue | DateValue | null | - | The date that is focused when the calendar first mounts (uncontrolled). |
isInvalid | boolean | - | Whether the current selection is invalid according to application logic. |
pageBehavior | PageBehavior | visible | Controls the behavior of paging. Pagination either works by advancing the visible page by visibleDuration (default) or one unit of visibleDuration. |
firstDayOfWeek | "fri" | "mon" | "sat" | "sun" | "thu" | "tue" | "wed" | - | The day that starts the week. |
selectionAlignment | "center" | "end" | "start" | 'center' | Determines the alignment of the visible months on initial render based on the current selection or current date if there is no selection. |
weeksInMonth | number | - | The number of weeks in a month. This overrides the default set by the locale. |
defaultValue | DateValue | readonly (DateValue | null)[] | null | - | The default value (uncontrolled). |
children | ChildrenOrFunction<CalendarRenderProps<M>> | - | The children of the component. A function may be provided to alter the children based on component state. |
style | StyleOrFunction<CalendarRenderProps<M>> | - | The inline style for the element. A function may be provided to compute the style based on component state. |
render | DOMRenderFunction<"div", CalendarRenderProps<M>> | - | Overrides the default DOM element with a custom render function. This allows rendering existing components with built-in styles and behaviors such as router links, animation libraries, and pre-styled components. Requirements:
|
slot | string | null | - | A slot name for the component. Slots allow the component to receive props from a parent
component. An explicit |