<media-time-range>
The <media-time-range> component is used to indicate the current time position
in the timeline of the media, and provides controls to seek to a new time in the media.
Hovering over the time range will show a preview time code by default, and if a track with a thumbnails VTT file is configured a preview thumbnail will be shown.
Default usage
Section titled Default usagePreview thumbnails
Section titled Preview thumbnailsAdding a metadata text track labelled “thumbnails” (<track default label="thumbnails" kind="metadata" src="">)
with a valid VTT file as src will enable the preview thumbnails on hover functionality.
Custom current slot
Section titled Custom current slotAdd a time display component in the current slot that will slide along the timeline as the video progresses.
Remove preview elements
Section titled Remove preview elementsSet the preview slot to an empty element to remove the default preview elements.
Styling
Section titled StylingUsing CSS variables
Section titled Using CSS variablesThe <media-time-range> consists of several elements including an
<input type="range">
element which can be tricky to style across browsers but the <media-time-range> component
comes with targeted CSS variables that make this a breeze.
Discover all the available CSS variables.
Using attributes
Section titled Using attributesThe <media-time-range> will be updated with media UI attributes any time
your media playback state changes. You can use these attributes to apply
custom styles to your <media-time-range> element under different state conditions.
/* Make the background color yellow when paused */
media-time-range[mediapaused] {
  --media-control-background: yellow;
}
/* Make the background color red when loading (buffering) */
media-time-range[medialoading] {
  --media-control-background: red;
}Discover all the available media UI attributes.
Reference
Section titled ReferenceSlots
Section titled Slots| Name | Description | 
|---|---|
| preview | An element that slides along the timeline to the position of the pointer hovering. | 
| current | An element that slides along the timeline to the position of the current time. | 
Attributes
Section titled Attributes| Name | Type | Description | 
|---|---|---|
| disabled | boolean | The Boolean disabled attribute makes the element not mutable or focusable. | 
| aria-disabled | ||
| mediacontroller | string | The element `id` of the media controller to connect to (if not nested within). | 
Media UI Attributes
Section titled Media UI Attributes
      The media UI attributes will be set automatically by the controller if they are
      connected via nesting or the mediacontroller attribute.
      Only set these attributes manually if you know what you're doing.
    
| Name | Type | Description | 
|---|---|---|
| mediabuffered | string | Set to the buffered time ranges. | 
| mediaplaybackrate | string | Set to the media playback rate. | 
| mediaduration | string | Set to the media duration. | 
| mediaseekable | string | Set to the seekable time ranges. | 
| mediapaused | boolean | Present if the media is paused. | 
| medialoading | boolean | Present if the media is loading. | 
| mediacurrenttime | string | Set to the current media time. | 
| mediapreviewimage | string | Set to the timeline preview image URL. | 
| mediapreviewtime | string | Set to the timeline preview time. | 
CSS Parts
Section titled CSS Parts| Name | Description | 
|---|---|
| box | A CSS part that selects both the preview and current box elements. | 
| preview-box | A CSS part that selects the preview box element. | 
| current-box | A CSS part that selects the current box element. | 
CSS Variables
Section titled CSS Variables| Name | Default | Description | 
|---|---|---|
| --media-time-range-display | inline-block | displayproperty of range. | 
| --media-preview-transition-property | visibility, opacity | transition-propertyof range hover preview. | 
| --media-preview-transition-duration-out | .25s | transition-durationout of range hover preview. | 
| --media-preview-transition-delay-out | 0s | transition-delayout of range hover preview. | 
| --media-preview-transition-duration-in | .5s | transition-durationin of range hover preview. | 
| --media-preview-transition-delay-in | .25s | transition-delayin of range hover preview. | 
| --media-preview-thumbnail-background | var(--media-preview-background, var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7)))) | backgroundof range preview thumbnail. | 
| --media-preview-thumbnail-box-shadow | 0 0 4px rgb(0 0 0 / .2) | box-shadowof range preview thumbnail. | 
| --media-preview-thumbnail-max-width | 180px | max-widthof range preview thumbnail. | 
| --media-preview-thumbnail-max-height | 160px | max-heightof range preview thumbnail. | 
| --media-preview-thumbnail-min-width | 120px | min-widthof range preview thumbnail. | 
| --media-preview-thumbnail-min-height | 80px | min-heightof range preview thumbnail. | 
| --media-preview-thumbnail-border-radius | var(--media-preview-border-radius) var(--media-preview-border-radius) 0 0 | border-radiusof range preview thumbnail. | 
| --media-preview-thumbnail-border | borderof range preview thumbnail. | |
| --media-preview-time-background | var(--media-preview-background, var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7)))) | backgroundof range preview time display. | 
| --media-preview-time-border-radius | 0 0 var(--media-preview-border-radius) var(--media-preview-border-radius) | border-radiusof range preview time display. | 
| --media-preview-time-padding | 1px 10px 0 | paddingof range preview time display. | 
| --media-preview-time-margin | 0 0 10px | marginof range preview time display. | 
| --media-preview-time-text-shadow | 0 0 4px rgb(0 0 0 / .75) | text-shadowof range preview time display. | 
| --media-primary-color | rgb(238 238 238) | Default color of range bar. | 
| --media-secondary-color | rgb(20 20 30 / .7) | Default color of range background. | 
| --media-control-display | inline-block | displayproperty of control. | 
| --media-control-padding | 10px | paddingof control. | 
| --media-control-background | var(--media-secondary-color, rgb(20 20 30 / .7)) | backgroundof control. | 
| --media-control-hover-background | rgb(50 50 70 / .7) | backgroundof control hover state. | 
| --media-control-height | 24px | heightof control. | 
| --media-range-padding | var(--media-control-padding, 10px) | paddingof range. | 
| --media-range-padding-left | var(--_media-range-padding) | padding-leftof range. | 
| --media-range-padding-right | var(--_media-range-padding) | padding-rightof range. | 
| --media-range-thumb-width | 10px | widthof range thumb. | 
| --media-range-thumb-height | 10px | heightof range thumb. | 
| --media-range-thumb-border | none | borderof range thumb. | 
| --media-range-thumb-border-radius | 10px | border-radiusof range thumb. | 
| --media-range-thumb-background | var(--media-primary-color, rgb(238 238 238)) | backgroundof range thumb. | 
| --media-range-thumb-box-shadow | 1px 1px 1px transparent | box-shadowof range thumb. | 
| --media-range-thumb-transition | none | transitionof range thumb. | 
| --media-range-thumb-transform | none | transformof range thumb. | 
| --media-range-thumb-opacity | 1 | opacityof range thumb. | 
| --media-range-bar-color | var(--media-primary-color, rgb(238 238 238)) | color_valueof range bar (elapsed progress). | 
| --media-range-track-color | transparent | color_valueof range track (remaining progress). | 
| --media-range-track-backdrop-filter | backdrop-filterof range track. | |
| --media-range-track-width | 100% | widthof range track. | 
| --media-range-track-height | 4px | heightof range track. | 
| --media-range-track-border | none | borderof range track. | 
| --media-range-track-outline | outlineof range track. | |
| --media-range-track-outline-offset | outline-offsetof range track. | |
| --media-range-track-border-radius | 1px | border-radiusof range track. | 
| --media-range-track-box-shadow | none | box-shadowof range track. | 
| --media-range-track-transition | none | transitionof range track. | 
| --media-range-track-translate-x | 0px | translatex-coordinate of range track. | 
| --media-range-track-translate-y | 0px | translatey-coordinate of range track. | 
| --media-range-track-background | rgb(255 255 255 / .2) | backgroundof range track background. | 
| --media-range-track-background-backdrop-filter | backdrop-filterof range track background. | |
| --media-time-range-hover-display | none | displayof range hover zone. | 
| --media-time-range-hover-bottom | -5px | bottomof range hover zone. | 
| --media-time-range-hover-height | max(calc(100% + 5px), 20px) | heightof range hover zone. | 
| --media-range-track-pointer-background | backgroundof range track pointer. | |
| --media-range-track-pointer-border-right | border-rightof range track pointer. |