Skip to content
This repository has been archived by the owner on Jun 25, 2023. It is now read-only.

Latest commit

 

History

History
52 lines (41 loc) · 1.22 KB

TextBox.md

File metadata and controls

52 lines (41 loc) · 1.22 KB
layout name group
control
TextBox
controls

Note: You can check the Avalonia docs for the TextBox and TextBox API if you need more information.

For Avalonia.FuncUI's DSL properties you can check TextBox.fs

The textbox is a control that allows a user to input strings.

Usage

Basic usage

TextBox.create [
    TextBox.text <text-for-box>
    TextBox.onTextChanged (fun newString ->
        // Do something with the changed string
    )
]

Example

Often you simply save the string in the state and use it for other things from there:

TextBox

type State = {
    myString: string
}

type Msg =
    | ChangeMyString of string

let update msg state =
    match msg with
    | ChangeMyString newString ->
        { state with myString = newString }

let view state dispatch =
    TextBox.create [
        TextBox.text state.myString
        TextBox.onTextChanged (ChangeMyString >> dispatch)
    ]