Hulian UIv0.93.5413 components0 components
  • Start
  • Components
  • Blocks
  • Pages
  • Demos
  • Changelog
ChineseEnglish
  • ComponentsComponents
  • ThemeTheme

Collections

  • QuestionCard
  • Table
  • Book3D
  • ProTable
  • PricingTable
  • JsonViewer
  • EditableTable
  • List
  • Descriptions
  • RowActions
  • Tree
  • Card
  • Carousel
  • Video
  • Audio
  • BentoGrid
  • Image
  • MagicCard
  • AnimatedList
  • Marquee
  • Sortable
  • Kanban
  • DesignCanvas
  • LayerTree
  • StageDraw
  • SlideDeck
  • PresenterView
  • ComponentPicker
  • EventStream
  • QueueLane
  • DocumentSheet
  • Novel reader
  • Scheduler
  • Org classroom
  • Danmaku
  • LiveChat
  • LivePlayer
  • LogViewer
  • FileTree
  • CodeReviewThread
  • VirtualList
  • InfiniteScroll
  • LogoLoop
  • BounceCards
  • CardSwap
  • ChromaGrid
  • CircularGallery
  • DomeGallery
  • FlyingPosters
  • InfiniteMenu
  • MagicBento
  • ScrollStack
  • ProfileCard
  • TiltedCard
  • PixelCard
  • DecayCard
  • ReflectiveCard
  • Folder

Charts and Diagrams

  • Flow
  • Diagram
  • Paper
  • SequenceDiagram
  • Sankey
  • Sparkline
  • Funnel
  • Treemap
  • Gantt
  • Heatmap
  • ContributionGraph
  • Legend
  • Chart
  • WorldMap

Information

  • ImageViewer
  • LiveProductCard
  • DiffStat
  • ScoreRing
  • ScoreScale
  • Badge
  • Dot
  • StatusDot
  • Chip
  • FilterChip
  • Coupon
  • Tag
  • Annotation
  • Avatar
  • AvatarCircles
  • User
  • QRCode
  • Comment
  • RelativeTime
  • GitCommit
  • DeployStatus
  • ShieldBadge
  • AwardBadge
  • CreditCard
  • IconTile

Metrics

  • Stat
  • Statistic
  • Meter
  • Timeline
  • NumberTicker

Placeholders

  • Empty
  • Skeleton
  • Watermark

Audio

audio

Lightweight theme-tokenized audio player for form previews and compact inline table playback.

Usage

Form preview (md)

Default layout for previewing uploaded audio in forms with title, play/pause, seek bar, and mute.

campaign-bgm.mp3
00:00 / 02:05
tsx
<Audio src={url} title="campaign-bgm.mp3" defaultDuration={125} />

Compact table cell player (sm)

size="sm" is a 32px single-row bar that fits directly inside admin table cells.

00:00 / 00:48
tsx
<Audio src={url} size="sm" defaultDuration={48} />

When to Use

Use it to preview uploaded audio in forms or play short audio clips inline inside admin table rows. It follows the design tokens consistently across light/dark modes and browsers, replacing raw <audio controls />.

For video playback use Video; for recording triggers use VoiceRecord.

Import

ts
import { Audio } from "@hulianui/ui"

Props

NameTypeDefaultDescription
src*string—Audio source URL (any format natively supported by the browser)
titlestring—Optional track title shown above the progress bar in size="md", also used as the accessible name fallback
size"sm" | "md""md"sm is a 32px single-row compact bar for table cells; md is suited for form previews
preload"none" | "metadata" | "auto""metadata"Native <audio preload> strategy
loopbooleanfalseLoops playback when finished
autoPlaybooleanfalseAttempts automatic playback (subject to browser autoplay policies)
mutedbooleanfalseInitial muted state
defaultDurationnumber—Known duration in seconds shown before audio metadata loads
disabledbooleanfalseDisables playback and seeking controls
onPlay() => void—Called when playback starts
onPause() => void—Called when playback pauses
onEnded() => void—Called when playback ends
onTimeUpdate(currentTime: number, duration: number) => void—Called as playback time updates (current seconds, total seconds)
onError() => void—Called when loading or decoding fails
Extends HTMLAttributes<HTMLDivElement> (except the media callbacks above and title).

Pitfalls

  • When rendering many players in a table, keep preload="metadata" or use preload="none" together with the API-provided defaultDuration to avoid fetching dozens of audio files up front.

Related

Video · VoiceRecord

Playground

campaign-bgm.mp3
00:00 / 02:05
<Audio src="/audio/bgm.mp3" size="md" defaultDuration={125} />
PreviousVideoData DisplayNextBentoGrid

On this page

  • Usage
  • Documentation
    • When to Use
    • Import
    • Props
    • Pitfalls
    • Related
  • Playground