Time Selection
Time Selection components allow users to specify a time, timeframe or range of time (beginning and end).
- Standard Time Select
- Examples
- Developer Notes
- Accessibility Notes
Standard Time Select
There are several controls for capturing a single time. A select input is the most common:
When to Use
- Use this variation when a limited set of times is available. For instance, even and uneven time increments or timeframes (morning, afternoon, etc.).
When Not to Use
- Do not use when the user is likely to want to specify an exact time, such as 11:48 a.m. A Time Text Input would be preferred.
Examples
- Single Time Select (shown above)
- Time Range Slider
- Time Range Select Input
- Time Text Input
Examples
Time Range Slider
When to Use
- To select a beginning and end time.
- To indicate a minimum and maximum time value.
- Recommended for touch displays.
When Not to Use
- Do not use for fine/exact time selection.
Time Range Select Input
The Time Range Select provides similar functionality as the Time Range Slider, but it is better suited to applications in which the user is more likely to be using a keyboard.
Time Text Input
When to Use
- When a user can specify an exact time (for example, 10:42 a.m.) or select from a list of time increments.
When Not to Use
- Not recommended for touch applications.
Developer Notes
Single Time Select and Time Range Select Input
The Single Time Select and Time Range Select components are a reuse of the Select Input component. Refer to the Select Input component documentation for details on setup and configurations.
Time Range Slider
Use of the Time Range Slider requires a JavaScript helper. It can be instantiated using new Spark.TimeRangeSlider(el)
. It implements the Messaging and Validation mixins, and provides mechanisms for getting and setting the value.
The following options may be passed when using new Spark.TimeRangeSlider(el, {});
:
For all available methods and full API, refer to the Time Range Slider API documentation.
HTML Attribute Configurations
The following attributes/configurations should be set on the Time Inputs’ markup to set the default positions of the Time Range Slider handles and the width of the range for each handle:
12-hour Time Range Slider
24-hour Time Range Slider
Disabled Time Range Slider
Time Text Input
Use of the Time Text Input requires a JavaScript helper. It can be instantiated using new Spark.TimeTextInput(el)
. It implements the Messaging and Validation mixins, and provides mechanisms for getting and setting the value.
The following options may be passed when using new Spark.TimeTextInput(el, {});
:
For all available methods and full API, refer to the Time Text Input API documentation.
12-hour Time Text Input
24-hour Time Text Input
Time Text Input with Preset Value
When using a Time Text Input with a preset value
, ensure that the value is set in 24-hour format.
Disabled Time Text Input
Time Text Input with Error
Accessibility Notes
Time Range Slider
Each input should have an id
attribute set with a unique value on the page. The value of this attribute will be used as the value of the aria-controls
property that is set on the corresponding Time Range Slider.
The following attributes and properties should be set on the spark-slider__handle
elements to ensure that assistive technologies are able to identify the component appropriately and provide meaningful information to users.
- An ARIA
role="slider"
should be set to identify the element as a slider, as this element is the operable control that represents the value of the slider. - The
aria-orientation
property is an optional attribute that can be set on a Time Range Slider handle. The default value of this property if not explicitly defined ishorizontal
. A value ofvertical
is also acceptable if your slider is vertical in nature. Keep in mind that a vertical variation of the Time Range Slider is not provided within Spark. - Use the
aria-valuemin
andaria-valuemax
attributes to indicate to assistive technologies what the minimum and maximum values of the Time Range Slider are. The values set should matchmin
andmax
values set on the Time Range Slider. - Use the
aria-valuenow
andaria-valuetext
attributes to indicate to assistive technologies what the current value of the Time Range Slider is. When changed by the user, Javascript will be used to update the attributes with the new values. - If a Time Range Slider is disabled, ensure that the
disabled
attribute is present on theinput
element, and that thetabindex="-1"
attribute and value are set on the Time Range Slider handle. If the Time Range Slider is programmatically disabled or enabled, these attributes will be set or removed using Javascript. - An
aria-label
property should be set as a text value is not provided on thebutton
element. - An
aria-controls
property with a value matching theid
of the associated input as already mentioned above.