Skip to content

Add TimeField component#644

Open
mkernohanbc wants to merge 15 commits intomainfrom
573-timefield
Open

Add TimeField component#644
mkernohanbc wants to merge 15 commits intomainfrom
573-timefield

Conversation

@mkernohanbc
Copy link
Contributor

This PR adds a new TimeField component (based on RA TimeField), building on work done by @raarielgrace as part of DDS' hackathon.

TimeField follows the pattern of other BCDS input components:

Screenshot 2026-03-10 at 3 08 56 PM

A value can be entered by:

  • Typing digits into each segment
  • Using the arrow keys to increment/decrement each segment's value

Like DatePicker, TimeField is designed to work with objects from @internationalized/date.

By default a TimeField:

  • Uses 12-hour time (toggleable via hourCycle)
  • Accepts an hour and minute value (can be configured to hour-only or second via granularity)
  • Appends a time-zone abbreviation (toggleable via hideTimeZone)
  • Does not show leading zeroes (toggleable via shouldForceLeadingZeros)

Like other components, it supports medium/small sizes, and required/disabled/read-only/invalid states. A TimeField's value can be set or reading using value, and constrained using minValue and maxValue.

@mkernohanbc mkernohanbc added this to the Components v0.7.0 milestone Mar 10, 2026
@mkernohanbc mkernohanbc self-assigned this Mar 10, 2026
@mkernohanbc mkernohanbc added the Components Changes or issues affect the design-system-react-components package label Mar 10, 2026
@mkernohanbc mkernohanbc linked an issue Mar 10, 2026 that may be closed by this pull request
Copy link
Contributor

@ty2k ty2k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome! Very minor changes requested below, and a couple comments beyond the scope of this PR.

.bcds-react-aria-TimeField--Segment {
padding: var(--layout-padding-none);
}
.bcds-react-aria-TimeField--Segment[data-type="timeZoneName"] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might also want a rule here that accounts for the disabled input case:

TimeField disabled with timezone

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor thing that's annoying with the time zone thing, it's focus-able and looks just like the rest of the fields but can't actually be changed in this example (the example in the Storybook with this text above it: "The granularity prop sets the smallest unit. Choose from hour, minute (default) or second:").

Screen.Recording.2026-03-10.at.8.46.10.PM.mov

I don't think there's much to be done here. We could write a CSS rule for when aria-readonly="true", I guess? But it seems like timezones are not going to be much of a concern for us going forward. Maybe not worth thinking about.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is an odd thing — there is no concept anywhere in the API of the time-zone being a thing the user sets manually, so it being a focusable segment is a bit strange.

Made a change in 25ff9d2, tweaking the styling of that specific segment to at least give a bit of a cue that this is Different to the others:

Screenshot 2026-03-11 at 10 05 32 AM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've also fixed the [data-disabled] case — the time-zone now follows the styling of the rest of the segments.


<Canvas of={TimeFieldStories.Disabled} />

Use `isReadOnly` to lock a field to its current value. A read-only input can be focused and copied, but cannot be edited:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor thing here we can't do anything about it (AFAIK), but I can't for the life of me actually highlight and copy the text in the input field without copying the label and description also:

Screen.Recording.2026-03-10.at.9.00.07.PM.mov

When I do that and paste into VS Code, I get the Unicode "pop directional isolate" character coming along for the ride:

Image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are not alone on this one: adobe/react-spectrum#5285

@mkernohanbc mkernohanbc requested a review from ty2k March 11, 2026 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Components Changes or issues affect the design-system-react-components package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Time field

3 participants