playdeck 1.3.0
A video player you compose,
not one you configure.
Compose it from React parts, style each one with your own CSS, or hand it to your agent.
pnpm add @playdeck/reactYou pick the controls. playdeck knows what each source can do.
Every control is a component
Reorder them, drop one, or put your own between them. Nothing renders that you did not compose.
It asks before it draws
Each provider says what it can do. A control it cannot honour is left out, not shown and disabled.
One API, five sources
Native video, HLS, YouTube, Vimeo and Wistia. The source picks the provider, and nothing else changes.
0
requests to YouTube or Vimeo before play
Measured on this page. Both players below wait for a press, and this site's tests fail if anything reaches another host before it.
Unstyled, your look.
playdeck imports no stylesheet. Its parts set only the geometry they need, and the optional theme is one import. Every part carries a name, like data-playdeck-part="play-button", for your CSS or your tokens to reach. Here is one live player, shown twice: the markup is the same, and only the CSS and the source change.
Velvet CSS · 70 lines
.velvet [data-playdeck-part="viewport"] {
aspect-ratio: var(--playdeck-media-aspect-ratio, 2048 / 858);
overflow: hidden;
border-radius: 28px;
background: radial-gradient(circle at 25% 15%, #7b3fa8, #2a0f45 55%, #12061f);
color: #fff;
font-family: ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
}
.velvet [data-playdeck-part="media"] {
width: 100%;
height: 100%;
}
.velvet [data-playdeck-part="activation"] {
--playdeck-activation-fill: #fff;
width: 96px;
height: 96px;
border-radius: 999px;
box-shadow: 0 16px 48px rgb(0 0 0 / .5);
color: #2a0f45;
font: inherit;
font-size: 18px;
font-weight: 700;
cursor: pointer;
}
.velvet [data-playdeck-part="activation"]:hover {
--playdeck-activation-fill: #ffd6e5;
}
.velvet [data-playdeck-part="controls"] {
position: absolute;
inset: auto 14px 14px;
display: flex;
align-items: center;
gap: 2px;
padding: 0 10px;
border-radius: 999px;
background: rgb(18 6 31 / .72);
backdrop-filter: blur(16px);
}
.velvet [data-playdeck-part="controls"] button {
display: grid;
place-items: center;
padding: 0;
border: 0;
border-radius: 999px;
background: none;
color: #fff;
cursor: pointer;
}
.velvet [data-playdeck-part="controls"] svg {
width: 22px;
height: 22px;
}
.velvet [data-playdeck-part="seek-slider"] {
flex: 1;
min-width: 0;
}
.velvet [data-playdeck-part="seek-slider-input"] {
display: block;
width: 100%;
accent-color: #ff8fb1;
}
.velvet [data-playdeck-part="time"] {
padding: 0 6px;
font-size: 14px;
font-variant-numeric: tabular-nums;
}
.velvet [data-playdeck-part="viewport"] :focus-visible {
outline: 2px solid #ff8fb1;
outline-offset: 2px;
}Broadcast CSS · 90 lines
.broadcast [data-playdeck-part="viewport"] {
box-sizing: content-box;
aspect-ratio: var(--playdeck-media-aspect-ratio, 2048 / 858);
border: 4px solid #000;
background: #ffd60a;
color: #000;
font-family: ui-monospace, Menlo, monospace;
text-transform: uppercase;
}
.broadcast [data-playdeck-part="media"] {
width: 100%;
height: 100%;
}
.broadcast [data-playdeck-part="activation"] {
--playdeck-activation-fill: transparent;
display: flex;
align-items: flex-end;
gap: 16px;
padding: 20px 24px;
color: #ffd60a;
font: inherit;
font-size: clamp(36px, 8vw, 64px);
font-weight: 800;
line-height: .9;
letter-spacing: -.04em;
text-transform: inherit;
text-shadow: 4px 4px 0 #000;
cursor: pointer;
}
.broadcast [data-playdeck-part="activation"]::before {
content: "";
width: .62em;
height: .72em;
background: currentcolor;
clip-path: polygon(0 0, 100% 50%, 0 100%);
}
.broadcast [data-playdeck-part="activation"]:hover {
--playdeck-activation-fill: rgb(0 0 0 / .6);
}
.broadcast [data-playdeck-part="controls"] {
position: absolute;
inset: auto 0 0;
display: flex;
gap: 4px;
border-top: 4px solid #000;
background: #000;
}
.broadcast [data-playdeck-part="controls"] button {
display: grid;
place-items: center;
padding: 0;
border: 0;
border-radius: 0;
background: #fff;
color: #000;
cursor: pointer;
}
.broadcast [data-playdeck-part="controls"] button:hover {
background: #000;
color: #ffd60a;
}
.broadcast [data-playdeck-part="controls"] svg {
width: 20px;
height: 20px;
}
.broadcast [data-playdeck-part="seek-slider"] {
display: flex;
flex: 1;
align-items: center;
min-width: 0;
padding: 0 12px;
background: #fff;
}
.broadcast [data-playdeck-part="seek-slider-input"] {
width: 100%;
accent-color: #000;
}
.broadcast [data-playdeck-part="time"] {
display: flex;
align-items: center;
padding: 0 12px;
background: #fff;
font-size: 14px;
font-weight: 700;
font-variant-numeric: tabular-nums;
}
.broadcast [data-playdeck-part="viewport"] :focus-visible {
outline: 4px solid #000;
outline-offset: -8px;
}No player on this page reaches YouTube or Vimeo until you press play. All three play Sprite Fright, © Blender Studio, licensed CC BY 4.0, from the studio's own uploads to YouTube and Vimeo.
See all examples ›Small, leans on the browser.
The browser already knows how to play a video. playdeck drives the video element instead of rebuilding it, and loads a provider only when a source needs one.
Providers on demand
A page that plays MP4 ships no YouTube, Vimeo, Wistia or hls.js code. Each provider loads once a source asks for it.
Native HLS where it exists
Safari and iOS play HLS on their own, so playdeck never fetches hls.js there.
40.4 KB for an MP4
The core, the primitives and the native provider, gzipped, with React external. playdeck's CI measures it on every run.
Built for agents.
Whether you write the code or your coding agent does, playdeck leaves less to guess.
A few named parts
A player is Player.Root, Player.Viewport and Player.Media, plus the controls you pick. The quickstart below is the whole of one.
Typed all the way
playdeck is written in TypeScript and ships its types, so your editor and your agent see every prop.
Mistakes say what they are
Ask a player to autoplay while it waits for a press, or to load on sight with no Player.Viewport, and it reports an error that names the mistake.
import * as Player from '@playdeck/react';
// One API across MP4/WebM, HLS, YouTube, Vimeo and Wistia: the source decides
// which provider loads, and nothing else changes.
export const Clip = () => (
<Player.Root source="https://example.com/clip.mp4">
<Player.Viewport>
<Player.Media />
<Player.Controls>
<Player.PlayButton />
<Player.SeekSlider />
<Player.Time type="current" />
<Player.FullscreenButton />
</Player.Controls>
</Player.Viewport>
</Player.Root>
);Accessible by default.
playdeck takes care of the keyboard, focus and screen readers for you. Each line below is backed by a test in playdeck's own repo.
Every control by Tab
Every control is reachable by Tab, in order.
Shortcuts reach the video
Keyboard shortcuts mute, pause and seek the video itself.
Focus comes back
The settings menu takes focus when it opens and gives it back on Escape.
Announced, never narrated
Live regions announce changes of state, never the ticking clock.
Clean under axe
axe finds no violations in any state of the reference player.
Calm under reduced motion
A viewer who asks for reduced motion gets no autoplay, unless you opt out.
playdeck is part of deck.cool, a family of unstyled React packages that look like you and work like the browser. Meet the family ›
