Media time slider
ProA media player's position bar: where playback is, what has loaded, and the time under the pointer, to seek by pointer, touch and keyboard. Not an M3 component (@windmorph/react-pro).
import { MediaTimeSlider } from '@windmorph/react-pro';Part of Windmorph Pro, paid components on the free core, not on sale yet. See the Pro guide for what it includes and to register interest.
Props
MediaTimeSlider 19 props
The media's length in seconds. Until it is known (
0orNaN, as a media element'sdurationbefore its metadata loads), and for a live stream with no end (Infinity), the slider can't be moved and leaves the Tab order (aria-disabled): focus already on it stays, as the next media loads.A new media's length goes unknown while it loads (a media element's
durationisNaNuntil its metadata comes): that lets go of anything held for the last one, so pass the element'sdurationas it is, rather than keeping the old length meanwhile (keep the slider mounted, too: a newkeywould drop focus on it to the page). A known length that changes, as a stream's grows, lets go of a position held after a seek, never of a drag.The position in seconds (controlled).
The first position in seconds when uncontrolled.
What has loaded: drawn over the bar, behind the played part.
Seconds an arrow key moves. Page Up and Page Down move a tenth of the length, Home and End go to the start and the end, and a drag moves freely.
Turns the slider off: it can't be moved or focused.
formatTimetype((seconds: number) => string)defaultm:ss, orh:mm:ssfor an hour or longer, in the locale's digitsThe bubble's time, laid out left to right as the bar is: return a time, not a sentence in a right-to-left script.
valueTexttype((seconds: number, duration: number, chapter?: string) => string)default thelabels.positionwords, as "1 minute, 23 seconds of 10 minutes"The position in words for screen readers (
aria-valuetext);labels.unknownLengthwhile the length isn't known. While the slider has focus, its value and words stay where the person last put them, so playback doesn't have screen readers say the time every second; they follow playback again once focus leaves.The media's chapters: the bar breaks at each start (
chapter-gap), the played gradient running across the breaks as one; the chapter under the pointer grows a step; the bubble shows its title, and the position's words name it. Starts at or past the length are left out, and starts closer thanchapter-min-widthmerge.The id of the root, the slider's
group.The root element.
Events
Called as the position moves: on every move of a drag, and for each key. While dragged, and after a seek until
valuecomes within a second of where it was put (two seconds at most, for a seek the player refused), the slider shows the position it was moved to, so the player's time updates never pull the handle back.Called when a drag ends, a key changes the position or a screen reader steps it: the moment to seek.
Text
Its words, for translation. A
LabelsProvidersets them for the whole app.labels.positiontype(position: string, duration: string) => stringdefault"1 minute, 23 seconds of 10 minutes"The position as screen readers say it, from the time played and the length, each in the locale's words ("1 minute, 23 seconds").
What screen readers say while the length isn't known: before the media's metadata loads, and for a live stream with no end.
labels.inChaptertype(position: string, chapter: string) => stringdefault (position, chapter) =>${position}, ${chapter}The position with the chapter it is in, for a slider with
chapters.
Accessible name when there's no visible label ("Position", "Seek").
One of
aria-labeloraria-labelledbyis required.The id of the visible label that names the slider.
One of
aria-labeloraria-labelledbyis required.
Classes for the root; they win over the component's own (
cn()).Classes for each part.
The root, the 48px target that takes presses;
classNamegoes here too.What holds the parts, left to right in every language: their one grid cell.
The bar, 4px at rest and 8px while active.
Each loaded range.
The played part, from the start to the position.
The stretch from the start to a mouse, trackpad or pen over the bar, under the played part.
The handle, its dot resting at
thumb-size-restand full while active; it holds the focus ring.The zero-size box at the time shown that the bubble hangs from (
bubble-gapabove the active bar); moves or turns the bubble.The time bubble above the bar: the chapter's title (
data-slot="bubble-title"), on a line of its own, over the time (data-slot="bubble-time").
Inline styles for the root, e.g.
--wm-media-time-slider-*tokens.
Also accepts the root element's HTML attributes (id, data-*, event handlers).
Types
MediaTimeRanges 3 fields
A media element's buffered (TimeRanges), or anything shaped like it.
Spec status
Not part of Material Design 3: a Windmorph Pro component, built on M3's colour roles, type scale, shapes and motion. Its variants and configurations each link to a live example.
| Item | Status | Details |
|---|---|---|
| The position, the loaded ranges and the time under the pointer | Built | Configuration · States |
An hour-long media (h:mm:ss) and a length not known yet | Built | Configuration · States |
A player that seeks on onChangeEnd | Built | Use case · Player |
Over a video, in a dark ThemeScope | Built | Use case · Video |
| Built to the M3 slider, for media | Extension | M3 has no media components and its slider tracks start at 16px; this one is a 4px bar that grows to 8px with a handle while active, in the slider’s colour roles and springs, with a 48px target and the core slider’s touch handling. |
The position, the loaded ranges and the time under the pointer
BuiltConfiguration · States
An hour-long media (
Builth:mm:ss) and a length not known yetConfiguration · States
A player that seeks on
BuiltonChangeEndUse case · Player
Over a video, in a dark
BuiltThemeScopeUse case · Video
Built to the M3 slider, for media
ExtensionM3 has no media components and its slider tracks start at 16px; this one is a 4px bar that grows to 8px with a handle while active, in the slider’s colour roles and springs, with a 48px target and the core slider’s touch handling.
Theming & tokens
Set the tokens below on the slider or any ancestor; over a video, a dark ThemeScope round the controls is usually all it needs. The bubble is the core's plain tooltip, themed by its own --md-comp-plain-tooltip-* tokens. className goes on the root, the 48px target; style each part with classNames: root, parts, track, buffered, played, hover, thumb, bubbleAnchor, bubble.
| Variable | Default | Paints |
|---|---|---|
--wm-media-time-slider-track-height | 4px | The bar’s thickness at rest. |
--wm-media-time-slider-track-height-active | 8px | The bar’s thickness under the pointer, while dragged or keyboard-focused. |
--wm-media-time-slider-track-corner | var(--md-sys-shape-corner-full) | The bar’s corners. |
--wm-media-time-slider-track-color | color-mix(in srgb, var(--md-sys-color-on-surface) 12%, transparent) | The part not yet played or loaded. |
--wm-media-time-slider-buffered-color | color-mix(in srgb, var(--md-sys-color-on-surface) 38%, transparent) | The loaded parts (`buffered`), drawn over the bar. |
--wm-media-time-slider-played-color | var(--md-sys-color-primary) | The played part, from the start to the position. |
--wm-media-time-slider-played-color-end | var(--_wm-media-time-slider-played-color) | The played part’s colour at the position: another colour makes the played part a gradient across its length, so this colour is always at the playhead (the same as `played-color` by default: solid). |
--wm-media-time-slider-played-blend-start | 55% | How far along the played part the gradient begins: `played-color` until there, then blending to `played-color-end` at the position. |
--wm-media-time-slider-underlay-color | transparent | A ground under the bar alone, the bar’s size, so a see-through track over a picture keeps its contrast with the played part (a player sets it). |
--wm-media-time-slider-chapter-gap | 4px | The break in the bar at each chapter’s start. |
--wm-media-time-slider-chapter-min-width | 4px | The narrowest a chapter is drawn; starts closer than this merge. |
--wm-media-time-slider-chapter-height-hover | 10px | The thickness of the chapter under the pointer, or under the handle while dragged or keyboard-focused, a step past the active bar. |
--wm-media-time-slider-hover-color | color-mix(in srgb, var(--md-sys-color-primary) 38%, transparent) | The stretch from the played part to a mouse, trackpad or pen over the bar, where a press would land (`transparent` turns it off). |
--wm-media-time-slider-thumb-size | 16px | The handle’s diameter while active. |
--wm-media-time-slider-thumb-size-rest | 0px | The handle’s dot at rest, so a paused player can show where it is (0, no dot, by default); it grows to `thumb-size` while active. |
--wm-media-time-slider-thumb-color | var(--_wm-media-time-slider-played-color) | The handle’s dot (its `::before`). |
--wm-media-time-slider-bubble-gap | 8px | The space between the time bubble and the active bar. |
--wm-media-time-slider-spring-duration | var(--md-sys-motion-spring-spatial-fast-duration) | How long the bar takes to grow and the handle to appear (the fast spatial spring; at once under reduced motion). |
--wm-media-time-slider-spring-easing | var(--md-sys-motion-spring-spatial-fast-easing) | Their easing. |