Calendar
Calendar widgets are Input Fields that allow the user to select a single date by interacting with a visual calendar grid.
import { gui } from '@golemui/gui-shared';
export default [ gui.inputs.calendar('appointmentDate', { hint: 'Select a date', label: 'Calendar', }),];{ "$schema": "https://golemui.com/schemas/form.schema.json", "form": [ { "kind": "input", "type": "calendar", "path": "appointmentDate", "label": "Calendar", "props": { "hint": "Select a date" } } ]}Use these props to customize your Calendar widget.
| prop | type | description |
|---|---|---|
disabledRanges | array | Array of objects ({ start: string, end?: string }) defining disabled date ranges |
hint | string | A description to display below the calendar |
maxDate | string | Maximum allowable date in ISO format |
minDate | string | Minimum allowable date in ISO format |
nextMonthAriaLabel | string | ARIA label for the next month button |
nextMonthIcon | string | Custom CSS class for the “next month” button icon |
numberOfMonths | number | Number of months to display simultaneously. Defaults to 1 |
prevMonthAriaLabel | string | ARIA label for the previous month button |
prevMonthIcon | string | Custom CSS class for the “previous month” button icon |
selectYearAriaLabel | string | ARIA label for the year-selector toggle button in the calendar header; the current year is appended. Defaults to Select year |
yearGridAriaLabel | string | ARIA label for the year-selection grid. Defaults to Year selection |
Use the property hint to add a description.
import { gui } from '@golemui/gui-shared';
export default [ gui.inputs.calendar('appointmentDate', { hint: 'Please select a valid date for your appointment', label: 'Appointment Date', }),];{ "$schema": "https://golemui.com/schemas/form.schema.json", "form": [ { "kind": "input", "type": "calendar", "path": "appointmentDate", "props": { "hint": "Please select a valid date for your appointment" }, "label": "Appointment Date" } ]}Min and Max Dates
Section titled “Min and Max Dates”Use the properties minDate and maxDate to specify the boundaries for selectable dates.
import { gui } from '@golemui/gui-shared';
export default [ gui.inputs.calendar('appointmentDate', { minDate: '2024-01-05T00:00:00.000Z', maxDate: '2024-02-21T23:59:59.999Z', defaultValue: '2024-01-21T00:00:00.000Z', }),];{ "$schema": "https://golemui.com/schemas/form.schema.json", "form": [ { "kind": "input", "type": "calendar", "path": "appointmentDate", "defaultValue": "2024-01-21T00:00:00.000Z", "props": { "minDate": "2024-01-05T00:00:00.000Z", "maxDate": "2024-02-21T23:59:59.999Z" } } ]}Number of Months
Section titled “Number of Months”Use the property numberOfMonths to display multiple months side-by-side.
import { gui } from '@golemui/gui-shared';
export default [ gui.inputs.calendar('appointmentDate', { numberOfMonths: 2, }),];{ "$schema": "https://golemui.com/schemas/form.schema.json", "form": [ { "kind": "input", "type": "calendar", "path": "appointmentDate", "props": { "numberOfMonths": 2 } } ]}Disabled Ranges
Section titled “Disabled Ranges”Use the property disabledRanges to selectively disable specific date blocks within the calendar.
import { gui } from '@golemui/gui-shared';
export default [ gui.inputs.calendar('appointmentDate', { disabledRanges: [ { start: '2024-03-10T00:00:00.000Z', end: '2024-03-15T23:59:59.999Z', }, ], defaultValue: '2024-03-21', }),];{ "$schema": "https://golemui.com/schemas/form.schema.json", "form": [ { "kind": "input", "type": "calendar", "path": "appointmentDate", "defaultValue": "2024-03-21", "props": { "disabledRanges": [ { "start": "2024-03-10T00:00:00.000Z", "end": "2024-03-15T23:59:59.999Z" } ] } } ]}Custom Icons
Section titled “Custom Icons”Use prevMonthIcon, nextMonthIcon, prevMonthAriaLabel and nextMonthAriaLabel to customize the navigation buttons.
import { gui } from '@golemui/gui-shared';
export default [ gui.inputs.calendar('date', { prevMonthIcon: 'chevron_left', nextMonthIcon: 'chevron_right', prevMonthAriaLabel: 'Go to previous month', nextMonthAriaLabel: 'Go to next month', label: 'Custom Icons Calendar', uid: 'calendar-icons', }),];{ "$schema": "https://golemui.com/schemas/form.schema.json", "form": [ { "uid": "calendar-icons", "kind": "input", "type": "calendar", "path": "date", "label": "Custom Icons Calendar", "props": { "prevMonthIcon": "chevron_left", "nextMonthIcon": "chevron_right", "prevMonthAriaLabel": "Go to previous month", "nextMonthAriaLabel": "Go to next month" } } ]}Styling
Section titled “Styling”Calendars can be styled as explained in the Styling Guide.
CSS Variables
Section titled “CSS Variables”Following you will find a list with the CSS Variables and a quick description of what you will style.
| CSS Variable | Description |
|---|---|
--gui-radius-md | Calendar container and day button border radius |
--gui-bg-default | Calendar container background color |
--gui-border-default | Default border color and cell hover border color |
--gui-space-3 | Internal padding |
--gui-calendar-change-month-button-width | Width of the next/prev buttons |
--gui-calendar-change-month-button-height | Height of the next/prev buttons |
--gui-text-default | Default text and focus border color |
--gui-text-secondary | Day button hover background color |
--gui-intent-primary-active | ”Today” border highlight color |
--gui-intent-primary | Selected day background color |
--gui-bg-disabled | Disabled day background color |
Anatomy
Section titled “Anatomy”This is the anatomy of the Calendar Widget in case you want to use your CSS styles.
<gui-calendar-input class="gui-calendar gui-field"> <gui-calendar class="gui-field"> <label class="gui-label" for="fieldUid" id="fieldUid_calendar_label"> <span class="gui-label__text">Label</span> <div class="gui-widget-hint" id="fieldUid_hint" aria-hidden="true">Hint</div> </label>
<div class="gui-widget"> <div class="gui-calendar-input" role="group" id="fieldUid_calendar" aria-labelledby="fieldUid_calendar_label" aria-describedby="fieldUid_hint" > <div class="gui-visually-hidden" aria-live="polite">March 2024</div>
<div class="gui-calendar__container"> <button type="button" class="gui-button gui-calendar__month-button gui-calendar__month-button--prev" aria-label="Previous month" > <span class="gui-caret gui-caret--left" aria-hidden="true"></span> </button>
<div class="gui-calendar__months-grid"> <div class="gui-calendar__panel"> <header class="gui-calendar__header"> <h2> <span class="gui-calendar__month-name">March</span> <button type="button" class="gui-calendar__year-selector" aria-expanded="false" aria-label="Select year, 2024" > <span class="gui-calendar__year-value">2024</span> <span class="gui-calendar__year-arrow" aria-hidden="true"> <span class="gui-caret" aria-hidden="true"></span> </span> </button> </h2> </header>
<div class="gui-calendar__days-grid" role="grid" aria-label="March 2024"> <div role="row" class="gui-calendar__rows"> <span class="gui-calendar__weekday" role="columnheader">S</span> <span class="gui-calendar__weekday" role="columnheader">M</span> <!-- More columnheader elements (7 in total) --> </div>
<div role="row" class="gui-calendar__rows"> <button type="button" role="gridcell" class="gui-calendar__day-button other-month" tabindex="-1" disabled="" aria-label="Sunday, February 25, 2024" data-date="2024-02-25" aria-selected="false" > 25 </button>
<button type="button" role="gridcell" class="gui-calendar__day-button other-month" tabindex="-1" disabled="" aria-label="Monday, February 26, 2024" data-date="2024-02-26" aria-selected="false" > 26 </button>
<button type="button" role="gridcell" class="gui-calendar__day-button other-month" tabindex="-1" disabled="" aria-label="Tuesday, February 27, 2024" data-date="2024-02-27" aria-selected="false" > 27 </button>
<button type="button" role="gridcell" class="gui-calendar__day-button other-month" tabindex="-1" disabled="" aria-label="Wednesday, February 28, 2024" data-date="2024-02-28" aria-selected="false" > 28 </button>
<button type="button" role="gridcell" class="gui-calendar__day-button other-month" tabindex="-1" disabled="" aria-label="Thursday, February 29, 2024" data-date="2024-02-29" aria-selected="false" > 29 </button>
<button type="button" role="gridcell" class="gui-calendar__day-button" tabindex="-1" aria-label="Friday, March 1, 2024" data-date="2024-03-01" aria-selected="false" > 1 </button>
<button type="button" role="gridcell" class="gui-calendar__day-button" tabindex="-1" aria-label="Saturday, March 2, 2024" data-date="2024-03-02" aria-selected="false" > 2 </button> </div> <!-- More row elements (7 in total) --> </div> </div> </div>
<button type="button" class="gui-button gui-calendar__month-button gui-calendar__month-button--next" aria-label="Next month" > <span class="gui-caret gui-caret--right" aria-hidden="true"></span> </button> </div> </div> </div> </gui-calendar></gui-calendar-input>