compose-signature
1.0.2indexedHighly customizable digital signature library enables drawing with features like undo/redo, grid display, fullscreen mode, real-time updates, state management, and multiple export options.
Highly customizable digital signature library enables drawing with features like undo/redo, grid display, fullscreen mode, real-time updates, state management, and multiple export options.
A customizable Compose Multiplatform library for capturing digital signatures. The library provides comprehensive state management, undo/redo functionality, and support for Android, iOS, Desktop ( JVM), and Web (JS/WASM) platforms.
Add the dependency to your build.gradle.kts:
dependencies {
implementation("io.github.niyajali:compose-signature:1.0.2")
}
@Composable
fun SimpleSignature() {
var signature by remember { mutableStateOf<ImageBitmap?>(null) }
ComposeSign(
onSignatureUpdate = { signature = it },
modifier = Modifier
.fillMaxWidth()
.height(200.dp)
)
}
@Composable
fun AdvancedSignature() {
signatureState = rememberSignatureState()
signature remember { mutableStateOf<ImageBitmap?>() }
ComposeSign(
onSignatureUpdate = { signature = it },
config = SignatureConfig(
strokeColor = Color.Blue,
strokeWidth = dp,
backgroundColor = Color.White,
showGrid = ,
gridColor = Color.Gray.copy(alpha = ),
showActions = ,
borderStroke = BorderStroke(dp, Color.Gray),
cornerShape = RoundedCornerShape(dp)
),
state = signatureState,
onActionClicked = { action ->
(action) {
SignatureAction.CLEAR -> signatureState.clear()
SignatureAction.UNDO -> signatureState.undo()
SignatureAction.REDO -> signatureState.redo()
SignatureAction.SAVE -> {
signature?.let { }
}
}
}
)
}
The main composable provides multiple overloads for different levels of customization:
// Simple usage
ComposeSign(onSignatureUpdate = { signature = it })
// Basic customization
ComposeSign(
onSignatureUpdate = { signature = it },
strokeColor = Color.Blue,
strokeWidth = 4.dp,
showGrid = true
)
// Full configuration
ComposeSign(
onSignatureUpdate = { signature = it },
config = SignatureConfig(/* ... */),
state = rememberSignatureState(),
onActionClicked = { action -> /* handle action */ }
)
Configuration object for controlling visual appearance and behavior:
Predefined configurations are available:
SignatureConfig.Default - Standard configurationSignatureConfig.Fullscreen - Fullscreen mode with actionsManages signature paths, input state, and history:
val state = rememberSignatureState()
// Available properties
state.paths // List of signature paths
state.inputState // Current input state (IDLE, DRAWING, COMPLETED)
state.signature // Generated ImageBitmap
state.canUndo // Whether undo is available
state.canRedo // Whether redo is available
// Operations
state.addPath(path)
state.clear()
state.undo()
state.redo()
// Extension functions
state.isEmpty()
state.getSignatureBounds()
state.getMetadata()
state.exportSignature(width, height)
state.isValid()
@Composable
fun FullscreenExample() {
var showFullscreen by remember { mutableStateOf(false) }
var signature by remember { mutableStateOf<ImageBitmap?>(null) }
if (showFullscreen) {
ComposeSignFullscreen(
onSignatureUpdate = { signature = it },
onDismiss = { showFullscreen = false },
config = SignatureConfig.Fullscreen
)
}
}
// Dark theme
ComposeSign(config = SignatureConfig.Default.asDarkTheme())
// High contrast for accessibility
ComposeSign(config = SignatureConfig.Default.asAccessible(highContrast = true))
// Form integration
ComposeSign(config = SignatureConfig.FormIntegration)
@Composable
fun MultiColorSignature() {
var currentColor by remember { mutableStateOf(Color.Black) }
ComposeSign(
onSignatureUpdate = { signature = it },
strokeColor = currentColor,
strokeWidth = 4.dp,
showGrid = true
)
ColorPicker(
selectedColor = currentColor,
onColorSelected = { currentColor = it }
)
}
val state = rememberSignatureState()
val metadata = state.getMetadata()
println("Path count: ${metadata.pathCount}")
println("Complexity: ${metadata.complexityDescription()}")
println("Total length: ${metadata.totalLength}")
val bounds = state.getSignatureBounds()
bounds?.let {
println("Dimensions: ${it.width} x ${it.height}")
println("Area: ${it.area()}")
}
val isValid = state.isValid(
minPaths = 5,
minLength = 100f,
minComplexity = 20
)
The library follows SOLID principles with clear separation of concerns:
Copyright 2026 Niyaj Ali
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http:
Unless applicable law agreed to writing, software
distributed under the License distributed an BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express implied.
See the License the specific language governing permissions
limitations under the License.
data class SignatureConfig(
val strokeColor: Color = Color.Black,
val strokeWidth: Dp = 3.dp,
val backgroundColor: Color = Color.White,
val borderStroke: BorderStroke? = BorderStroke(1.dp, Color.Gray),
val cornerShape: CornerBasedShape = RoundedCornerShape(8.dp),
val showGrid: Boolean = false,
val gridColor: Color = Color.Gray.copy(alpha = 0.3f),
val gridSpacing: Dp = 20.dp,
val isFullScreen: Boolean = false,
val minHeight: Dp = 200.dp,
val maxHeight: Dp = 400.dp,
val showActions: Boolean = false,
val enableSmoothDrawing: Boolean = true
)
SignatureConfig.WithGrid - Includes grid overlaySignatureConfig.ThickStroke - Thicker stroke widthSignatureConfig.Professional - Professional document stylingSignatureConfig.Creative - Creative color schemeSignatureConfig.FormIntegration - Compact form stylingSurfaced from shared tags and platforms — no rankings paid for.