ターミナルはテキストベースのユーザーインターフェースです。
import { Terminal } from 'primereact/terminal';
import { TerminalService } from 'primereact/terminalservice';
ターミナルは、_command_、_response_、_clear_イベントを使用して_TerminalService_ APIと対話します。 _command_イベントはコマンドを処理するためのコールバックを必要とし、_response_はコマンドの応答を出力し、_clear_を出力するとターミナルがリセットされます。
現在の日付を表示するには「**date**」と入力し、メッセージを表示するには「**greet {0}**」、乱数を取得するには「**random**」、すべてのコマンドをクリアするには「**clear**」と入力します。
<Terminal
welcomeMessage="Welcome to PrimeReact"
prompt="primereact $"
pt={{
root: 'bg-gray-900 text-white border-round',
prompt: 'text-gray-400 mr-2',
command: 'text-primary-300',
response: 'text-primary-300'
}}
/>
ターミナルコンポーネントには、_aria-label_または_aria-labelledby_プロパティで説明できる入力要素があります。 前のコマンドをリストする要素には_aria-live_があるため、変更はスクリーンリーダーによって受信されます。
キー | 機能 |
---|---|
tab | 入力要素間でフォーカスを移動します。 |
enter | 入力要素にフォーカスがあるときにコマンドを実行します。 |