<media-loop-button>
The <media-loop-button> component toggles media looping on and off. When active, the media will automatically restart after finishing playback. This component is especially made for being included inside a <media-context-menu> and <media-context-menu-item> as a playback option.
Usage
Section titled UsageThe <media-loop-button> is commonly used as part of a <media-context-menu> to allow users to toggle looping playback within an options panel.
When used in this way, selecting the button from the menu dispatches a media-loop-request event, toggling the looping behavior of the current media element.
Styling with attributes
Section titled Styling with attributesThe <media-loop-button> updates automatically with Media UI Attributes, reflecting the current looping state of the media.
You can use these attributes to style the button. For example, to visually highlight when looping is enabled:
media-loop-button[medialoop] {
color: var(--media-button-active-color, #1e90ff);
}
media-loop-button:not([medialoop]) {
opacity: 0.6;
} Reference
Section titled ReferenceAttributes
Section titled Attributes| Name | Type | Description |
|---|---|---|
disabled | boolean | The Boolean disabled attribute makes the element not mutable or focusable. |
mediacontroller | string | The element `id` of the media controller to connect to (if not nested within). |
tooltipplacement | ('top'|'right'|'bottom'|'left'|'none') | The placement of the tooltip, defaults to "top" |
notooltip | boolean | Hides the tooltip if this attribute is present |
CSS Variables
Section titled CSS Variables| Name | Default | Description |
|---|---|---|
--media-primary-color | rgb(238 238 238) | Default color of text and icon. |
--media-secondary-color | rgb(20 20 30 / .7) | Default color of button background. |
--media-text-color | var(--media-primary-color, rgb(238 238 238)) | color of button text. |
--media-icon-color | var(--media-primary-color, rgb(238 238 238)) | fill color of button icon. |
--media-control-display | display property of control. | |
--media-control-background | var(--media-secondary-color, rgb(20 20 30 / .7)) | background of control. |
--media-control-hover-background | rgba(50 50 70 / .7) | background of control hover state. |
--media-control-padding | 10px | padding of control. |
--media-control-height | 24px | line-height of control. |
--media-font | var(--media-font-weight, bold) var(--media-font-size, 14px) / var(--media-text-content-height, var(--media-control-height, 24px)) var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif) | font shorthand property. |
--media-font-weight | bold | font-weight property. |
--media-font-family | helvetica neue, segoe ui, roboto, arial, sans-serif | font-family property. |
--media-font-size | 14px | font-size property. |
--media-text-content-height | var(--media-control-height, 24px) | line-height of button text. |
--media-button-icon-width | width of button icon. | |
--media-button-icon-height | var(--media-control-height, 24px) | height of button icon. |
--media-button-icon-transform | transform of button icon. | |
--media-button-icon-transition | transition of button icon. | |
--media-button-justify-content | center | justify-content property of button. |
--media-button-padding | var(--media-control-padding, 10px) | padding of button. |
--media-cursor | pointer | cursor property. |
--media-focus-box-shadow | inset 0 0 0 2px rgb(27 127 204 / .9) | box-shadow of focused control. |