---
title: Signature
product: Form Library
description: Add a signature pad to your e-forms to enable respondents to sign it with a handwritten but digitally captured signature once all required fields are filled out. View a free demo example for JavaScript to learn more.
framework: React
source: https://surveyjs.io/form-library/examples/signature-pad-widget-javascript/reactjs
index: https://surveyjs.io/form-library/examples/overview.md
---

# Signature (React)

A built-in JavaScript signature capture widget allows your respondents to add a digital signature to a web form that they fill out. Switch between available front-end frameworks to see a dedicated demo version of an e-signature pad widget for jQuery, React, Angular, Vue, or Vanilla JavaScript. Draw your e-signature with the mouse pointer or your finger on a touch-enabled device to try the functionality.

To add a signature pad JavaScript widget to your survey, define an object with the `type` property set to `"signaturepad"` and add it to the [`elements`](https://surveyjs.io/form-library/documentation/pagemodel#elements) array. You can also specify [`penColor`](https://surveyjs.io/form-library/documentation/questionsignaturepadmodel#penColor) and use the [`signatureHeight`](https://surveyjs.io/form-library/documentation/questionsignaturepadmodel#signatureHeight) and [`signatureWidth`](https://surveyjs.io/form-library/documentation/questionsignaturepadmodel#signatureWidth) properties to resize the signature box.

The signature can be saved in PNG (default), JPEG, or SVG. Set the [`dataFormat`](https://surveyjs.io/form-library/documentation/questionsignaturepadmodel#dataFormat) property to change the format.

## Files

### `public/index.html`

```html
<div id="surveyElement" style="position: absolute; top: 0; left: 0; right: 0; bottom: 0; min-height: 100%; height:100%"></div>
```

### `src/SurveyComponent.jsx`

```js
import React from "react";
import { Model } from "survey-core";
import { Survey } from "survey-react-ui";
import "survey-core/survey-core.min.css";
import "./index.css";
import { json } from "./json";

function SurveyComponent() {
    const survey = new Model(json);
    survey.onComplete.add((sender, options) => {
        console.log(JSON.stringify(sender.data, null, 3));
    });
    return (<Survey model={survey} />);
}

export default SurveyComponent;
```

### `src/index.css`

```css
/* You can add your custom CSS here. */
```

### `src/index.js`

```js
import React from "react";
import { createRoot } from "react-dom/client";
import SurveyComponent from "./SurveyComponent";

const root = createRoot(document.getElementById("surveyElement"));
root.render(<SurveyComponent />);
```

### `src/json.js`

```js
export const json = {
  "elements": [
    {
      "type": "signaturepad",
      "name": "signature",
      "title": "Please sign here",
      "isRequired": true,
      "signatureWidth": 600
    }
  ]
};
```

### `src/theme.js`

```js
export const themeJson = {};
```

### `package.json`

```json
{
  "dependencies": {
    "react": "latest",
    "react-dom": "latest",
    "survey-core": "latest",
    "survey-react-ui": "latest"
  },
  "devDependencies": {
    "react-scripts": "latest"
  }
}
```

## Other Frameworks

- [Angular](https://surveyjs.io/form-library/examples/signature-pad-widget-javascript/angular.md)
- [Vue 3](https://surveyjs.io/form-library/examples/signature-pad-widget-javascript/vue3js.md)
- [jQuery](https://surveyjs.io/form-library/examples/signature-pad-widget-javascript/jquery.md)
- [Vanilla JS](https://surveyjs.io/form-library/examples/signature-pad-widget-javascript/vanillajs.md)
