compose-form

Lightweight, customizable form-builder DSL with reusable fields, built-in field and form validation, stateful ViewModel access, change observation, and custom input field support.

Android JVMJVMKotlin/NativeWasmJS
GitHub stars0
Open issues0
Creation date5 months ago

Last activityabout 1 month ago
Latest release1.0.0 (15 days ago)

Compose Form


A lightweight and customisable Form builder DSL for Compose Multiplatform

Features


  • Cross-platform support
  • Build compose forms in a quick and reusable way
  • Built in validation on a field and form wide level
  • Access current form value statefully and at the ViewModel level
  • Observe value changes
  • Out of the box input fields
  • Implement custom fields to match your design

Quick Start

Setup

Android

dependencies{
    ...
    implementation("io.github.idscodelabs:compose-form:$version")
}

Multiplatform

commonMain.dependencies{
    ...
    implementation("io.github.idscodelabs:compose-form:$version")
}

Version catalog

TOML
[versions]
compose-form = "<version>"

[libraries]
compose-form = { module = "io.github.idscodelabs:compose-form", version.ref = "compose-form" }
build.gradle.kts
commonMain.dependencies{
    ...
    implementation(libs.compose.form)
}

Basic Usage

// Define your model
data class FormTextFieldExampleModel(
    var value: String? = null,
)

...

// Create the form
Form(emptyModel = ::FormTextFieldExampleModel) {
    
    // Add fields
    FormTextField(
        modelProperty = FormTextFieldExampleModel::value,
        validator = NotEmptyValidator(), // Add validation
        updateModel = { value = it },
        hint = "Value"
    )
    
    // Submit the form
    Button(onClick = submitFunction {
        // Do something with the result
    }) {
        Text("Submit")
    }
}
Android JVMJVMKotlin/NativeWasmJS
GitHub stars0
Open issues0
Creation date5 months ago

Last activityabout 1 month ago
Latest release1.0.0 (15 days ago)

Compose Form


A lightweight and customisable Form builder DSL for Compose Multiplatform

Features


  • Cross-platform support
  • Build compose forms in a quick and reusable way
  • Built in validation on a field and form wide level
  • Access current form value statefully and at the ViewModel level
  • Observe value changes
  • Out of the box input fields
  • Implement custom fields to match your design

Quick Start

Setup

Android

dependencies{
    ...
    implementation("io.github.idscodelabs:compose-form:$version")
}

Multiplatform

commonMain.dependencies{
    ...
    implementation("io.github.idscodelabs:compose-form:$version")
}

Version catalog

TOML
[versions]
compose-form = "<version>"

[libraries]
compose-form = { module = "io.github.idscodelabs:compose-form", version.ref = "compose-form" }
build.gradle.kts
commonMain.dependencies{
    ...
    implementation(libs.compose.form)
}

Basic Usage

// Define your model
data class FormTextFieldExampleModel(
    var value: String? = null,
)

...

// Create the form
Form(emptyModel = ::FormTextFieldExampleModel) {
    
    // Add fields
    FormTextField(
        modelProperty = FormTextFieldExampleModel::value,
        validator = NotEmptyValidator(), // Add validation
        updateModel = { value = it },
        hint = "Value"
    )
    
    // Submit the form
    Button(onClick = submitFunction {
        // Do something with the result
    }) {
        Text("Submit")
    }
}