Signature Pad

Canvas-based signature capture pad.

python 12 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):
        pass  # your app acts on 'save_signature'; no component state moves
my_template.html
django
{{ component }}

Events this component sends to the view: save_signature.

Needs its script on the page: <script src="{% static 'djust_components/signature-pad.js' %}"></script>. djust ships it; without it the markup renders but does not update in the browser.

Parameters

NameTypeDefaultDescription
namestr'signature'form field name for the hidden input
save_eventstr — renames the event'save_signature'djust event fired on save with base64 data
widthint400canvas width (default 400)
heightint200canvas height (default 200)
pen_colorstr'#000000'stroke color (default "#000000")
pen_widthint2stroke width in px (default 2)
disabledboolFalsedisable drawing (default False)
custom_classstr''additional CSS classes
max_bytesint204800largest data URL the hook sends (default 204800)
labelstr'Signature drawing area'accessible name of the canvas (default "Signature drawing area")
typedboolTrueoffer the typed-name alternative (default True)
**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 12 of this component's classes at line 2009, 2010, 2012, 2013, 2015, 2016, 2017, 2018, 2020, 2552. Override those rules, or the custom properties they read, in a stylesheet loaded after it.