Skip to main content

Text Input

The Text Input widget provides a single-line text input field that allows users to enter and edit text.

States

StateTypeDefaultDescription
valuestringNoneCurrent text content of the input

Properties

PropertyTypeDefaultDescription
labelstring""Label text displayed above the input
placeholderstring""Placeholder text displayed when the input is empty
default_valuestringNoneInitial value of the input
requiredboolFalseWhether the input is required
disabledboolFalseWhether the input is disabled
max_lengthint32NoneMaximum number of characters allowed
min_lengthint32NoneMinimum number of characters allowed

Examples

Basic Text Input

package main

import (
"github.com/sourcetool/sourcetool-go"
"github.com/sourcetool/sourcetool-go/textinput"
)

func main() {
// Create a basic text input
textInput := ui.TextInput("Name", textinput.Placeholder("Enter your name"))
}

Disabled Text Input

// Create a disabled text input
textInput := ui.TextInput("Name", textinput.Placeholder("Enter your name"), textinput.Disabled(true))

Text Input with Length Constraints

// Create a text input with length constraints
passwordInput := ui.TextInput("Password", textinput.Placeholder("Enter a secure password"), textinput.Required(true), textinput.MinLength(8), textinput.MaxLength(64))