BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/ericts-ui/play-button

Play Button

ericts-ui/play-button
FreeComponent

A circular media toggle whose glyph morphs between a play triangle and pause bars, with a ghost or frosted over-video surface.

Live preview

live · rendered by the registry
Rendered by ericts-ui on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://ui.ericts.com/r/play-button.json

Source

registry/base/ui/play-button.tsxui.ericts.com/r/play-button.json · first 6 KB
1"use client";
2
3import * as React from "react";
4import {
5 animate,
6 motion,
7 useMotionValue,
8 useReducedMotion,
9 type Transition,
10} from "motion/react";
11
12import { cn } from "@/lib/utils";
13
14// YouTube's play button is one `<path>` whose `d` is rewritten frame by frame,
15// and the shape of that data is the whole trick: the play triangle is split
16// down x=17 into two sub-paths, each written as a four-corner rounded quad.
17// The pause icon is the same two quads with different corners, so the morph is
18// a straight lerp of eight points instead of a path diff — the triangle's left
19// half straightens into the first bar while its tip unfolds into the second.
20//
21// The play numbers below are recovered from the player's own path data: the
22// corner vertices sit at (7.5, 3) / (7.5, 33) with a 3.93 tangent length, and
23// the tip is a degenerate corner pair at (33, 18).
24
25const ICON_VIEW_BOX = 36;
26const EPSILON = 1e-4;
27
28type Point = readonly [number, number];
29type Corner = { readonly point: Point; readonly radius: number };
30/** Corners run top-left → bottom-left → bottom-right → top-right. */
31type Shape = readonly Corner[];
32
33const PLAY_SHAPES: readonly [Shape, Shape] = [
34 [
35 { point: [7.5, 3], radius: 3.93 },
36 { point: [7.5, 33], radius: 3.93 },
37 { point: [17, 27.4], radius: 0 },
38 { point: [17, 8.6], radius: 0 },
39 ],
40 [
41 { point: [17, 8.6], radius: 0 },
42 { point: [17, 27.4], radius: 0 },
43 { point: [33, 18], radius: 0 },
44 { point: [33, 18], radius: 0 },
45 ],
46];
47
48const PAUSE_SHAPES: readonly [Shape, Shape] = [
49 [
50 { point: [8.5, 4.5], radius: 2.5 },
51 { point: [8.5, 31.5], radius: 2.5 },
52 { point: [15.5, 31.5], radius: 2.5 },
53 { point: [15.5, 4.5], radius: 2.5 },
54 ],
55 [
56 { point: [20.5, 4.5], radius: 2.5 },
57 { point: [20.5, 31.5], radius: 2.5 },
58 { point: [27.5, 31.5], radius: 2.5 },
59 { point: [27.5, 4.5], radius: 2.5 },
60 ],
61];
62
63// A morph is only a lerp while both icons keep the same corner count.
64if (
65 process.env.NODE_ENV !== "production" &&
66 PLAY_SHAPES.some((shape, index) => shape.length !== PAUSE_SHAPES[index].length)
67) {
68 throw new Error("play-button: play and pause shapes must share a corner count.");
69}
70
71function lerp(from: number, to: number, progress: number) {
72 return from + (to - from) * progress;
73}
74
75function round(value: number) {
76 return Math.round(value * 100) / 100;
77}
78
79function coords([x, y]: Point) {
80 return `${round(x)} ${round(y)}`;
81}
82
83/**
84// … truncated

What it pulls in

npm packages

  • motion

Files it writes

  • registry/base/ui/play-button.tsx

Facts

Registry
ericts-ui
Type
registry:ui
Access
Free
Files written
1
Licence
MIT
First indexed
2026-08-09
Last confirmed
today

Go to the source

Docs on ericts-ui ui.ericts.com EricTsai83/ericts-ui on GitHub Raw registry item This item as JSON

More from ericts-ui

All 33 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Adaptive Draweradaptive-drawerericts-uiComponentsFree2 deps
Check Animationcheck-animationericts-uiComponentsFreeno deps · 2 files
Context Cursorcontext-cursorericts-uiComponentsFree1 dep
Copy Buttoncopy-buttonericts-uiComponentsFree2 deps
Expandable Dialogexpandable-modalericts-uiComponentsFree1 dep
Expandable Tabsexpandable-tabsericts-uiComponentsFree1 dep
Expandable Toolbarexpandable-toolbarericts-uiComponentsFree1 dep
Expanding Panelexpanding-panelericts-uiComponentsFree2 deps
BlockDex

Built by

Kynth Studios

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studios

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studios

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex