Terminal Component Examples
Interactive Terminal​
Try typing commands like ls
, pwd
, whoami
, date
, help
, or echo hello world
:
bash
user@localhost:~$
Read-only Terminal​
This shows pre-executed commands for documentation purposes:
Project Setup
Custom Terminal​
With custom styling and configuration:
production-server
admin@prod:~/app$
Direct Component Usage​
You can also use the component directly with inline props:
my-terminal
developer@localhost:~/docs$
Installation Steps​
- Create the component file: Save as
src/components/BashTerminal.js
- Create the CSS module: Save as
src/components/BashTerminal.module.css
- Create examples (optional): Save as
src/components/TerminalExamples.js
- Use in MDX files: Import and use as shown above
Available Props​
Prop | Type | Default | Description |
---|---|---|---|
initialCommands | Array | [] | Pre-executed commands with outputs |
title | String | "bash" | Terminal window title |
height | String | "400px" | Terminal height |
prompt | String | "user@localhost:~$ " | Command prompt |
readOnly | Boolean | false | Disable input for display mode |
Built-in Commands​
ls
- List directory contentspwd
- Print working directorywhoami
- Display current usernamedate
- Show current date and timeclear
- Clear terminal screenhelp
- Show available commandsecho [text]
- Echo text back