ReferenceButtons
media-cast-button
Accessible Cast toggle button with state reflection and keyboard support
Import
Anatomy
Behavior
Toggles a Google Cast session. Clicking the button while disconnected opens the Cast device picker; clicking while connected ends the session.
The button derives its presentation from availability:
"unsupported"— the element receives the nativehiddenattribute."unavailable"— the button remains visible and focusable witharia-disabled="true"anddata-disabled, but does not open the picker. This lets a tooltip explain that no Cast device is reachable."available"— the button is fully interactive unless thedisabledprop is set.
Configurable Cast sessions come from the Google Cast extension. Add it to the player next to your media element; without it the button drives the browser’s native Remote Playback API instead, which offers no receiver or load-request configuration. See Cast to AirPlay and Chromecast for the complete setup.
Styling
Style based on cast and disabled state:
Unsupported buttons are hidden automatically. No availability selector or extra hiding CSS is required.
Accessibility
Renders a <button> with an automatic aria-label:
Override with the label prop. Keyboard activation: Enter / Space.