Vue3 Terminal
Vue3 Terminal is a text based user interface. It supports Vue 3 with PrimeVue 3 and Vue 2 with PrimeVue 2.
Setup
Refer to PrimeVue setup documentation for download and installation steps for your environment such as Vue CLI, Vite or browser.
Mitt EventBus
Terminal requires Mitt, a tiny 200b EventBus implementation.
npm install mitt --save
Import
import Terminal from 'primevue/terminal';
import TerminalService from 'primevue/terminalservice';
Getting Started
Commands are processed using an EventBus implementation called TerminalService. Import this service into your component and subscribe to the command event to process the commands by sending replies with the response event.
<Terminal welcomeMessage="Welcome to PrimeVue" prompt="primevue $" />
import TerminalService from 'primevue/terminalservice';
export default {
methods: {
commandHandler(text) {
let response;
let argsIndex = text.indexOf(' ');
let command = argsIndex !== -1 ? text.substring(0, argsIndex) : text;
switch(command) {
case "date":
response = 'Today is ' + new Date().toDateString();
break;
case "greet":
response = 'Hola ' + text.substring(argsIndex + 1);
break;
case "random":
response = Math.floor(Math.random() * 100);
break;
default:
response = "Unknown command: " + command;
}
TerminalService.$emit('response', response);
}
},
mounted() {
TerminalService.$on('command', this.commandHandler);
},
beforeUnmount() {
TerminalService.$off('command', this.commandHandler);
}
}
Theming
Terminal supports various themes featuring Material, Bootstrap, Fluent as well as your own custom themes via the Designer tool.
Resources
Visit the PrimeVue Terminal showcase for demos and documentation.