voice-button
elevenlabs/voice-buttonFreeComponent
shadcn/ui publishes no description for this item.
Install it
npx shadcn@latest add https://raw.githubusercontent.com/elevenlabs/ui/main/apps/www/public/r/voice-button.jsonSource
1"use client"23import * as React from "react"4import { CheckIcon, XIcon } from "lucide-react"56import { cn } from "@/lib/utils"7import { Button } from "@/components/ui/button"8import { LiveWaveform } from "@/components/ui/live-waveform"910export type VoiceButtonState =11 | "idle"12 | "recording"13 | "processing"14 | "success"15 | "error"1617export interface VoiceButtonProps18 extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "onError"> {19 /**20 * Current state of the voice button21 * @default "idle"22 */23 state?: VoiceButtonState2425 /**26 * Callback when button is clicked27 */28 onPress?: () => void2930 /**31 * Content to display on the left side (label)32 * Can be a string or ReactNode for custom components33 */34 label?: React.ReactNode3536 /**37 * Content to display on the right side (e.g., keyboard shortcut)38 * Can be a string or ReactNode for custom components39 * @example "⌥Space" or <kbd>⌘K</kbd>40 */41 trailing?: React.ReactNode4243 /**44 * Icon to display in the center when idle (for icon size buttons)45 */46 icon?: React.ReactNode4748 /**49 * Custom variant for the button50 * @default "outline"51 */52 variant?:53 | "default"54 | "destructive"55 | "outline"56 | "secondary"57 | "ghost"58 | "link"5960 /**61 * Size of the button62 * @default "default"63 */64 size?: "default" | "sm" | "lg" | "icon"6566 /**67 * Custom className for the button68 */69 className?: string7071 /**72 * Custom className for the waveform container73 */74 waveformClassName?: string7576 /**77 * Duration in ms to show success/error states78 * @default 150079 */80 feedbackDuration?: number8182 /**83 * Disable the button84 */85 disabled?: boolean86}8788export const VoiceButton = React.forwardRef<89 HTMLButtonElement,90 VoiceButtonProps91>(92 (93 {94 state = "idle",95 onPress,96 label,97 trailing,98 icon,99 variant = "outline",100 size = "default",101 className,102 waveformClassName,103 feedbackDuration = 1500,104 disabled,105 onClick,106 ...props107 },108 ref109 ) => {110 const [showFeedback, setShowFeedback] = React.useState(false)111112 React.useEffect(() => {113 if (state === "success" || state === "error") {114 setShowFeedback(true)115 const timeout = setTimeout(116 () => setShowFeedback(false),117 feedbackDuration118 )119 return () => clearTimeout(timeout)120 } else {121 // Reset feedback when state changes away from success/error122// … truncated
What it pulls in
Other registry items
Files it writes
More from shadcn/ui
All 50 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| audio-playeraudio-player | shadcn/ui | Components | Free | 2 deps | |
| bar-visualizerbar-visualizer | shadcn/ui | Components | Free | no deps | |
| conversationconversation | shadcn/ui | Components | Free | 1 dep | |
| conversation-barconversation-bar | shadcn/ui | Components | Free | 1 dep | |
| live-waveformlive-waveform | shadcn/ui | Components | Free | no deps | |
| matrixmatrix | shadcn/ui | Components | Free | no deps | |
| messagemessage | shadcn/ui | Components | Free | 1 dep | |
| mic-selectormic-selector | shadcn/ui | Components | Free | no deps |
