Skip to content
Develop cross-plattform MVU GUI Applications using F# and Avalonia!
F#
Branch: master
Clone or download

README.md

Avalonia FuncUI

Avalonia FuncUI

Develop cross-platform MVU GUI Applications using F# and Avalonia!

GitHub top language GitHub repo size


(Application was created using Avalonia.FuncUI!)

About

This library allows you to write cross-platform GUI Applications entirely in F# - No XAML, but a declarative Elm-like DSL. MVU (Model-View-Update) architecture support is built in, and bindings to use it with Elmish are also ready to use.

Getting started

Check out the Wiki (WIP - examples are currently for 0.1.x) and Examples.

🧱 Templates

Contributing

Please contribute to this library through issue reports, pull requests, code reviews, documentation, and discussion.

Example

Below is the code of a simple counter app (using the Avalonia.FuncUI.Elmish package).

module Counter =

    type CounterState = {
        count : int
    }

    let init = {
        count = 0
    }

    type Msg =
    | Increment
    | Decrement

    let update (msg: Msg) (state: CounterState) : CounterState =
        match msg with
        | Increment -> { state with count =  state.count + 1 }
        | Decrement -> { state with count =  state.count - 1 }
    
    let view (state: CounterState) (dispatch): IView =
        DockPanel.create [
            DockPanel.children [
                Button.create [
                    Button.onClick (fun _ -> dispatch Increment)
                    Button.content "click to increment"
                ]
                Button.create [
                    Button.onClick (fun _ -> dispatch Decrement)
                    Button.content "click to decrement" 
                ]
                TextBlock.create [
                    TextBlock.dock Dock.Top
                    TextBlock.text (sprintf "the count is %i" state.count)
                ]
            ]
        ]    
You can’t perform that action at this time.