Terminal

Monospace terminal emulator display with ANSI color support.

python 7 params

Preview

show_line_numbers
shell
1$ djust new myapp
2Creating project…
3Done in 1.2s
python
terminal(output=['$ djust new myapp', 'Creating project…', 'Done in 1.2s'], title='shell', show_line_numbers=True)

Usage

views.py
python
from djust import LiveView
from djust.components import Terminal


class MyView(LiveView):
    template_name = "my_template.html"

    def mount(self, request, **kwargs):
        self.component = Terminal(output=['$ djust new myapp', 'Creating project…', 'Done in 1.2s'], title='shell', show_line_numbers=True)
my_template.html
django
{{ component }}

Needs a client hook djust does not ship: dj-hook="Terminal". The markup renders, but the interaction described above is yours to add — register window.djust.hooks.Terminal = { mounted() { … } } before client.js loads (see the hooks guide).

Parameters

NameTypeDefault
outputlist | NoneNone
titlestr''
stream_eventstr — the event your server pushes to it''
show_line_numbersboolFalse
wrapboolFalse
custom_classstr''
**kwargs— passed to `Component.__init__`: `name=` identifies the instance in the events it sends, `id=` sets `component.id`, and any other keyword is kept as state
Source & styles
FilePathNotes
moduledjust.components.components.terminalSubclass it, or pass custom_class, to change how it renders.
cssdjust_components/components.cssDefines 12 of this component's classes at line 2070, 2071, 2072, 2073, 2074, 2075, 2076, 2077, 2078, 2079, 2080, 2081. Override those rules, or the custom properties they read, in a stylesheet loaded after it.