ReferenceButtons
AirPlayButton
Accessible AirPlay toggle button that opens the WebKit playback target picker and reflects session state
Import
Anatomy
Behavior
Opens the WebKit AirPlay playback target picker and reflects session state. AirPlay is a WebKit-only feature, so the button reports availability: "unsupported" outside Safari (macOS and iOS). On supported platforms availability flips to "available" once Safari discovers at least one AirPlay receiver on the local network, and "unavailable" otherwise.
The button is hidden until availability is "available": the component returns null.
An explicitly disabled, otherwise available button stays visible and focusable with aria-disabled="true" and data-disabled, but does not open the picker.
The component consumes the unified remotePlayback store feature alongside CastButton: both buttons drive their state from the same feature, but each only surfaces on its supported platform (WebKit for AirPlay, Chromium for Cast).
WebKit does not expose a "connecting" intermediate state — the state slice flips directly between "disconnected" and "connected" when the AirPlay session changes. When connected, the picker itself acts as the disconnect UI.
Styling
Use data-airplay-state to swap icons or labels based on the session state:
React renders a <button> element. Add a className and use it as the selector:
Use data-disabled to style an explicitly disabled, available button:
Unavailable and unsupported buttons are hidden automatically. No availability selector or extra hiding CSS is required.
Accessibility
Renders a <button> with an automatic aria-label: “Start AirPlay” when disconnected, “Stop AirPlay” when connected. (The component also supports a "Connecting" label, but WebKit AirPlay never emits a connecting state, so that label is unreachable in practice.) Override with the label prop — either a string or a function that receives the current state. Keyboard activation: Enter / Space.