How can I help you?
Customization in Angular Signature component
26 Feb 20269 minutes to read
Customize the Signature component’s appearance by modifying stroke properties, background colors, and images. The component uses Canvas API methods (moveTo and lineTo) to render strokes with customizable width, color, and background styling.
Stroke Width
Control stroke width dynamically using the maxStrokeWidth, minStrokeWidth, and velocity properties for smooth, realistic signatures. Default values: minStrokeWidth = 0.5, maxStrokeWidth = 2.5, velocity = 0.7. The following example customizes these values.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { FormsModule } from '@angular/forms'
import { SignatureModule } from '@syncfusion/ej2-angular-inputs'
import { enableRipple } from '@syncfusion/ej2-base'
import { Component } from '@angular/core';
import { SignatureComponent } from '@syncfusion/ej2-angular-inputs';
enableRipple(true);
@Component({
imports: [
FormsModule,SignatureModule
],
standalone: true,
selector: 'app-root',
template: `<div class="e-section-control">
<h4>Sign here</h4>
<!-- To Render Signature. -->
<canvas ejs-signature #signature id="signature" [maxStrokeWidth]="3" [minStrokeWidth]="0.5" [velocity]="0.7"></canvas></div>`
})
export class AppComponent {
}import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));Stroke Color
Specify the stroke color using the strokeColor property. It accepts hexadecimal codes, RGB values, and color names. Default value: #000000 (black).
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { FormsModule } from '@angular/forms'
import { SignatureModule } from '@syncfusion/ej2-angular-inputs'
import { ButtonModule } from '@syncfusion/ej2-angular-buttons'
import { enableRipple } from '@syncfusion/ej2-base'
import { Component, ViewChild } from '@angular/core';
import { SignatureComponent } from '@syncfusion/ej2-angular-inputs';
enableRipple(true);
@Component({
imports: [
FormsModule,ButtonModule,SignatureModule
],
standalone: true,
selector: 'app-root',
template: `<div class="e-section-control">
<div id="input">
<input type="text" id="text" placeholder="Enter the Stroke Color Value" >
<button ejs-button cssClass="e-primary" (click)="setColor()">Set Stroke Color</button>
</div>
<div id="signature-control">
<canvas ejs-signature #signature id="signature"></canvas>
</div>
</div>`
})
export class AppComponent {
@ViewChild('signature')
public signature?: SignatureComponent;
setColor(): void {
let color = (document.getElementById('text') as any).value;
this.signature!.strokeColor = color;
}
}import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));Background Color
Set the background color using the backgroundColor property. It accepts hexadecimal codes, RGB values, and color names. Default value: #ffffff (white).
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { FormsModule } from '@angular/forms'
import { SignatureModule } from '@syncfusion/ej2-angular-inputs'
import { ButtonModule } from '@syncfusion/ej2-angular-buttons'
import { enableRipple } from '@syncfusion/ej2-base'
import { Component, ViewChild } from '@angular/core';
import { SignatureComponent } from '@syncfusion/ej2-angular-inputs';
enableRipple(true);
@Component({
imports: [
FormsModule,ButtonModule,SignatureModule
],
standalone: true,
selector: 'app-root',
template: `<div class="e-section-control">
<div id="input">
<input type="text" id="text" placeholder="Enter the Background Color Value" >
<button ejs-button cssClass="e-primary" (click)="setBgColor()">Set Background Color</button>
</div>
<div id="signature-control">
<canvas ejs-signature #signature id="signature"></canvas>
</div>
</div>`
})
export class AppComponent {
@ViewChild('signature')
public signature?: SignatureComponent;
setBgColor(): void {
let bgColor = (document.getElementById('text') as any).value;
this.signature!.backgroundColor = bgColor;
}
}import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));Background Image
Set a background image using the backgroundImage property. The image can be hosted locally or retrieved from an online source via URL.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { FormsModule } from '@angular/forms'
import { SignatureModule } from '@syncfusion/ej2-angular-inputs'
import { ButtonModule } from '@syncfusion/ej2-angular-buttons'
import { enableRipple } from '@syncfusion/ej2-base'
import { Component, ViewChild } from '@angular/core';
import { SignatureComponent } from '@syncfusion/ej2-angular-inputs';
enableRipple(true);
@Component({
imports: [
FormsModule,ButtonModule,SignatureModule
],
standalone: true,
selector: 'app-root',
template: `<div class="e-section-control">
<div id="input">
<input type="text" id="text" placeholder="Enter the URL of the background Image" >
<button ejs-button cssClass="e-primary" (click)="setBgImage()">Set Background Image</button>
</div>
<div id="signature-control">
<canvas ejs-signature #signature id="signature"></canvas>
</div>
</div>`
})
export class AppComponent {
@ViewChild('signature')
public signature?: SignatureComponent;
setBgImage(): void {
let bgImage = (document.getElementById('text') as any).value;
this.signature!.backgroundImage = bgImage;
}
}import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));