### UserVideoComponent: Basic Camera Control Setup Source: https://voiceuikit.pipecat.ai/components/UserVideoControl This example demonstrates a basic setup of the UserVideoComponent, showing how to provide available cameras and handle the camera selection and toggle logic via props. It logs actions to the console for demonstration purposes. ```jsx import { UserVideoComponent } from "@pipecat-ai/voice-ui-kit"; console.log("Toggle camera")} availableCams={[ {deviceId: "cam1", label: "Built-in Camera"}, {deviceId: "cam2", label: "External USB Camera"}, ]} selectedCam={{deviceId: "cam1", label: "Built-in Camera"}} updateCam={(deviceId) => console.log("Selected:", deviceId)} isCamEnabled={true} /> ``` -------------------------------- ### DeviceDropDownComponent Initial Configuration Source: https://voiceuikit.pipecat.ai/components/DeviceDropDown Shows the initial setup of the `DeviceDropDownComponent` with specific available devices and a selected device. This example highlights the core props required for device selection functionality. ```javascript import { Button, DeviceDropDownComponent } from "@pipecat-ai/voice-ui-kit"; console.log("Selected:", deviceId)} > ``` -------------------------------- ### Install Pipecat Client SDK Source: https://voiceuikit.pipecat.ai/index Installs the necessary packages for using the Voice UI Kit with the Pipecat Client SDK. This includes the main client and React bindings. ```bash npm install @pipecat-ai/client-js @pipecat-ai/client-react ``` -------------------------------- ### Install Voice UI Kit Source: https://voiceuikit.pipecat.ai/index Installs the core Voice UI Kit library using npm. This is the first step to integrating the kit into your project. ```bash npm install @pipecat-ai/voice-ui-kit ``` -------------------------------- ### LED Component Sizing Example Source: https://voiceuikit.pipecat.ai/primitives/led Illustrates how to control the size of the LED component using Tailwind's `size-*` utilities applied via the `className` prop. It shows examples of small, default, and larger sizes. ```javascript import { LED } from "@pipecat-ai/voice-ui-kit";
``` -------------------------------- ### LED Component Basic States Example Source: https://voiceuikit.pipecat.ai/primitives/led Illustrates different basic states of the LED component, including off, on, blinking, and both on and blinking. This example utilizes flexbox for layout and gap utilities for spacing. ```javascript import { LED } from "@pipecat-ai/voice-ui-kit";
``` -------------------------------- ### DeviceSelect with Guide Content Source: https://voiceuikit.pipecat.ai/components/DeviceSelect Demonstrates adding guide content to the DeviceSelect component's trigger. This is useful for providing additional context or instructions to the user alongside the device selection prompt. ```javascript import { DeviceSelect } from "@pipecat-ai/voice-ui-kit"; ``` -------------------------------- ### Install Three.js for Plasma Visualizer Source: https://voiceuikit.pipecat.ai/visualizers/plasma-visualizer The PlasmaVisualizer component relies on WebGL and Three.js. This snippet shows how to install Three.js using npm, yarn, or pnpm as a project dependency. ```bash npm install three # or yarn add three # or pnpm add three ``` -------------------------------- ### Install WebRTC Transport Package Source: https://voiceuikit.pipecat.ai/index Installs a transport package for real-time communication. Choose between `@pipecat-ai/small-webrtc-transport` or `@pipecat-ai/daily-transport` based on your needs. ```bash npm install @pipecat-ai/small-webrtc-transport # or npm install @pipecat-ai/daily-transport ``` -------------------------------- ### Multiple Transcript Overlays Example (React) Source: https://voiceuikit.pipecat.ai/components/TranscriptOverlay Shows how to render multiple TranscriptOverlay components simultaneously to display both bot and user speech transcripts side-by-side. This setup requires the components to be within a PipecatClientProvider context. ```jsx import { TranscriptOverlay } from "@pipecat-ai/voice-ui-kit";

Bot Speech

User Speech

``` -------------------------------- ### Basic Panel Implementation in React Source: https://voiceuikit.pipecat.ai/primitives/panel Demonstrates the fundamental structure of a Panel component, including its header and content areas. This basic setup is useful for general-purpose layout containers. ```jsx import { Panel, PanelHeader, PanelTitle, PanelContent } from "@pipecat-ai/voice-ui-kit"; Hello world My Panel ``` -------------------------------- ### Scoped UI Kit Styling Example Source: https://voiceuikit.pipecat.ai/styling Provides an HTML example demonstrating the effect of scoped styles in Voice UI Kit. Elements with the 'vkui:flex' class inside a '.vkui-root' div are correctly styled, while those outside are not, highlighting the isolation provided by scoped CSS. ```html
✅ Scoped correctly
❌ Not scoped
``` -------------------------------- ### Select Component with Guide Element (React) Source: https://voiceuikit.pipecat.ai/primitives/select Shows how to integrate a guide element within the Select component's trigger. This enhances usability by providing context or a label directly within the trigger area, alongside the placeholder. It uses SelectGuide in addition to other Select components. ```javascript import { Select, SelectTrigger, SelectGuide, SelectValue, SelectContent, SelectItem } from "@pipecat-ai/voice-ui-kit"; ``` -------------------------------- ### LED Component Styling with Classes Source: https://voiceuikit.pipecat.ai/primitives/led Shows how to apply custom styling to the LED component using the `className` prop. This example adds a rounded-full class to all LED instances, demonstrating consistent styling application. ```javascript import { LED } from "@pipecat-ai/voice-ui-kit";
``` -------------------------------- ### Card Sizing Examples in React Source: https://voiceuikit.pipecat.ai/primitives/card Illustrates how to control the size of the Card component using the 'size' prop. Examples show 'sm', 'md', 'lg', and 'xl' sizes, each with corresponding content and import statements. This helps in visualizing and choosing the appropriate card dimensions. ```jsx import { Card, CardHeader, CardTitle, CardContent, } from "@pipecat-ai/voice-ui-kit"; <> Small Card
size="sm"
Medium Card
size="md"
Large Card
size="lg"
Extra Large Card
size="xl"
``` -------------------------------- ### Basic Card Implementation in React Source: https://voiceuikit.pipecat.ai/primitives/card Demonstrates the basic structure of the Card component using React. It imports necessary components from '@pipecat-ai/voice-ui-kit' and renders a card with a header, title, content, divider, and footer. This serves as a foundational example for using the Card. ```jsx import { Card, CardHeader, CardTitle, CardContent, CardFooter, Divider } from "@pipecat-ai/voice-ui-kit"; Card Title General purpose card content. Card Footer ``` -------------------------------- ### Full Example of Conversation UI with Scrolling Source: https://voiceuikit.pipecat.ai/hooks/usePipecatConversation A comprehensive example demonstrating the `usePipecatConversation` hook. It includes rendering messages, displaying timestamps, and automatically scrolling to the latest message using a `useRef` and `useEffect` hook. ```typescript import React, { useEffect, useRef } from "react"; import { usePipecatConversation } from "@pipecat-ai/voice-ui-kit"; export function ConversationExample() { const { messages } = usePipecatConversation(); const endRef = useRef(null); useEffect(() => { endRef.current?.scrollIntoView({ behavior: "smooth" }); }, [messages]); return (
{messages.map((m, i) => (
[{m.role}] {typeof m.content === "string" ? m.content : "[component]"} {new Date(m.createdAt).toLocaleTimeString()}
))}
); } ``` -------------------------------- ### Setup PipecatAppBase for Conversation Provider Source: https://voiceuikit.pipecat.ai/hooks/usePipecatConversation Demonstrates how to set up the PipecatAppBase component, which automatically includes the ConversationProvider. This provider is essential for managing conversation state and processing RTVI events. ```typescript import { PipecatAppBase, usePipecatConversation } from "@pipecat-ai/voice-ui-kit"; export default function App() { return ( ); } ``` -------------------------------- ### Panel with Adaptive Buttons in React Source: https://voiceuikit.pipecat.ai/primitives/panel Shows how to integrate buttons within a Panel's content area, utilizing container queries for responsive sizing. Note: The `ArrowRightIcon` component used in this example is not defined and will result in a `ReferenceError`. ```jsx import { Panel, PanelHeader, PanelTitle, PanelContent, Button, ButtonGroup, ArrowRightIcon } from "@pipecat-ai/voice-ui-kit"; Actions ``` -------------------------------- ### Basic usePipecatEventStream Hook Usage Source: https://voiceuikit.pipecat.ai/hooks/usePipecatEventStream Demonstrates basic setup of the usePipecatEventStream hook with maxEvents configuration. Shows how to render recent events in a list format with a clear button to reset the event buffer. ```typescript import { usePipecatEventStream } from "@pipecat-ai/voice-ui-kit"; export function RecentEvents() { const { events, clear } = usePipecatEventStream({ maxEvents: 100 }); return (
    {events.map((e) => (
  • {e.type} – {e.timestamp.toLocaleTimeString()}
  • ))}
); } ``` -------------------------------- ### Basic Connect Button with usePipecatConnectionState Source: https://voiceuikit.pipecat.ai/hooks/usePipecatConnectionState Simple example showing how to use usePipecatConnectionState to create a connect button that displays different text based on connection status and disables when not connected. ```typescript import { usePipecatConnectionState } from "@pipecat-ai/voice-ui-kit"; export function ConnectButton() { const { isConnected, isConnecting } = usePipecatConnectionState(); return ( ); } ``` -------------------------------- ### DeviceSelectComponent (Headless Variant) Example Source: https://voiceuikit.pipecat.ai/components/DeviceSelect Demonstrates the headless DeviceSelectComponent, which accepts available devices and callbacks as props. This allows for flexible integration with custom state management solutions. It requires manual provision of device data and selection handling. ```javascript import { DeviceSelectComponent } from "@pipecat-ai/voice-ui-kit"; // Example with mock data const mockDevices = [ { deviceId: "mic1", label: "Built-in Microphone" }, { deviceId: "mic2", label: "External USB Mic" }, ]; function Demo() { return ( console.log("Selected:", deviceId)} /> ); } render(); ``` -------------------------------- ### Card Variant Examples in React Source: https://voiceuikit.pipecat.ai/primitives/card Showcases the different 'variant' options available for the Card component, including 'destructive' and 'success'. Each example includes the necessary imports and JSX to render cards with these specific visual styles. This is useful for semantic differentiation. ```jsx import { Card, CardHeader, CardTitle, CardContent, } from "@pipecat-ai/voice-ui-kit"; <> Destructive Card
variant="destructive"
Success Card
variant="success"
``` -------------------------------- ### Complete Connection Controls with Conditional Rendering Source: https://voiceuikit.pipecat.ai/hooks/usePipecatConnectionState Full example implementing connection controls with dynamic button text, status LED color coding, and loading spinner. Shows how to handle both connect and disconnect actions with visual feedback based on connection state. ```typescript import React from "react"; import { usePipecatConnectionState } from "@pipecat-ai/voice-ui-kit"; export function ConnectionControls() { const { isConnected, isConnecting, isDisconnected } = usePipecatConnectionState(); const getButtonText = () => { if (isConnected) return "Disconnect"; if (isConnecting) return "Connecting..."; return "Connect"; }; const getStatusColor = () => { if (isConnected) return "green"; if (isConnecting) return "yellow"; return "red"; }; return (
{isConnecting && (
)}
); } ``` -------------------------------- ### Basic Button Group Usage Source: https://voiceuikit.pipecat.ai/primitives/buttongroup Demonstrates how to import and use the Button and ButtonGroup components to group buttons. This basic setup creates a row of buttons with shared styling. ```jsx import { Button, ButtonGroup } from "@pipecat-ai/voice-ui-kit"; ``` -------------------------------- ### TranscriptOverlay Component Usage Examples (React) Source: https://voiceuikit.pipecat.ai/components/TranscriptOverlay Demonstrates how to use the connected TranscriptOverlay component to display bot and user speech transcripts, including customization of size, styling, and animation durations. Requires being used within a PipecatClientProvider context. ```jsx import { TranscriptOverlay } from "@pipecat-ai/voice-ui-kit"; // Display bot speech transcripts // Display user speech transcripts // With custom styling and size // With custom animation durations ``` -------------------------------- ### Full Width Button Layout in React Source: https://voiceuikit.pipecat.ai/primitives/button Shows how to create full-width buttons using the isFullWidth prop. This example demonstrates full-width buttons with both primary and outline variants, useful for mobile layouts or call-to-action sections. ```jsx import { Button } from "@pipecat-ai/voice-ui-kit";
``` -------------------------------- ### LED Component Custom Colors Example Source: https://voiceuikit.pipecat.ai/primitives/led Demonstrates how to set custom colors for the LED's on and off states using the `classNames` prop. It accepts an object with `on` and `off` keys to specify Tailwind CSS classes for each state. ```javascript import { LED } from "@pipecat-ai/voice-ui-kit";
``` -------------------------------- ### LED Component Watch-driven Flash Demo Source: https://voiceuikit.pipecat.ai/primitives/led Demonstrates the watch-driven flash functionality of the LED component. When the `watch` prop (a state variable `count`) changes, the LED blinks for a duration specified by `watchBlinkDurationMs`. This example includes buttons to trigger single pings and bursts of pings. ```javascript import { LED, Button } from "@pipecat-ai/voice-ui-kit"; import React from "react"; function Demo() { const [count, setCount] = React.useState(0); return (
count: {count}
); } // Assuming render is available globally or imported // render(); ``` -------------------------------- ### Import Voice UI Kit with Tailwind CSS Source: https://voiceuikit.pipecat.ai/styling Integrate Voice UI Kit styles with your existing Tailwind CSS setup by importing both in your global CSS. This ensures compatibility and allows for combined customization. ```css @import "tailwindcss"; @import "tw-animate-css"; @import "@pipecat-ai/voice-ui-kit/styles"; :root { /* etc */ } ``` -------------------------------- ### Progress Component Multiple States (React) Source: https://voiceuikit.pipecat.ai/primitives/progress Illustrates various states of the Progress component, including default, 50% completion, and 100% completion, along with custom class names. This example is useful for showcasing different progress levels. Requires the @pipecat-ai/voice-ui-kit library. ```jsx import { Progress } from "@pipecat-ai/voice-ui-kit";
``` -------------------------------- ### CSS Variable Override for Highlight Overlay Source: https://voiceuikit.pipecat.ai/components/HighlightOverlay Shows how to customize the animation and opacity of the Highlight Overlay component using CSS variables. The first example demonstrates a global override using a class selector, while the second shows a per-instance override using inline styles. ```css .voice-ui-kit { --animate-highlight: highlight-focus 900ms ease-out forwards; } ``` ```jsx ``` -------------------------------- ### Plasma Visualizer with Custom Background Source: https://voiceuikit.pipecat.ai/visualizers/plasma-visualizer This React example shows how to use the PlasmaVisualizer component with additional styling, including a black background and rounded corners, applied to its container div. The component still automatically handles audio visualization and Pipecat client integration. ```jsx import { PlasmaVisualizer } from "@pipecat-ai/voice-ui-kit/webgl";
``` -------------------------------- ### CircularWaveform: Usage Examples (Idle and Thinking States) Source: https://voiceuikit.pipecat.ai/visualizers/circular-waveform Illustrates how to use the CircularWaveform component to represent different application states, specifically 'Idle' and 'Thinking'. The `isThinking` prop is key to toggling between these visual modes. This example uses React and assumes the `@pipecat-ai/voice-ui-kit` package is installed. ```jsx import { CircularWaveform } from "@pipecat-ai/voice-ui-kit";

Idle State

Thinking State

``` -------------------------------- ### Disabled Video State Example Source: https://voiceuikit.pipecat.ai/components/UserVideoControl Provides an example of how to display the UserVideoComponent in a disabled state, indicating that video functionality is unavailable. This uses 'noVideo', 'noVideoText', and 'isCamEnabled' props. ```javascript import { UserVideoComponent } from "@pipecat-ai/voice-ui-kit"; function Demo() { return ( {}} /> ); } render(); ``` -------------------------------- ### PipecatAppBase: Initialize Devices on Mount (JavaScript) Source: https://voiceuikit.pipecat.ai/hooks/PipecatAppBase Explains how to automatically initialize audio and video devices (microphone, camera, speakers) when the PipecatAppBase component mounts by setting the `initDevicesOnMount` prop to `true`. This is useful for applications that need immediate access to user media. ```javascript import { PipecatAppBase } from "@pipecat-ai/voice-ui-kit"; export default function Home() { return ( ); } ``` -------------------------------- ### Switching Themes Globally with ThemeProvider Source: https://voiceuikit.pipecat.ai/styling Demonstrates how to switch themes globally using the ThemeProvider component from @pipecat-ai/voice-ui-kit. It allows setting a default theme and provides a hook to toggle between 'light', 'dark', and 'system' themes within a Toolbar component. ```javascript import { ThemeProvider, useTheme } from "@pipecat-ai/voice-ui-kit"; export default function App() { return ( ); } function Toolbar() { const { theme, resolvedTheme, setTheme } = useTheme(); return (
current: {resolvedTheme}
); } ``` -------------------------------- ### Button Component Basic Usage (React) Source: https://voiceuikit.pipecat.ai/primitives/button Demonstrates the basic integration and rendering of the Button component. It requires importing the Button from '@pipecat-ai/voice-ui-kit'. The component accepts a 'variant' prop to define its appearance. ```jsx import { Button } from "@pipecat-ai/voice-ui-kit"; ``` -------------------------------- ### PipecatAppBase: Auto-Connect on Mount (JavaScript) Source: https://voiceuikit.pipecat.ai/hooks/PipecatAppBase Demonstrates how to automatically initiate a connection when the PipecatAppBase component mounts by setting the `connectOnMount` prop to `true`. This simplifies the initial connection process for applications that require immediate connection. ```javascript import { PipecatAppBase } from "@pipecat-ai/voice-ui-kit"; export default function Home() { return ( ); } ``` -------------------------------- ### Importing Utilities CSS Bundle Source: https://voiceuikit.pipecat.ai/styling Demonstrates how to import the utilities bundle for Voice UI Kit, alongside Tailwind CSS and base UI Kit styles. Importing utilities provides additional design tokens, helpers, and ensures correct merging of custom styles with UI Kit components. ```css @import "tailwindcss"; @import "@pipecat-ai/voice-ui-kit/styles"; @import "@pipecat-ai/voice-ui-kit/utilities"; ``` -------------------------------- ### DeviceDropDownComponent Basic Usage Source: https://voiceuikit.pipecat.ai/components/DeviceDropDown Demonstrates the basic usage of the `DeviceDropDownComponent` with mock device data. This headless variant allows for custom state management and UI integration. It takes `availableDevices`, `selectedDevice`, and an `updateDevice` callback as props. ```javascript import { DeviceDropDownComponent, Button } from "@pipecat-ai/voice-ui-kit"; // Example with mock data const mockDevices = [ { deviceId: "mic1", label: "Built-in Microphone" }, { deviceId: "mic2", label: "External USB Mic" }, ]; function Demo() { return ( console.log("Selected:", deviceId)} menuLabel="Select Microphone" > ); } render(); ``` -------------------------------- ### Custom Sizing for CircularWaveform React Source: https://voiceuikit.pipecat.ai/visualizers/circular-waveform Provides examples of responsive sizing options for the CircularWaveform component with small (200px), medium (320px), and large (480px) configurations. Each size example uses a fixed dimension container with appropriate padding and demonstrates how the size prop controls the visualization dimensions. ```JavaScript/React import { CircularWaveform } from "@pipecat-ai/voice-ui-kit";

Small (200px)

Medium (320px)

Large (480px)

``` -------------------------------- ### Progress Component Basic Usage (React) Source: https://voiceuikit.pipecat.ai/primitives/progress Demonstrates the basic implementation of the Progress component from @pipecat-ai/voice-ui-kit. It shows how to render a progress bar with a specified percentage and custom class names for styling. Dependencies include the @pipecat-ai/voice-ui-kit library. ```jsx import { Progress } from "@pipecat-ai/voice-ui-kit"; ``` -------------------------------- ### Importing Terminal Theme Source: https://voiceuikit.pipecat.ai/styling Shows how to import the terminal theme for the Voice UI Kit. It requires importing the base UI Kit styles first, followed by the specific theme file. This approach allows for quick theme application or serves as a base for customization. ```css @import "@pipecat-ai/voice-ui-kit/styles"; @import "@pipecat-ai/voice-ui-kit/themes/terminal"; ``` -------------------------------- ### VoiceVisualizer Basic Usage with React Source: https://voiceuikit.pipecat.ai/visualizers/basic-visualizer Demonstrates the basic implementation of the VoiceVisualizer component in a React application. It requires the VoiceVisualizer import and a participantType prop. Customization of bars and colors is shown. ```javascript import { VoiceVisualizer } from "@pipecat-ai/voice-ui-kit";
``` ```javascript import { VoiceVisualizer } from "@pipecat-ai/voice-ui-kit";
``` -------------------------------- ### ThemeProvider for Theme Management (React) Source: https://voiceuikit.pipecat.ai/styling Wrap your application with the ThemeProvider to enable and manage light/dark modes and theme persistence. It accepts props for default theme and storage key. ```typescript import { ThemeProvider } from "@pipecat-ai/voice-ui-kit"; export default function RootLayout({ children }: { children: React.ReactNode }) { return ( {children} ); } ``` -------------------------------- ### DeviceSelectComponent (Headless Variant) with Props Source: https://voiceuikit.pipecat.ai/components/DeviceSelect An example of using the headless DeviceSelectComponent with explicitly provided props for available devices, the selected device, and the update callback. This demonstrates its flexibility for custom UI implementations. ```javascript import { DeviceSelectComponent } from "@pipecat-ai/voice-ui-kit"; console.log("Selected:", deviceId)} /> ``` -------------------------------- ### LED Component Blink Interval Configuration Source: https://voiceuikit.pipecat.ai/primitives/led Shows how to adjust the blinking speed of the LED component using the `blinkIntervalMs` prop. The example displays LEDs with intervals of 100ms and 500ms, alongside text indicators. ```javascript import { LED } from "@pipecat-ai/voice-ui-kit";
100ms
500ms
``` -------------------------------- ### Basic Usage of Plasma Visualizer Component Source: https://voiceuikit.pipecat.ai/visualizers/plasma-visualizer This React code snippet demonstrates the basic integration of the PlasmaVisualizer component within a div element. It requires importing the component and rendering it, allowing it to automatically connect to the Pipecat client and visualize audio data. ```jsx import { PlasmaVisualizer } from "@pipecat-ai/voice-ui-kit/webgl";
``` -------------------------------- ### LED Component Basic Usage Source: https://voiceuikit.pipecat.ai/primitives/led Demonstrates the basic import and rendering of the LED component from the @pipecat-ai/voice-ui-kit library. It shows the default off state and an explicitly turned on state. ```javascript import { LED } from "@pipecat-ai/voice-ui-kit"; ``` -------------------------------- ### Progress Component Rounded Style (React) Source: https://voiceuikit.pipecat.ai/primitives/progress Shows how to apply a rounded style to the Progress component using the 'rounded' prop. This example also includes custom width and height for the progress bar. Depends on the @pipecat-ai/voice-ui-kit library. ```jsx import { Progress } from "@pipecat-ai/voice-ui-kit"; ``` -------------------------------- ### React Highlight Overlay with No Auto-Clear Source: https://voiceuikit.pipecat.ai/components/HighlightOverlay Demonstrates how to use the HighlightOverlay component from @pipecat-ai/voice-ui-kit in a React application. This example shows how to manually control the highlighting of cards using buttons and disables the auto-clear functionality by setting `autoClearDuration` to 0. ```jsx import { Button, Card, HighlightOverlay } from "@pipecat-ai/voice-ui-kit"; import React from "react"; function Demo() { const [highlightedElement, setHighlightedElement] = React.useState(null); return (
Card 1 Card 2
); } render() ``` -------------------------------- ### VoiceVisualizer High Resolution Configuration Source: https://voiceuikit.pipecat.ai/visualizers/basic-visualizer Demonstrates configuring the VoiceVisualizer for high-resolution audio visualization by adjusting the number of bars and their properties. Uses props like 'barCount', 'barWidth', and 'barGap' for detailed frequency analysis. ```jsx import { VoiceVisualizer } from "@pipecat-ai/voice-ui-kit";

High Resolution (20 bars)

Ultra High Resolution (32 bars)

``` -------------------------------- ### Import Voice UI Kit Styles Source: https://voiceuikit.pipecat.ai/styling Import the default Voice UI Kit styles into your global CSS file. This sets up the foundational styles for the kit, which can be extended or customized further. ```css @import "@pipecat-ai/voice-ui-kit/styles"; :root { /* etc */ } ``` -------------------------------- ### Full usePipecatEventStream Implementation with Grouping and Auto-scroll Source: https://voiceuikit.pipecat.ai/hooks/usePipecatEventStream Complete example demonstrating usePipecatEventStream with event grouping, expandable group UI, auto-scroll functionality, and event display with timestamps and data. Handles both single and multiple consecutive events with collapsible groups. ```typescript import React, { useEffect, useRef, useState } from "react"; import { usePipecatEventStream, type PipecatEventGroup, } from "@pipecat-ai/voice-ui-kit"; export function EventStreamExample() { const { events, groups } = usePipecatEventStream({ maxEvents: 200, groupConsecutive: true, }); const [expanded, setExpanded] = useState>(new Set()); const endRef = useRef(null); // Auto-scroll on new events useEffect(() => { endRef.current?.scrollIntoView({ behavior: "smooth" }); }, [events]); const toggleGroup = (id: string) => { setExpanded((prev) => { const next = new Set(prev); next.has(id) ? next.delete(id) : next.add(id); return next; }); }; return (
{groups.map((group: PipecatEventGroup) => { const isExpanded = expanded.has(group.id); const hasMultiple = group.events.length > 1; if (!hasMultiple || isExpanded) { return group.events.map((e, idx) => (
{hasMultiple && idx === 0 ? ( ) : ( )} [{e.timestamp.toLocaleTimeString()}] {e.type} {e.data ? JSON.stringify(e.data) : "null"}
)); } return (
[{group.events[0].timestamp.toLocaleTimeString()}] {group.type} ({group.events.length} events)
); })}
); } ``` -------------------------------- ### CircularWaveform: Bar Configuration Options Source: https://voiceuikit.pipecat.ai/visualizers/circular-waveform Demonstrates how to adjust the number and width of bars in the CircularWaveform visualization using the `numBars` and `barWidth` props. This example uses React and the `@pipecat-ai/voice-ui-kit` package, showing variations for fewer, default, and many bars. ```jsx import { CircularWaveform } from "@pipecat-ai/voice-ui-kit";

Few Bars (32)

Default Bars (64)

Many Bars (128)

``` -------------------------------- ### Button Component Rounded Styles (React) Source: https://voiceuikit.pipecat.ai/primitives/button Illustrates the different border-radius options for the Button component, controlled by the 'rounded' prop. Options include 'size', 'sm', 'lg', 'xl', 'full', and 'none'. This example uses flexbox for layout. ```jsx import { Button } from "@pipecat-ai/voice-ui-kit";
``` -------------------------------- ### Divider with variant styles Source: https://voiceuikit.pipecat.ai/primitives/divider Shows how to apply different line variants to the Divider component including solid, dotted, and dashed patterns. All examples use the primary color for visual consistency and demonstrate how variant affects the line appearance. ```jsx import { Divider } from "@pipecat-ai/voice-ui-kit";
``` -------------------------------- ### Switching Themes with Scoped Styles Source: https://voiceuikit.pipecat.ai/styling Illustrates theme switching with scoped styles by importing '@pipecat-ai/voice-ui-kit/styles.scoped'. The theme class is applied to the `.vkui-root` element, ensuring styles are isolated to that container. This is useful for integrating UI Kit components within larger applications without style conflicts. ```javascript import "@pipecat-ai/voice-ui-kit/styles.scoped"; import { ThemeProvider, useTheme } from "@pipecat-ai/voice-ui-kit"; export default function App() { return ( ); } function ScopedRoot() { const { resolvedTheme } = useTheme(); // IMPORTANT: when using scoped styles, put the theme class on ".vkui-root" return (
); } ``` -------------------------------- ### PipecatAppBase Usage: Direct Children Pattern (JavaScript) Source: https://voiceuikit.pipecat.ai/hooks/PipecatAppBase Illustrates the Direct Children pattern for PipecatAppBase, suitable for leveraging built-in components that manage connection state internally. This example shows integrating ConnectButton and ControlBar with UserAudioControl. ```javascript import { PipecatAppBase, ConnectButton, ControlBar, UserAudioControl, } from "@pipecat-ai/voice-ui-kit"; export default function Home() { return (
); } ``` -------------------------------- ### UserAudioOutputControlComponent: Basic Usage with Devices Source: https://voiceuikit.pipecat.ai/components/UserAudioOutputControl Demonstrates the basic usage of the UserAudioOutputControlComponent, a headless variant that accepts available audio devices and a callback for device updates as props. It allows for custom management of device selection logic. ```jsx import { UserAudioOutputControlComponent } from "@pipecat-ai/voice-ui-kit"; console.log("Selected:", deviceId как} /> ```