Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Voice Command Dialog Block for React

A smart-home panel with a simulated voice drawer shown open: a mic button and four phrases start a bounded pass of moving bars, a transcript that fills word by word and a parsed intent card, and Confirm applies the command to the panel. No microphone is used.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

Turn a sentence into a command you can check before it acts, with this voice drawer for React with Base UI. It opens from the Home page of Murmurhome, a smart-home hub: the page's header holds an outline Voice command Button, and the page, a thermostat dial at 19 degrees, two lights, a door lock and a kitchen speaker, is drawn under a soft scrim inside a hairline frame with a plus mark on each corner. The Drawer is a simulation and says so on screen: the microphone is not used, nothing listens and no permission is asked. A mic Button, pressed while it runs, and four phrases to try start a bounded pass: three bars move for 1.4 seconds on a fixed curve, the phrase appears word by word, and a parsed intent card fills in as a list with an Action, a Target and a Value. Pressing the mic again stops it. Confirm is the only Shine Button: it applies the command to the panel, as real text, so the living-room thermostat reads 21 degrees, the porch light goes off, the front door locks or the kitchen speaker plays. For preview the drawer is drawn open in place when the page loads, at rest; the header button opens the real Drawer.

FAQ

Why is the drawer already open, and what do I keep?

So you can see it without a click. On load the drawer is a copy drawn in place, docked to the foot of the page: a native dialog element that isn't modal, so nothing is trapped, hidden or focused, and the page around the preview keeps working. Nothing runs until you press the mic or a phrase. The Voice command button opens the real Drawer, with its swipe, Escape and focus return, and the copy stays closed until a reload. Both show the same VoiceFields component and share the block's state. In your app keep the Drawer and drop the copy: the "in-place" state, the scrim and the dialog element inside the frame.

Does it listen to anything?

No. The microphone is never opened, there is no speech recognition and no permission prompt, and the drawer says so under its title and beside the mic. The four phrases are typed in the block, and the bars move on a fixed curve, so the same pass looks the same every time. In your app pass the recognised text to the same intent step: the transcript, the card and Confirm work on any string you give them.

How does a pass work, and how do I stop it?

The bars move for seven beats, 1.4 seconds in all, then the phrase appears one word at a time, at most seven steps, and the card fills in. The mic button says Stop listening while a pass runs and ends it on a press, and the phrases wait until it is over. Under reduced motion the bars hold one shape and the phrase and the card appear at once. Closing the drawer drops a pass in hand, and a pending step is cleared with it.

What does a screen reader hear?

The moving bars and the word-by-word transcript are decoration and are hidden from assistive technology; what is read, once, is the final phrase and the card: "Heard Set the living room to 21 degrees. Action: Set temperature. Target: Living room. Value: 21 °C. Confirm or cancel." Stopping early says "Stopped. Nothing was heard." Confirm stays quiet until a phrase has been understood, and pressing it before then says what is missing.

What stays local in the demo, and how do I wire it up?

Everything. Confirm changes the drawn panel in this page's state and says "Nothing was sent to a device in this demo"; no light, lock or thermostat is switched. In your app call your hub from confirm, keep homeAfter as the place that applies an intent to your state, and ask for the microphone only when the person presses the mic.

Is it accessible from the keyboard?

Yes. The real drawer is named Voice command, focus starts on the mic and stays inside until it closes, and Escape returns focus to the Voice command button. The mic, the phrases, Cancel and Confirm are all buttons. The trigger is passed to DrawerTrigger through render, and the drawer is controlled with open and onOpenChange. The copy shown on load moves no focus; Escape inside it and Cancel close it and put focus on the button.

  • Pro

    Audio Player Dialog

    Drawers and popovers

    An ambient-sound library's page with its mini player shown open over it: a floating panel with the track, a seek slider and its time, Previous, Play and Next, and a volume slider with mute. It isn't modal, so the page stays usable, and nothing really plays.

  • Pro

    Voice Recorder Dialog

    Media and widgets

    A voice-memo list with a simulated recorder dialog shown open: a record button with a one-second clock up to 0:12, a waveform that fills as it runs, a trim slider with two thumbs, a name field, an inline discard check and a Save memo button that adds the memo to the list.

  • Pro

    Sleep Timer Dialog

    Drawers and popovers

    A podcast player with its sleep timer drawer shown open: presets and a fine-tune slider, the stop time worked out from a typed clock, a fade switch, a linear track with the fade zone hatched, and a running state with the time left.

  • Pro

    Set Reminder Dialog

    Time and scheduling

    A to-do list with its reminder dialog shown open: five quick chips, an inline calendar and a time in quarter hours, repeat and notify choices, and one plain sentence that always reads the choice back.

  • Pro

    Quick Note Dialog

    Notes and editing

    A sticky-note wall with its dialog shown open: a title, a note of up to 280 characters, an Idea, To-do, Reference or Later label, a reminder day on a calendar and a pin switch, and a new card that lands first on the wall.

  • Pro

    An uptime monitor's status page with a dialog shown open that asks before the browser does: three switches with an example each, a live preview of drawn notification cards, a not-now path and a Don't ask again box, and no browser prompt.