Vue Terminal 컴포넌트
Terminal은 텍스트 기반 사용자 인터페이스예요. 명령을 입력하면 이벤트로 응답을 받아 화면에 출력하는, 콘솔 스타일 UI를 애플리케이션 안에 만들 수 있게 도와줘요.
출처: 문서
본문
Vue Terminal Component
Terminal is a text based user interface.
Import
import Terminal from 'primevue/terminal';
import TerminalService from 'primevue/terminalservice';
Accessibility
Screen Reader Terminal 컴포넌트에는 aria-label 또는 aria-labelledby 프로퍼티로 설명할 수 있는 input 요소가 있어요. 이전 명령들을 나열하는 요소에는 aria-live가 지정되어 있어서 스크린 리더가 변화를 받을 수 있어요. Keyboard Support Key Function tab input 요소를 통해 포커스를 이동해요. enter input 요소에 포커스가 있을 때 명령을 실행해요.
Basic
명령은 TerminalService라는 EventBus 구현으로 처리돼요. 이 서비스를 컴포넌트에 임포트하고 command 이벤트를 구독한 뒤, response 이벤트로 응답을 보내 명령을 처리하세요.
<Terminal welcomeMessage="Welcome to PrimeVue" prompt="primevue $" aria-label="PrimeVue Terminal Service" />
Terminal
Props
| Name | Type | Default | Description |
|---|---|---|---|
| welcomeMessage | string | - | Initial text to display on terminal. |
| prompt | string | - | Prompt text for each command. |
| dt | any | - | It generates scoped CSS variables using design tokens for the component. |
| pt | PassThrough | - | Used to pass attributes to DOM elements inside the component. |
| ptOptions | any | - | Used to configure passthrough(pt) options of the component. |
| unstyled | boolean | false | When enabled, it removes component related styles in the core. |
Pass Through Options
| Name | Type | Description |
|---|---|---|
| root | TerminalPassThroughOptionType | Used to pass attributes to the root's DOM element. |
| welcomeMessage | TerminalPassThroughOptionType | Used to pass attributes to the welcome message's DOM element. |
| content | TerminalPassThroughOptionType | Used to pass attributes to the content's DOM element. |
| commands | TerminalPassThroughOptionType | Used to pass attributes to the commands' DOM element. |
| prompt | TerminalPassThroughOptionType | Used to pass attributes to the prompt's DOM element. |
| command | TerminalPassThroughOptionType | Used to pass attributes to the command's DOM element. |
| response | TerminalPassThroughOptionType | Used to pass attributes to the response's DOM element. |
| container | TerminalPassThroughOptionType | Used to pass attributes to the container's DOM element. |
| commandText | TerminalPassThroughOptionType | Used to pass attributes to the command text's DOM element. |
| hooks | any | Used to manage all lifecycle hooks. |
Theming
CSS Classes
| Class | Description |
|---|---|
| p-terminal | Class name of the root element |
| p-terminal-welcome-message | Class name of the welcome message element |
| p-terminal-command-list | Class name of the command list element |
| p-terminal-command | Class name of the command element |
| p-terminal-command-value | Class name of the command value element |
| p-terminal-command-response | Class name of the command response element |
| p-terminal-prompt | Class name of the prompt element |
| p-terminal-prompt-label | Class name of the prompt label element |
| p-terminal-prompt-value | Class name of the prompt value element |
Design Tokens
| Token | CSS Variable | Description |
|---|---|---|
| terminal.background | --p-terminal-background | Background of root |
| terminal.border.color | --p-terminal-border-color | Border color of root |
| terminal.color | --p-terminal-color | Color of root |
| terminal.height | --p-terminal-height | Height of root |
| terminal.padding | --p-terminal-padding | Padding of root |
| terminal.border.radius | --p-terminal-border-radius | Border radius of root |
| terminal.prompt.gap | --p-terminal-prompt-gap | Gap of prompt |
| terminal.command.response.margin | --p-terminal-command-response-margin | Margin of command response |