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.

Purpose

A video's length in the corner of its picture (“4:12”), on a card, a list row or a search result. It is light on a dark, see-through ground in every theme and mode, so it reads over any picture, and it has no role and no focus: inside a link, it becomes part of the link's name.

M3 has no such tag; the core list's video item draws the same look for its own length. For a count or a status on an icon, use a Badge; for a label a person can act on, a Tag or a chip.

Behaviour

  • duration is in seconds, rounded down to whole seconds: m:ss, or h:mm:ss for an hour or more, under a second 0:00. A length that isn't a finite number, or is negative, draws nothing.
  • Screen readers get one text in words, in the page's language (“Length 4 minutes, 12 seconds”), visually hidden; the clock is hidden from them. label replaces those words, labels.length translates “Length”, and formatDuration replaces the clock. The core's formatClock and formatDurationWords, in @windmorph/react/primitives, write a length the same way in a sentence of your own.
  • The whole clock always shows: larger text grows the tag, and on a narrow picture it may run past the corner's inset, never past the frame. It reads left to right in every language, and its corner follows the page's direction.
  • It looks the same in light and dark mode and at every contrast level, and nothing changes when the card around it is hovered, focused or pressed. It has no motion.

The frame

MediaFrame is a one-cell grid that clips to its corner: the picture and everything over it share the cell, so nothing is positioned. Put the picture first and the tag last. ratio gives it a shape; left out, its size is yours. It is a span, so it can sit inside a link. It works out how far in the tag must sit to clear its corner (4px for corners up to 17px, 8px at 28px), from --wm-media-frame-corner, so change its corner with that token rather than a class.

In a frame of your own, make it a one-cell grid (grid *:[grid-area:1/1]) and the tag finds its corner, or pass placement="none" and place it yourself.

When not to use

For a count or a status on an icon, use a Badge; for a label a person can act on, a Tag or a chip.

See also

  • Badge: A small dot or a short count or label, placed on an anchor with BadgedBox.
  • Tag: A small, static label for a status or category: Sold, Open now, Featured. Tonal, filled or outlined, in M3, success and warning colours. Not an M3 component (@windmorph/react-pro).
  • Video player: A video player complete with nothing set: its own controls, keys, touch gestures, captions and states over a file or a stream, drawn in the theme over any picture. Not an M3 component (@windmorph/react-pro).