Control Components
Interactive control related components: ControlPanel, Input, RecommendedQuestions.
ControlPanel
Voice/text input control panel, supports mode switching.
Basic Usage
import {PilotKit, ControlPanel} from '@bdky/aaas-pilot-kit-react-widget';
import '@bdky/aaas-pilot-kit-react-widget/styles.css';
function App() {
return (
<PilotKit {...props}>
<ControlPanel />
</PilotKit>
);
}
Responsive Adaptation
| Feature | PC | Mobile |
|---|---|---|
| Input Width | 479px fixed | 100% adaptive |
| Button Size | 54-55px | 50px |
| Layout | Centered absolute positioning | Full-width flex |
| Hangup Button | Optional display | Always display |
Props
| Property | Type | Default | Description |
|---|---|---|---|
variant | 'auto' | 'mobile' | 'desktop' | 'auto' | Display mode |
className | string | - | Custom class name |
style | CSSProperties | - | Custom style |
mode | 'voice' | 'text' | - | Controlled mode |
defaultMode | 'voice' | 'text' | 'voice' | Default mode |
onModeChange | (mode) => void | - | Mode switch callback |
inputValue | string | - | Controlled input value |
inputPlaceholder | string | '请输入...' | Input placeholder |
inputDisabled | boolean | false | Whether to disable input |
onInputChange | (value) => void | - | Input change callback |
onSend | (value) => void | - | Send callback |
onMuteToggle | (muted) => void | - | Mute toggle callback |
showHangupButton | boolean | false | Whether to show hangup button |
onHangup | () => void | - | Hangup callback |
Custom Icons
| Property | Type | Description |
|---|---|---|
muteIcon | ReactNode | Mute state icon |
unmuteIcon | ReactNode | Unmute state icon |
hangupIcon | ReactNode | Hangup button icon |
asrIcon | ReactNode | ASR mode icon |
keyboardIcon | ReactNode | Keyboard mode icon |
sendIcon | ReactNode | Send button icon |
Custom Rendering
<ControlPanel>
{/* Fully custom control panel */}
<div className="my-control-panel">
<button>Custom Button</button>
</div>
</ControlPanel>
Style Customization
| Class Name | Description |
|---|---|
.apk-control-panel | Root container |
.apk-control-panel--mobile | Mobile style |
.apk-control-panel__inner | Inner container |
.apk-control-panel__mode-btn | Mode switch button |
.apk-control-panel__input-wrapper | Input wrapper |
.apk-control-panel__input | Input |
.apk-control-panel__send-btn | Send button |
.apk-control-panel__mic-btn | Microphone button |
.apk-control-panel__hangup-btn | Hangup button |
.apk-control-panel__icon | Icon |
.apk-control-panel__icon-mute | Mute icon |
Input
Independent text input component.
Basic Usage
import {PilotKit, Input} from '@bdky/aaas-pilot-kit-react-widget';
import '@bdky/aaas-pilot-kit-react-widget/styles.css';
function App() {
return (
<PilotKit {...props}>
<Input placeholder="Enter message..." />
</PilotKit>
);
}
Responsive Adaptation
| Feature | PC | Mobile |
|---|---|---|
| Width | 479px | 100% |
| Height | 55px | 50px |
| Border Radius | 28px | 20px |
| Padding | 24px | 16px |
Props
| Property | Type | Default | Description |
|---|---|---|---|
variant | 'auto' | 'mobile' | 'desktop' | 'auto' | Display mode |
className | string | - | Custom class name |
style | CSSProperties | - | Custom style |
value | string | - | Controlled value |
defaultValue | string | '' | Default value |
placeholder | string | '请输入...' | Placeholder |
disabled | boolean | false | Whether disabled |
maxLength | number | - | Maximum length |
autoFocus | boolean | false | Whether to auto focus |
status | 'default' | 'error' | 'warning' | 'default' | Status |
loading | boolean | false | Whether loading |
showSendIcon | boolean | true | Whether to show send icon |
sendIcon | ReactNode | - | Custom send icon |
onChange | (e) => void | - | Native change event |
onTextChange | (value) => void | - | Text change callback |
onSend | (value) => void | - | Send callback |
onFocus | (e) => void | - | Focus callback |
onBlur | (e) => void | - | Blur callback |
onKeyDown | (e) => void | - | Keydown callback |
Custom Rendering
<Input>
{({value, setValue, handleSend, disabled, loading}) => (
<div className="my-input">
<input
value={value}
onChange={e => setValue(e.target.value)}
disabled={disabled}
/>
<button onClick={handleSend} disabled={loading}>
Send
</button>
</div>
)}
</Input>
Style Customization
| Class Name | Description |
|---|---|
.apk-input | Root container |
.apk-input--mobile | Mobile style |
.apk-input--desktop | Desktop style |
.apk-input__field | Input field |
.apk-input__send-icon | Send icon |
.apk-input__loader | Loading indicator |
.apk-input--error | Error state |
.apk-input--warning | Warning state |
.apk-input--disabled | Disabled state |
.apk-input--loading | Loading state |
RecommendedQuestions
Recommended questions list component.
Basic Usage
import {useRef} from 'react';
import {PilotKit, RecommendedQuestions} from '@bdky/aaas-pilot-kit-react-widget';
import '@bdky/aaas-pilot-kit-react-widget/styles.css';
function App() {
const pilotKitRef = useRef(null);
return (
<PilotKit ref={pilotKitRef} {...props}>
<RecommendedQuestions
questions={['Introduce yourself', 'What can you do?', 'Help me check my order']}
onQuestionClick={q => pilotKitRef.current?.input(q)}
/>
</PilotKit>
);
}
Responsive Adaptation
| Feature | PC | Mobile |
|---|---|---|
| Layout | Horizontal arrangement | Vertical arrangement |
| Background | Semi-transparent capsule | Transparent |
| Question Item | Text + arrow | Card style |
| Title | Visible | Hidden by default |
| Divider | Visible | Hidden |
Props
| Property | Type | Default | Description |
|---|---|---|---|
variant | 'auto' | 'mobile' | 'desktop' | 'auto' | Display mode |
className | string | - | Custom class name |
style | CSSProperties | - | Custom style |
questions | string[] | [] | Question list |
title | string | '试试这样问:' | Title text |
showTitle | boolean | false | Whether to show title |
showDivider | boolean | true | Whether to show divider |
expanded | boolean | false | Whether expanded |
arrowIcon | ReactNode | - | Custom arrow icon |
onQuestionClick | (question: string) => void | - | Question click callback |
Style Customization
| Class Name | Description |
|---|---|
.apk-recommended-questions | Root container |
.apk-recommended-questions--mobile | Mobile style |
.apk-recommended-questions__title | Title |
.apk-recommended-questions__divider | Divider |
.apk-recommended-questions__list | Question list |
.apk-recommended-questions__item | Question item |
.apk-recommended-questions__arrow | Arrow icon |
.apk-recommended-questions__arrow-icon | Mobile arrow icon |
Related
- PilotKit - Core container component
- React SDK Hooks - Underlying Hooks