生态产品多个设计器现已发布候选版本

查看生态总览
Skip to content

SignaturePad ​

Data entry component. This page is the API reference, generated from the source code. Usage guidance and live examples are on the Chinese page.

Anatomy ​

Parts in bold are required.

data-scope="signature-pad": root · label · control · guide · path · undo-trigger · redo-trigger · clear-trigger · status · hidden-input

API reference ​

Descriptions of individual props, events and slots are written in Chinese and appear on the Chinese page.

Artifacts ​

LayerValue
Custom element<xh-signature-pad>
Vue componentsXhSignaturePadClearTrigger XhSignaturePadControl XhSignaturePadGuide XhSignaturePadHiddenInput XhSignaturePadLabel XhSignaturePadPath XhSignaturePadRedoTrigger XhSignaturePadRoot XhSignaturePadStatus XhSignaturePadUndoTrigger
ComposableuseSignaturePad
State machinesignaturePadMachine
Skin@xihan-ui/styles/signature-pad.css

Props ​

PropTypeRequired
labelledboolean
ariaLabelstring
disabledboolean
readOnlyboolean
requiredboolean
invalidboolean
namestring
valueSignaturePadValue
defaultValueSignaturePadValue
drawingSignaturePadDrawingOptions
translationsPartial<SignaturePadTranslations>
onDraw(details: SignaturePadDrawDetails) => void
onDrawEnd(details: SignaturePadDrawEndDetails) => void
onValueChange(details: SignaturePadValueChangeDetails) => void
onClear() => void

Events ​

Custom elements put the payload in detail; Vue emits an event of the same name.

EventPayload
drawSignaturePadDrawDetails
draw-endSignaturePadDrawEndDetails
value-changeSignaturePadValueChangeDetails
clear``

Slots ​

Only slots with a payload are listed.

Vue componentSlotPayload
XhSignaturePadRootdefaultSignaturePadRootSlotProps
XhSignaturePadRootlabel—

React adapter props ​

Only the props each component declares itself: DOM attributes inherited from ComponentPropsWithRef are left out, and root props already listed in the Props table are not repeated. The Vue counterpart is the slot table above.

React componentPropTypeRequired
XhSignaturePadRootlabelReactNode
XhSignaturePadRootchildrenSlotChildren<SignaturePadRootSlotProps>

State ​

The following names are internal to the state machine.

States: drawing · idle

Events: DRAW.START · DRAW.MOVE · DRAW.END · STROKES.CLEAR · HISTORY.UNDO · HISTORY.REDO · FORM.RESET · PRESS.START · PRESS.END

Guards: canDraw · canPress

connect API ​

getXxxProps() returns the host attributes of the matching part.

MemberType
valueSignaturePadValue
pathsreadonly string[]
emptyboolean
drawingboolean
disabledboolean
readOnlyboolean
canUndoboolean
canRedoboolean
statusTextstring
translationsSignaturePadTranslations
toSvg() => string
clear() => void
undo() => void
redo() => void
getRootProps() => T['element']
getLabelProps() => T['element']
getControlProps() => T['element']
getGuideProps() => T['element']
getPathProps() => T['element']
getClearTriggerProps() => T['button']
getUndoTriggerProps() => T['button']
getRedoTriggerProps() => T['button']
getStatusProps() => T['element']
getHiddenInputProps() => T['input']

Accessibility ​

Keyboard ​

Specification: W3C APG. Each row is a stable behavior id that the conformance tests cover; the conditions and effects are described on the Chinese page.

KeysBehavior
Enter / Spacesignature-pad.kbd.clear
Enter / Spacesignature-pad.kbd.undo
Enter / Spacesignature-pad.kbd.redo
Enter / Spacesignature-pad.kbd.press

ARIA ​

These attributes are produced by connect.

PartAttributeValue
controlaria-labelprops.ariaLabel
controlaria-labelledbyid of the label part | undefined
controlrole'img'
guidearia-hidden'true'
undo-triggeraria-disabled'true' | undefined
undo-triggeraria-labeltranslations.undoTrigger
redo-triggeraria-disabled'true' | undefined
redo-triggeraria-labeltranslations.redoTrigger
clear-triggeraria-labeltranslations.clearTrigger
statusaria-atomic'true'
statusaria-live'polite'
statusrole'status'
hidden-inputaria-hidden'true'
hidden-inputaria-invalid'true' | 'false'

Style reference ​

Skin ​

@xihan-ui/styles/signature-pad.css is written against [data-scope="signature-pad"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-signature-pad in place of data-scope (same specificity) and sits in the xihan.components layer. Put overrides in xihan.overrides; the part selectors work as usual.

Data attributes ​

Produced by connect; valueless attributes are omitted while their condition does not hold.

PartAttributeValue
rootdata-disabled'' (present only while the condition holds)
rootdata-drawing'' (present only while the condition holds)
rootdata-empty'' (present only while the condition holds)
rootdata-invalid'' (present only while the condition holds)
rootdata-readonly'' (present only while the condition holds)
labeldata-disabled'' (present only while the condition holds)
controldata-disabled'' (present only while the condition holds)
controldata-drawing'' (present only while the condition holds)
controldata-empty'' (present only while the condition holds)
controldata-invalid'' (present only while the condition holds)
controldata-readonly'' (present only while the condition holds)
guidedata-disabled'' (present only while the condition holds)
pathdata-empty'' (present only while the condition holds)
undo-triggerdata-disabled'' (present only while the condition holds)
undo-triggerdata-pressed'' (present only while the condition holds)
undo-triggerdata-xh-action-control''
undo-triggerdata-xh-action-display'always'
undo-triggerdata-xh-action-profile'text'
undo-triggerdata-xh-action-size'sm'
undo-triggerdata-xh-action-variant'outline'
redo-triggerdata-disabled'' (present only while the condition holds)
redo-triggerdata-pressed'' (present only while the condition holds)
redo-triggerdata-xh-action-control''
redo-triggerdata-xh-action-display'always'
redo-triggerdata-xh-action-profile'text'
redo-triggerdata-xh-action-size'sm'
redo-triggerdata-xh-action-variant'outline'
clear-triggerdata-disabled'' (present only while the condition holds)
clear-triggerdata-empty'' (present only while the condition holds)
clear-triggerdata-pressed'' (present only while the condition holds)
clear-triggerdata-xh-action-control''
clear-triggerdata-xh-action-display'always'
clear-triggerdata-xh-action-profile'text'
clear-triggerdata-xh-action-size'sm'
clear-triggerdata-xh-action-variant'outline'
statusdata-empty'' (present only while the condition holds)
hidden-inputdata-disabled'' (present only while the condition holds)

CSS variables ​

The public override slots, generated from what the standalone skin actually consumes.

VariablePartCSS propertyStateDefault from
--xh-signature-pad-aspect-ratiocontrolaspect-ratiodefault5 / 2
--xh-signature-pad-bgcontrolbackgrounddefault--xh-bg-field
--xh-signature-pad-bg-disabledcontrolbackgrounddisabled--xh-bg-subtle
--xh-signature-pad-bg-drawingcontrolbackgrounddrawing--xh-bg-surface
--xh-signature-pad-bg-invalidcontrolbackgroundinvalid--xh-bg-field-invalid
--xh-signature-pad-bg-readonlycontrolbackgrounddisabled
not([data-disabled])
readonly
--xh-bg-subtle
--xh-signature-pad-bordercontrolborderdefault--xh-border-control
--xh-signature-pad-border-disabledcontrolborder-colordisabled--xh-border-default
--xh-signature-pad-border-drawingcontrolborder-colordrawing--xh-border-control-focus
--xh-signature-pad-border-hovercontrolborder-colordisabled
drawing
hover
invalid
not([data-disabled])
not([data-drawing])
not([data-invalid])
not([data-readonly])
readonly
--xh-border-strong
--xh-signature-pad-clear-bgclear-trigger--xh-ink-surface
background-color
default
focus-visible
xh-ink-surface
--xh-_action-variant-bg-focus-visible
--xh-_action-variant-bg-rest
--xh-signature-pad-clear-bg-activeclear-triggerbackground-colordisabled
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-bg-pressed
--xh-signature-pad-clear-bg-disabledclear-trigger--xh-ink-surface
background-color
disabled
xh-ink-surface
--xh-_action-variant-bg-disabled
--xh-signature-pad-clear-bg-hoverclear-triggerbackground-colordisabled
hover
loading
not([data-disabled])
not([data-loading])
--xh-_action-variant-bg-hover
--xh-signature-pad-clear-borderclear-triggerborder
border-color
default
focus-visible
--xh-_action-variant-border-focus-visible
--xh-_action-variant-border-rest
--xh-signature-pad-clear-border-hoverclear-triggerborder-colordisabled
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-border-hover
--xh-_action-variant-border-pressed
--xh-signature-pad-clear-fgclear-triggercolordefault
disabled
focus-visible
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-fg-focus-visible
--xh-_action-variant-fg-hover
--xh-_action-variant-fg-pressed
--xh-_action-variant-fg-rest
--xh-signature-pad-clear-fg-emptyclear-triggercolorempty--xh-fg-muted
--xh-signature-pad-clear-font-sizeclear-triggerfont-sizedefault--xh-_action-profile-font-size
--xh-signature-pad-clear-gapclear-triggergapdefault--xh-_action-profile-gap
--xh-signature-pad-clear-hclear-triggerblock-sizedefault--xh-_action-profile-visual-size
--xh-signature-pad-clear-icon-sizeclear-trigger--xh-icon-sizedefault--xh-_action-profile-glyph-size
--xh-signature-pad-clear-pxclear-triggerpadding-inlinedefault--xh-_action-profile-padding-inline
--xh-signature-pad-clear-radiusclear-triggerborder-radiusdefault--xh-shape-control
--xh-signature-pad-clear-shadow-hoverclear-triggerbox-shadowdisabled
hover
loading
not([data-disabled])
not([data-loading])
none
--xh-signature-pad-control-border-invalidcontrolborder-colorinvalid--xh-border-invalid
--xh-signature-pad-gaplabel
root
gap
margin-block-end
default--xh-space-2
--xh-signature-pad-guide-strokeguidestrokedefault--xh-border-control
--xh-signature-pad-inkpathfilldefault--xh-fg-default
--xh-signature-pad-label-fglabelcolordefault--xh-fg-muted
--xh-signature-pad-label-fg-disabledlabelcolordisabled--xh-fg-muted
--xh-signature-pad-label-font-sizelabelfont-sizedefault--xh-text-label-size
--xh-signature-pad-label-font-weightlabelfont-weightdefault--xh-text-label-weight
--xh-signature-pad-label-gaplabelmargin-block-enddefault--xh-space-2
--xh-signature-pad-radiuscontrolborder-radiusdefault--xh-shape-control
--xh-signature-pad-status-fgstatuscolordefault--xh-fg-muted
--xh-signature-pad-status-font-sizestatusfont-sizedefault--xh-text-secondary-size

Released under The MIT License