volume-state-control-demo

Previous
Docs
limeplayexample

Preview

Loading preview…
registry/default/examples/volume-state-control-demo.tsx
"use client"

import {
  SpeakerHighIcon,
  SpeakerLowIcon,
  SpeakerXIcon,
} from "@phosphor-icons/react"

import { Button } from "@/components/ui/button"
import { useMediaStore } from "@/registry/default/ui/media-provider"
import { MuteControl } from "@/registry/default/ui/mute-control"

export function VolumeStateControlDemo() {
  const muted = useMediaStore((state) => state.muted)
  const volume = useMediaStore((state) => state.volume)

  return (
    <MuteControl asChild>
      <Button size="icon" variant="ghost">
        {muted || volume === 0 ? (
          <SpeakerXIcon weight="fill" />
        ) : volume < 0.5 ? (
          <SpeakerLowIcon weight="fill" />
        ) : (
          <SpeakerHighIcon weight="fill" />
        )}
      </Button>
    </MuteControl>
  )
}

Installation

npx shadcn@latest add @limeplay/volume-state-control-demo

Usage

import { VolumeStateControlDemo } from "@/components/volume-state-control-demo"
<VolumeStateControlDemo />