v7.3.0

TimeRanges
Feature

This feature provides an easy way to highlight ranges of time in a calendar's day and week views. Each time range is represented using the TimeRangeModel.

TimeRange types

Time ranges can take a few different forms:

  • A line at the startDate with optional tooltip based on the name.
  • A styled region between the startDate and endDate. The cls field is used to apply the desired style to the time range element.
  • A titled region based on the name field, between the startDate and endDate. The cls field can be used to apply the styling to the time range element. The color and iconCls fields can be used to apply a background color and icon to the header element. An optional footer can also be added.

Disabling the feature will hide all time ranges.

TimeRange DOM structure

A rendered time range element is divided into three sections: a header, body, and footer laid out horizontally across the day cell. This is achieved using flexbox column layout, but rotating the writing-mode to be vertical-rl or vertical-lr so that text is displayed vertically and the primary axis is horizontal.

The time range's cls field is applied to the encapsulating element in addition to the b-cal-time-range class. The arrangement is as follows:

  <inset>px                flexed                 <inset>px
┌────────────┬──────────────────────────────────┬────────────┐
│            │                                  │            │
│     H      │                                  │     F      │
│     e      │                                  │     o      │
│     a      │                                  │     o      │
│     d      │                                  │     t      │
│     e      │                                  │     e      │
│     r      │                                  │     r      │
│            │                                  │            │
└────────────┴──────────────────────────────────┴────────────┘

The visual order can be reversed by setting the alignment field to 'end'.

If the time range has a name, the header section will be rendered with that name and will be inset pixels wide. The header section may also include an icon if the time range has an iconCls field. The header section is rendered with the b-cal-time-range-header CSS class.

The body section occupies the space between the header and footer sections and is rendered with the b-cal-time-range-body CSS class.

If the time range has an footer, a footer section will also be rendered inset pixels wide containing that text. The footer section is rendered with the b-cal-time-range-footer CSS class.

The sections are rendered across the day cell with the name and footer text rotated. The whole element leaves the end gutter area free. To have time ranges render across the gutter area too, apply the CSS class b-cal-time-range-overlay-gutter to a cls time range's cls field.

The body section has no rendition by default, but can be styled using the cls field in addition to the b-cal-time-range-body class.

A header and footer will occupy space on the inline-start and inline-end sides of the time range. This can be reversed by specifying the alignment as 'end'.

The width of the header and footer is determined by the inset configuration of the view's layout.

The three sections of a time range can be customized using the following CSS classes:

  • .b-cal-time-range-header : The header element
  • .b-cal-time-range-body : The body element
  • .b-cal-time-range-footer : The footer element

A "part" renderer can return null to suppress visibility of a header or a footer.

Integration with ScheduleTooltip feature

The ScheduleTooltip feature's renderer will be passed hovered time ranges by default. The content may be customized as in the example below.

Resource-specific TimeRanges

To display time range elements for individual resources, you can include resourceTimeRanges in the loaded data. You can use this feature to visualize resource specific working times for example. The results are shown in views which display resources, such as DayResourceView or subviews of a ResourceView. As with regular time ranges, you can include a recurrenceRule to specify repeating patterns.

Example data showing Resource 1 with shaded days until 9am, and Resource 2 shaded until 8am in the morning.

"resourceTimeRanges" : {
    "rows" : [
      {
        "id"             : 1,
        "resourceId"     : 1,
        "startDate"      : "2026-01-26 00:00",
        "endDate"        : "2026-01-26 09:00",
        "recurrenceRule" : "FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR"
      },
      {
        "id"             : 2,
        "resourceId"     : 2,
        "startDate"      : "2026-01-26 00:00",
        "endDate"        : "2026-01-27 08:00",
        "recurrenceRule" : "FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR"
      }
   ]
}

This feature is disabled by default.

Useful configs

Config Description
renderer Custom renderer for time range elements
headerWidth Width of the time range header area (pixels or proportion)

See also

No results

Configs

Configs are options you supply in a configuration object when creating an instance of this class

Properties

Properties are getters/setters or publicly accessible variables on this class

Type definitions

CSS variables

CSS variables that can be set to adjust appearance
Name Description
--b-calendar-time-range-border-color Time range border color
--b-calendar-time-range-border-width Time range border width
--b-calendar-time-range-header-background Time range header background
--b-calendar-time-range-line-size Time range line size
--b-calendar-time-range-line-zoom-scale Time range line zoom scale
id: timeRanges

Source path

Calendar/feature/TimeRanges.js

Demo

examples/timeranges

Contents