Video player settings
ProA video player's settings: a small panel over the picture at the player's corner whose rows open pages in its place (speed, captions, quality), a bottom sheet on phones. Not an M3 component (@windmorph/react-pro).
import { VideoPlayerSettings, VideoPlayerSettingsTrigger, VideoPlayerSettingsItem, VideoPlayerSettingsSwitch, VideoPlayerSettingsChoice, VideoPlayerSettingsSpeed, VideoPlayerSettingsPage } 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
The settings of a video player: a small panel that opens inside the player, over the picture, at its end corner. Its first page is a short list of rows, each with what is chosen (“Quality Auto (720p) ›”); a row's page takes the panel's place under a header that goes back, and the panel grows or shrinks to each page from its corner. On a phone the same pages are a bottom sheet.
M3's menus open submenus beside the item, hold only menu items, sit against their trigger and are modal; this panel holds a page that isn't a menu, rows with a value, a second line and a badge, sits at its element's corner whatever opened it, and leaves the video playing. For a menu of actions, use the core Menu.
In a player, or alone
- In a
VideoPlayer'ssettingsslot nothing else is written: the player draws the Settings button (a gear that turns as it opens, withsettingsBadgeon it), and gives the corner, the insets and the most height. With no rows of its own, the panel draws Playback speed, Captions and Loop from the player, and Autoplay and Rotate where the bar has no room for them; your rows go after them, anddefaultRows={false}drops them. Quality is always yours. - As a function,
childrenplaces the player's rows among yours, in the order it returns them:{(rows) => <>{rows.loop}{rows.speed}<Quality />{rows.captions}</>}.rowsholdsspeed,captions,loop,autoplayandrotate, eachnullwhere it doesn't apply (no caption tracks, noonAutoplayNextChange, not rotatable, or outside a player). A row left out doesn't show, and opening focuses the first row placed. Autoplay and Rotate still show only where the bar has no room for them. - Alone,
VideoPlayerSettingsTriggertakes your button first, then the settings, and gives the buttonaria-haspopup,aria-expanded,aria-controlsanddata-open. The panel opens in the positioned element you name (container), at a corner (placement,bottom-endby default), and keeps its own dark scope.
Rows and pages
VideoPlayerSettingsItem: an action (onAction), closing the panel unlesscloseOnAction={false}.VideoPlayerSettingsSwitch: a switch at the row's end, switching in place (selected,onChange).VideoPlayerSettingsChoice: a page of one choice fromoptions(each with a label, a second line, a badge or disabled), the chosen one ticked. A choice closes the panel at once and hands focus back to the button;afterSelect="back"goes back instead.valueLabelshows a value other than the option's label (“Auto (720p)”).VideoPlayerSettingsSpeed: the speed page, with the speed in large figures, a thin slider between Slower and Faster, and a row of common speeds (1, 1.25, 1.5 and 2 by default, “Normal” under 1). A speed between two presets selects none. A preset can carry a caption and a mark before its figure; a disabled one doesn't change the speed and callsonPresetPress, for a speed behind a subscription.labelrenames the row;formatValueandlabels.presetValuewrite the speed and a preset's figure.VideoPlayerSettingsPage: a page of your own content under the same header.- Every row takes an
icon, alabel, avalue, adescriptionand abadge(an option too). A text badge is read after the label (“1080p HD”); one that isn't text is read as itsbadgeLabel. Thedescriptiondescribes the row rather than joining its name. Itsidnames its page forpageandonPageChange. A row hidden by CSS is skipped by the keys, and a page opens on its first row that shows. - Going back: the header, Escape, or the arrow key pointing back returns to the first page, focus on the row the page was opened from. Escape on the first page closes it.
Behaviour
- It isn't modal: no scrim, no focus trap, no scroll lock. The video plays on and the scrubber stays live. A press outside the panel closes it and does nothing else to what is under it in the player; a press on another control closes it and that control acts. Tab past its last control closes it too.
- It keeps its corner and its width (320px, never wider than its element less its insets) from page to page; only its height changes, from its anchored edge, and a page taller than the room scrolls inside. In full screen and theater it sits at the same corner of the larger player.
- Keys pressed inside are its own: none reach the player, so K, M, F and the digits don't act on the video while it is open.
- Under 600px of window (
presentation="auto", decided as it opens) the same pages are a coreBottomSheetin the theme's colours, with M3's touch sizes on the speed page; a window crossing 600px while open closes it.panelandsheetpick one. - It opens and closes with a 50ms fade; pages slide a full width in 150ms as the height follows; a choice closes it at once. Under reduced motion only the fade stays.
When not to use
For a menu of actions, use a Menu; for settings of a page, a List of switches.
See also
- 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).
- Menu: A temporary list of choices anchored to a trigger, with groups, selection, submenus and context menus, or a bottom sheet on phones.
- Sheets: Bottom and side sheets for supplementary content, modal or standing in the layout.