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

Buttons

  • Button
  • ShimmerButton
  • InteractiveHoverButton
  • RainbowButton
  • PulsatingButton
  • RippleButton
  • ButtonGroup
  • SocialButton

Basic Inputs

  • Input
  • Textarea
  • CellEditor
  • Select
  • Checkbox
  • CheckboxGroup
  • Radio
  • Switch
  • Toggle
  • Segmented
  • Slider
  • NumberField
  • ElasticSlider

Advanced Inputs

  • MathTextarea
  • QuestionEditor
  • QuestionAnswer
  • MathField
  • SecretField
  • PasswordGenerator
  • Combobox
  • RemoteSelect
  • Listbox
  • Mentions
  • InputOTP
  • Rating
  • Upload
  • RegionSelect
  • ImageCropper
  • ScopeMatrix
  • Transfer
  • Cascader
  • TreeSelect
  • RegionCascader
  • CountrySelect
  • MarkdownEditor
  • Novel editor
  • RichTextEditor
  • CodeEditor
  • IssueReporter
  • ColorPicker
  • ColorField
  • ColorSwatchPicker
  • Choicebox
  • EmojiPicker
  • VoiceRecord
  • IconPicker
  • InspectorPanel

Date and Time

  • Calendar
  • DatePicker
  • DateTimePicker
  • DateRangePicker
  • TimePicker
  • TimeField

Form Frameworks

  • Form
  • ModalForm / DrawerForm
  • ProForm
  • StepsForm
  • LoginForm
  • AuthPanel
  • ClickCaptcha
  • Label
  • Field
  • SearchForm

VoiceRecord

voice-record

Presents hold-to-talk or tap-to-toggle recording controls with waveform and processing states.

Usage

Basic usage (press and hold to speak)

Default pressAndHold: press to start recording, release to end and enter processing, iOS gesture interruption (pointercancel) can also release correctly.

Hold to talk
tsx
const [status, setStatus] = useState<VoiceRecordStatus>("idle");
const [levels, setLevels] = useState<number[]>([]); // Microphone analyzer feeds 0-1 waveform

<VoiceRecord
  status={status}
  levels={levels}
  onPress={() => setStatus("recording")}
  onRelease={() => setStatus("processing")}
/>

Click to switch modes

pressAndHold={false} Click Start/Click End again, and onToggle will transfer automatically after receiving the current status.

Click to speak
tsx
<VoiceRecord
  status={status}
  levels={levels}
  pressAndHold={false}
  onToggle={(s) => (s === "idle" ? start() : stop())}
/>

Size

sm / md / lg three levels, icons and labels scale with the level.

Hold to talk
Hold to talk
Hold to talk
tsx
<>
  <VoiceRecord size="sm" />
  <VoiceRecord size="md" />
  <VoiceRecord size="lg" />
</>

VoiceRecord

Voice recording trigger whose status drives its visual feedback.

States

StatusEffectClick behavior
idleDefault microphone iconCalls onToggle to start recording.
recordingPulsing halo, waveform, and compact danger buttonCalls onToggle to stop.
processingSpinnerNo response.
disabledMuted and noninteractiveNo response.

Props

PropTypeDefaultDescription
status"idle" | "recording" | "processing" | "disabled""idle"Current status
onToggle(status) => void-Called from idle or recording with the current status.
levelsnumber[][]Waveform levels from 0-1; an empty array hides the waveform.
size"sm" | "md" | "lg""md"Button size.
labelIdlestring"\u6309\u4f4f\u8bf4\u8bdd"Idle-state label; the built-in Chinese copy means “Hold to speak.”
labelRecordingstring"\u677e\u5f00\u7ed3\u675f"Recording-state label; the built-in Chinese copy means “Release to finish.”
labelProcessingstring"\u5904\u7406\u4e2d\u2026"Processing-state label; the built-in Chinese copy means “Processing…”.
pressAndHoldbooleanfalsePress-and-hold mode: press to start and release to stop, driving onPress / onRelease. When false the button toggles on click and drives onToggle. Release, pointer-leave, and the pointercancel iOS fires when the system interrupts a gesture all end the recording, so a hold can never get stuck.
onPress() => void-Fires when an idle button is pressed (only while pressAndHold is true).
onRelease() => void-Fires when a recording button is released (only while pressAndHold is true).

Playground

Press and hold to speak
<VoiceRecord status="idle" size="md" />
PreviousEmojiPickerFormsNextCalendar

On this page

  • Usage
  • Documentation
    • States
    • Props
  • Playground