Terminal

Terminal is a text based user interface.


import { Terminal } from 'primereact/terminal';
import { TerminalService } from 'primereact/terminalservice';
         

Terminal is interacted with TerminalService api using command, response and clear events. The command event requires a callback to handle the commands, the responseemits the response of the command and emitting clear reset the terminal.

Enter "date" to display the current date, "greet {0}" for a message, "random" to get a random number and "clear" to clear all commands.

Welcome to PrimeReact
primereact $ 

<Terminal welcomeMessage="Welcome to PrimeReact" prompt="primereact $" />
         

Following is the list of structural style classes, for theming classes visit theming page.

NameElement
p-terminalContainer element.
p-terminal-contentContent of terminal.
p-terminal-promptPrompt text.
p-terminal-responseCommand response.
p-terminal-inputInput element to enter commands.
Accessibility guide documents the specification of this component based on WCAG guidelines, the implementation is in progress.

Screen Reader

Terminal component has an input element that can be described with aria-label or aria-labelledby props. The element that lists the previous commands has aria-live so that changes are received by the screen reader.

Keyboard Support

KeyFunction
tabMoves focus through the input element.
enterExecutes the command when focus in on the input element.