defuss-shadcn / Website / Media / audio-player
Built with: CSS
Audio PlayerBLK
Plays one audio recording with playback controls and metadata - cover art, title, show and episode, the native player and a download link. Part of the Media blocks.
On this page (4)
§Default
Cover art beside the show, title and metadata, then the native <audio controls> (preload="none") and a download link.
§Compact
data-variant='compact': no cover - title and length on one line above the player. For lists of voice notes or tracks.
§Podcast
data-variant='podcast': a large cover with a shadow, the episode, the player and the show notes in a <details>.
§CSS view file
/* -- Audio Player (website · Media) --------------------------------------- Plays one audio recording with playback controls and metadata - cover art, title, show and episode, the native player and a download link. */@layer components { /* every box in the block measures border-box - the same on any page */ :where(.mk-audio-player, .mk-audio-player *, .mk-audio-player ::before, .mk-audio-player ::after) { box-sizing: border-box; } .mk-audio-player { display: grid; grid-template-columns: 6rem minmax(0, 1fr); gap: 1rem 1.25rem; align-items: center; padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--card); color: var(--card-foreground); } .mk-audio-player-cover { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius-lg); background: var(--muted); } .mk-audio-player-body { display: grid; gap: 0.375rem; min-width: 0; } .mk-audio-player-show { color: var(--primary); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; } .mk-audio-player-title { margin: 0; font-size: 1.0625rem; font-weight: 600; line-height: 1.3; text-wrap: balance; } .mk-audio-player-meta { color: var(--muted-foreground); font-size: 0.8125rem; } .mk-audio-player-controls { grid-column: 1 / -1; display: flex; align-items: center; gap: 0.5rem; & audio { flex: 1; min-width: 0; height: 2.5rem; } } .mk-audio-player-notes { grid-column: 1 / -1; border-block-start: 1px solid var(--border); padding-block-start: 0.75rem; & summary { cursor: pointer; font-size: 0.875rem; font-weight: 600; } & summary:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: var(--radius-sm); } & p, & ul { margin: 0.5rem 0 0; color: var(--muted-foreground); font-size: 0.875rem; line-height: 1.6; } } .mk-audio-player[data-variant="compact"] { grid-template-columns: minmax(0, 1fr); gap: 0.5rem; padding: 0.75rem 1rem; & .mk-audio-player-cover { display: none; } & .mk-audio-player-body { grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 0.75rem; } & .mk-audio-player-title { font-size: 0.9375rem; } & .mk-audio-player-show { display: none; } } .mk-audio-player[data-variant="podcast"] { grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); align-items: start; padding: 1.5rem; & .mk-audio-player-cover { box-shadow: var(--shadow-xl); } & .mk-audio-player-title { font-size: 1.5rem; letter-spacing: -0.02em; } & .mk-audio-player-controls, & .mk-audio-player-notes { grid-column: auto; } & .mk-audio-player-body { gap: 0.75rem; } } /* -- Accessibility ------------------------------------------- */ @media (forced-colors: active) { .mk-audio-player { border-color: CanvasText; } }}Comments, ideas or improvements? Edit this page's source on GitHub