Skip to content

Duration tag

Pro

A video's length in the corner of its picture, light on a dark see-through ground over any picture, read in words as part of the card's link. Not an M3 component (@windmorph/react-pro).

import { DurationTag, MediaFrame } 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

By name or description, across the 17 props below

DurationTag 11 props

  • durationtype number | null | undefinedRequired

    The media's length in seconds (whole seconds, rounded down). Not finite or negative: nothing is drawn.

  • raisedtype booleandefault false

    Lifts it clear of something along the picture's foot, such as a progress line.

  • placementtype "bottom-end" | "bottom-start" | "top-end" | "top-start" | "none"default "bottom-end"

    Which corner of its MediaFrame (or any one-cell grid) it sits in; none leaves it in the flow, for an app that places it.

  • labeltype string

    What assistive technology reads in place of the default ("Length 4 minutes, 12 seconds").

  • formatDurationtype ((seconds: number, locale: string) => string)

    Replaces the clock ("4:12"); given the seconds and the page's locale.

  • reftype Ref<HTMLSpanElement>

    Ref to the tag.

  • idtype string

    The tag's id.

Text

  • labelstype Partial<DurationTagLabels>

    Words it says, with English defaults. A LabelsProvider sets them for the whole app.

MediaFrame 6 props

  • ratiotype number | `${number}/${number}`

    The frame's shape, e.g. 16/9; left out, its size is the app's.

  • childrentype ReactNode

    The picture (or video), then what lies over it, the DurationTag last.

  • reftype Ref<HTMLSpanElement>

    Ref to the frame.

  • idtype string

    The frame's id.

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.

  • A length on a card that is a link, read in words as part of its name

    Built

    Use case · Card

  • Raised clear of a progress line (raised)

    Built

    Configuration · Options

  • Corners (placement) and a rounder frame (--wm-media-frame-corner)

    Built

    Configuration · Options

  • Your own words and clock (label, formatDuration)

    Built

    Configuration · Options

  • Not an M3 component

    Extension

    M3 has no length tag; the core list’s video item draws the same look for its own length, from the same formatters in the core’s primitives.

  • One look in every mode

    Extension

    The clock is the theme’s light neutral on scrim at 72% in light and dark mode alike, so it keeps 4.5:1 over a white picture without a theme scope of its own.

Theming & tokens

Set the tokens below on the tag, its frame or any ancestor. The tag is a dark ThemeScope, so its clock is the dark theme's on-surface in every mode, in a theme made at run time too, on scrim at 72%, which keeps 4.5:1 over a white picture in every theme and contrast level. className goes on the tag; style each part with classNames: root, label, clock.

DurationTag tokens
VariableDefaultPaints
--wm-duration-tag-container-colorcolor-mix(in srgb, var(--md-sys-color-scrim) 72%, transparent)The ground, the same in both modes: at 72% the text keeps 4.5:1 over a white picture (under about 60% it doesn’t).
--wm-duration-tag-content-colorvar(--md-sys-color-on-surface)The clock: the dark theme’s `on-surface` (the tag is a dark scope), light in every mode.
--wm-duration-tag-cornervar(--md-sys-shape-corner-extra-small)The tag’s corners.
--wm-duration-tag-padding-inline4pxThe space at each side of the clock.
--wm-duration-tag-insetvar(--_wm-duration-tag-frame-inset, 4px)The distance from the picture’s edges: inside a `MediaFrame`, the least that clears its corners; otherwise 4px.
--wm-duration-tag-raised-inset8pxThe foot’s distance when `raised`, clear of a progress line along the picture.
MediaFrame tokens
VariableDefaultPaints
--wm-media-frame-cornervar(--md-sys-shape-corner-medium)The frame’s corners, which it paints and from which it works out how far in a tag must sit to clear the curve.