# Embedded Signature Maker (JavaScript)

This component allows you to seamlessly add drawing signature functionality to your website or mobile app. It supports [JS+HTML](https://github.com/docusealco/signature-maker-js), [Vue](https://github.com/docusealco/signature-maker-vue) and [React](https://github.com/docusealco/signature-maker-react).

## Example code

```html
<signature-maker id="signatureMaker"></signature-maker>

<script>
  window.signatureMaker.addEventListener('change', (e) => {
    if (e.detail.base64) {
      fetch('/background-save-signature', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ file: e.detail.base64 }),
      });
    } else {
      console.log('No signature to save');
    }
  })
</script>
```

## Attributes

| Attribute | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| data-download-on-save | boolean | No | `false` | Set `false` to disable downloading the signature image on save. It's useful when you want to handle the image data yourself. |
| data-with-typed | boolean | No | `true` | Set `false` to disable text signature input panel. |
| data-with-drawn | boolean | No | `true` | Set `false` to disable drawing signature panel. |
| data-with-upload | boolean | No | `true` | Set `false` to disable uploading signature image panel. |
| data-with-color-select | boolean | No | `true` | Set `false` to disable color selection. Only black color will be available. |
| data-with-submit | boolean | No | `true` | Set `false` to disable the submit button. Any changes will be available as a base64 string in the `change` event. Custom event 'save' will be triggered on clicking the submit button. |
| data-save-button-text | string | No | `Submit` |  |
| data-control-buttons-container-class | string | No |  | Custom CSS class for the control buttons container. Example: `flex gap-2` |
| data-control-buttons-container-style | string | No | `display: flex; align-items: center; justify-content: space-between; text-align: center; margin: 1rem 0;` | Custom CSS styles for the control buttons container. Default CSS styles will be disabled |
| data-save-button-class | string | No |  | Custom CSS class for the save button Example: `btn btn-neutral text-white text-base w-full` |
| data-save-button-style | string | No | `color: #ffffff; font-family: ui-sans-serif, system-ui, sans-serif font-size: 16px; font-weight: 600; line-height: 24px; padding: 0px 16px; text-transform: uppercase; background-color: #222222; cursor: pointer; align-items: center; border-radius: 8px; gap: 8px; display: inline-flex; flex-shrink: 0; flex-wrap: wrap; height: 48px; justify-content: center; outline-color: #222222; text-align: center; text-decoration-line: none; width: 100%; border: 1px solid #222222;` | Custom CSS styles for the save button |
| data-save-button-disabled-class | string | No |  | Custom CSS class for the disabled save button. Example: `btn-disabled` |
| data-save-button-disabled-style | string | No | `background-color: #D3D3D3; color: #808080; cursor: not-allowed; border: 0;` | Custom CSS styles for the disabled save button. |
| data-undo-button-text | string | No | `Undo` |  |
| data-undo-button-class | string | No |  | Custom CSS class for the undo button. Example: `btn btn-outline btn-sm font-medium` |
| data-undo-button-style | string | No | `color: #222222; background-color: transparent; font-family: ui-sans-serif, system-ui, sans-serif; font-size: 14px; font-weight: 500; line-height: 14px; padding: 0px 12px; text-transform: uppercase; appearance: button; cursor: pointer; align-items: center; border-radius: 8px; gap: 8px; display: inline-flex; flex-shrink: 0; flex-wrap: wrap; height: 32px; justify-content: center; outline-color: #222222; text-align: center; border: 1px solid #222222;` | Custom CSS styles for the undo button. |
| data-clear-button-text | string | No | `Clear` | Custom text for the clear button. |
| data-clear-button-class | string | No |  | Custom CSS class for the clear button. Example: `btn btn-outline btn-sm font-medium` |
| data-clear-button-style | string | No | `color: #222222; background-color: transparent; font-family: ui-sans-serif, system-ui, sans-serif; font-size: 14px; font-weight: 500; line-height: 14px; padding: 0px 12px; text-transform: uppercase; appearance: button; cursor: pointer; align-items: center; border-radius: 8px; gap: 8px; display: inline-flex; flex-shrink: 0; flex-wrap: wrap; height: 32px; justify-content: center; outline-color: #222222; text-align: center; border: 1px solid #222222;` | Custom CSS styles for the clear button. |
| data-text-input-placeholder | string | No | `Type signature here` | Custom placeholder text for the text input field. |
| data-text-input-class | string | No |  | Custom CSS class for the text input field. Example: `input mb-4 input-bordered bg-white text-2xl w-full h-14 rounded-2xl` |
| data-text-input-style | string | No | `color: #222222; font-family: ui-sans-serif, system-ui, sans-serif; font-size: 24px; font-weight: 400; line-height: 32px; margin: 0px 0px 16px; padding: 0px 16px; background-color: #ffffff; border-radius: 8px; flex-shrink: 1; height: 56px; outline: #222222 none 0px; outline-offset: 0px; width: 100%; text-align: start; border: 1px solid #D3D3D3;` | Custom CSS styles for the text input field. |
| data-canvas-class | string | No |  | Custom CSS class for the canvas element. Example: `bg-white border border-base-300 rounded-2xl w-full` |
| data-canvas-style | string | No | `display: block; vertical-align: middle; width: 100%; border-radius: 8px; background-color: #ffffff; padding: 1px; touch-action: none; user-select: none; text-align: center; line-height: 24px; border: 1px solid #D3D3D3;` | Custom CSS styles for the canvas element. |
| data-type-buttons-container-class | string | No |  | Custom CSS class for the type buttons container. Example: `flex gap-2 mb-4 justify-center` |
| data-type-buttons-container-style | string | No | `margin-bottom: 1rem; display: flex; justify-content: center; flex-wrap: wrap; gap: 0.5rem;` | Custom CSS styles for the type buttons container. |
| data-draw-type-button-text | string | No | `Draw` | Custom text for the draw type button. |
| data-draw-type-button-class | string | No |  | Custom CSS class for the draw type button. Example: `flex items-center justify-center py-3 w-40 uppercase border-neutral-focus space-x-2 border rounded-3xl cursor-pointer hover:bg-neutral hover:text-white hover:font-semibold` |
| data-draw-type-button-style | string | No | `color: #222222; font-family: ui-sans-serif, system-ui, sans-serif; font-size: 16px; font-weight: 500; line-height: 24px; padding: 0px 40px; text-transform: uppercase; background-color: transparent; cursor: pointer; align-items: center; border-radius: 8px; gap: 8px; display: inline-flex; flex-shrink: 0; flex-wrap: wrap; height: 48px; justify-content: center; outline-color: #222222; text-align: center; border: 1px solid #222222;` | Custom CSS styles for the draw type button. |
| data-draw-type-button-active-class | string | No |  | Custom CSS class for the active draw type button. Example: `bg-neutral text-white font-semibold` |
| data-draw-type-button-active-style | string | No | `color: #fff; background-color: #222222; font-weight: 500;` | Custom CSS styles for the active draw type button. |
| data-text-type-button-text | string | No | `Type` | Custom text for the text type button. |
| data-text-type-button-class | string | No |  | Custom CSS class for the text type button. Example: `flex items-center justify-center py-3 w-40 uppercase border-neutral-focus space-x-2 border rounded-3xl cursor-pointer hover:bg-neutral hover:text-white hover:font-semibold` |
| data-text-type-button-style | string | No | `color: #222222; font-family: ui-sans-serif, system-ui, sans-serif; font-size: 16px; font-weight: 500; line-height: 24px; padding: 0px 40px; text-transform: uppercase; background-color: transparent; cursor: pointer; align-items: center; border-radius: 8px; gap: 8px; display: inline-flex; flex-shrink: 0; flex-wrap: wrap; height: 48px; justify-content: center; outline-color: #222222; text-align: center; border: 1px solid #222222;` | Custom CSS styles for the text type button. |
| data-text-type-button-active-class | string | No |  | Custom CSS class for the active text type button. Example: `bg-neutral text-white font-semibold` |
| data-text-type-button-active-style | string | No | `color: #fff; background-color: #222222; font-weight: 500;` | Custom CSS styles for the active text type button. |
| data-upload-type-button-text | string | No | `Type` | Custom text for the upload type button. |
| data-upload-type-button-class | string | No |  | Custom CSS class for the upload type button. Example: `flex items-center justify-center py-3 w-40 uppercase border-neutral-focus space-x-2 border rounded-3xl cursor-pointer hover:bg-neutral hover:text-white hover:font-semibold` |
| data-upload-type-button-style | string | No | `color: #222222; font-family: ui-sans-serif, system-ui, sans-serif; font-size: 16px; font-weight: 500; line-height: 24px; padding: 0px 40px; text-transform: uppercase; background-color: transparent; cursor: pointer; align-items: center; border-radius: 8px; gap: 8px; display: inline-flex; flex-shrink: 0; flex-wrap: wrap; height: 48px; justify-content: center; outline-color: #222222; text-align: center; border: 1px solid #222222;` | Custom CSS styles for the upload type button. |
| data-upload-type-button-active-class | string | No |  | Custom CSS class for the active upload type button. Example: `bg-neutral text-white font-semibold` |
| data-upload-type-button-active-style | string | No | `color: #fff; background-color: #222222; font-weight: 500;` | Custom CSS styles for the active upload type button. |
| data-font-url | string | No | `https://cdn.jsdelivr.net/npm/@fontsource/dancing-script/files/dancing-script-latin-400-normal.woff` | Custom font URL to be used for the text signature input panel. |

## Callbacks

| Callback | Description |
| --- | --- |
| change | Custom event to be triggered every time a change to the signature is made. Example: `document.querySelector('signature-maker').addEventListener('change', (e) => e.detail)` |
| save | Custom event to be triggered on saving changes of the signature. data-with-submit attribute should be enabled to trigger this event. Example: `document.querySelector('signature-maker').addEventListener('save', (e) => e.detail)` |

## Other frameworks

- [React](https://www.docuseal.com/docs/embedded/signature/react.md)
- [Vue](https://www.docuseal.com/docs/embedded/signature/vue.md)

## Other embedded components

- [Embedded Signing Form](https://www.docuseal.com/docs/embedded/form/js.md)
- [Embedded Form Builder](https://www.docuseal.com/docs/embedded/builder/js.md)
