Signature Pad

Canvas-based signature capture pad.

python 9 params

Preview

Usage

views.py
python
from djust import LiveView
from djust.decorators import event_handler
from djust.components import SignaturePad


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

    def mount(self, request, **kwargs):
        self.component = SignaturePad()

    @event_handler()
    def save_signature(self, value=None, **kwargs):
        ...  # write to self.component; the re-render carries it
my_template.html
django
{{ component }}

Events this component sends to the view: save_signature.

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

Parameters

NameTypeDefault
namestr'signature'
save_eventstr — renames the event'save_signature'
widthint400
heightint200
pen_colorstr'#000000'
pen_widthint2
disabledboolFalse
custom_classstr''
**kwargs— passed to `Component.__init__`: `id=` sets `component.id`, and any other keyword is kept as state
Source & styles
FilePathNotes
moduledjust.components.components.signature_padSubclass it, or pass custom_class, to change how it renders.
cssdjust_components/components.cssDefines 6 of this component's classes at line 1968, 1969, 1970, 1971, 1972, 2449. Override those rules, or the custom properties they read, in a stylesheet loaded after it.