承接 mrshanebarron/signature-pad 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mrshanebarron/signature-pad

最新稳定版本:v1.0.3

Composer 安装命令:

composer require mrshanebarron/signature-pad

包简介

Signature pad component for Laravel - supports Livewire and Vue

README 文档

README

Digital signature capture component for Laravel applications. Supports touch and mouse input, customizable colors and stroke width, and exports to PNG data URL. Works with Livewire and Vue 3.

Installation

composer require mrshanebarron/signature-pad

Livewire Usage

Basic Usage

<livewire:sb-signature-pad />

Custom Dimensions

<livewire:sb-signature-pad
    :width="600"
    :height="200"
/>

Custom Colors

<livewire:sb-signature-pad
    stroke-color="#0000FF"
    background-color="#F5F5F5"
/>

Custom Stroke Width

<livewire:sb-signature-pad :stroke-width="3" />

With Wire Model

<livewire:sb-signature-pad wire:model="signature" />

Livewire Props

Prop Type Default Description
signature string null Base64 PNG data URL (modelable)
width int 400 Canvas width in pixels
height int 200 Canvas height in pixels
strokeColor string '#000000' Pen color (hex)
strokeWidth int 2 Line thickness in pixels
backgroundColor string '#ffffff' Canvas background color

Methods

The component exposes a clear() method:

<livewire:sb-signature-pad wire:ref="signaturePad" />
<button wire:click="$refs.signaturePad.clear()">Clear</button>

Vue 3 Usage

Setup

import { SbSignaturePad } from './vendor/sb-signature-pad';
app.component('SbSignaturePad', SbSignaturePad);

Basic Usage

<template>
  <SbSignaturePad v-model="signature" />
</template>

<script setup>
import { ref } from 'vue';
const signature = ref(null);
</script>

Custom Configuration

<template>
  <SbSignaturePad
    v-model="signature"
    :width="500"
    :height="250"
    stroke-color="#1a365d"
    :stroke-width="3"
    background-color="#edf2f7"
    ref="pad"
  />
  <button @click="$refs.pad.clear()">Clear</button>
  <button @click="save">Save</button>
</template>

<script setup>
import { ref } from 'vue';
const signature = ref(null);

function save() {
  console.log('Signature:', signature.value); // Base64 PNG
}
</script>

Vue Props

Prop Type Default Description
modelValue String null v-model binding for signature data
width Number 400 Canvas width
height Number 200 Canvas height
strokeColor String '#000000' Pen color
strokeWidth Number 2 Line thickness
backgroundColor String '#ffffff' Background color

Methods

Method Description
clear() Clear the signature canvas
toDataURL() Get the signature as base64 PNG
isEmpty() Check if canvas is empty

Events

Event Payload Description
update:modelValue string Emitted when signature changes
signature-saved string Emitted with data URL when saved
signature-cleared - Emitted when canvas is cleared

Saving Signatures

The signature is exported as a base64-encoded PNG data URL:

// In your Livewire component
public string $signature = '';

public function save()
{
    // $this->signature contains: data:image/png;base64,...

    // Save to file
    $data = base64_decode(str_replace('data:image/png;base64,', '', $this->signature));
    file_put_contents(storage_path('signatures/sig.png'), $data);

    // Or save to database
    $user->update(['signature' => $this->signature]);
}

Touch Support

The component supports:

  • Mouse drawing (desktop)
  • Touch drawing (tablets, phones)
  • Prevents scrolling while signing

Styling

The signature pad includes:

  • Rounded border
  • Shadow on focus
  • Clear button styling
  • Responsive container

Requirements

  • PHP 8.1+
  • Laravel 10, 11, or 12
  • Tailwind CSS 3.x

License

MIT License

统计信息

  • 总下载量: 10
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: Vue

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固