A field to sign: draw with the mouse, the finger or the pen, or type the name; clear and start again. It
writes what was signed into hidden inputs for the form: the method, the typed name or the SVG of the stroke
(DevactionUI.Signature hook, exportSvg). The SVG is the drawing only, in its own coordinates, so it can be
kept and drawn back at any size. A drawing is accepted by the server only after safe_path?/1.
The pad stays mounted when the mode changes (it is only hidden), so a stroke is not lost by a look at the
typed name; the form reads name[method] to know which of name[path] and name[typed] counts. Drawing has
no keyboard equivalent: the typed mode is the way for whoever cannot draw. The typed name is set in the
Caveat font (.signature-typed), which the package does not load: add Caveat (weight 500) to the page, for
example from Google Fonts, or the name falls back to the browser's cursive. To use another face, give font
(a CSS font-family value such as "'Dancing Script', cursive") and load that one instead.
guide_label writes a line of text under the guide line of the pad ("Sign above the line"); typed_label is
the visible label of the name field; required marks the name field as required (a drawing is checked by the
server, with safe_path?/1). error marks both ways of signing as invalid and disabled makes the whole field
inert.
Summary
Functions
Whether a path is only path commands and numbers, so it can be drawn back without being trusted.
The SVG of a stroke, nil for one that is not safe. color is #RRGGBB or currentColor (default ink on
white); another value gives nil too.
Functions
Whether a path is only path commands and numbers, so it can be drawn back without being trusted.
Attributes
id(:string) (required)name(:string) (required) - the form field:name[method],name[typed]andname[path].mode(:atom) - Defaults to:draw. Must be one of:draw, or:type.typed(:string) - Defaults to"".label(:string) (required)mode_event(:string) (required) - sent withphx-value-modeby the two buttons.draw_label(:string) (required)type_label(:string) (required)clear_label(:string) (required)pad_label(:string) - names the drawing area for assistive technology, asSignature area; without it the area is hidden from them. Defaults tonil.empty_label(:string) - the status while nothing is drawn, such as "Signature empty"; the status shows when given. Defaults tonil.ready_label(:string) - the status once there is a stroke. Defaults tonil.guide_label(:string) - text under the guide line of the pad, such as "Sign above the line". Defaults tonil.typed_label(:string) - the visible label of the name field; without it the field is named bylabel. Defaults tonil.font(:string) - a CSSfont-familyfor the typed name, such as"'Dancing Script', cursive"; the page loads the font. Letters, digits, spaces, commas, quotes and hyphens only. Defaults tonil.hint(:string) - Defaults tonil.error(:string) - Defaults tonil.required(:boolean) - marks the name field as required. Defaults tofalse.disabled(:boolean) - Defaults tofalse.class(:any) - Defaults tonil.target(:any) - aphx-target(a@myself) when used inside a LiveComponent. Defaults tonil.- Global attributes are accepted.
Slots
clear_icon- the icon of the clear button, such as an eraser.
The SVG of a stroke, nil for one that is not safe. color is #RRGGBB or currentColor (default ink on
white); another value gives nil too.