Ruckus T-Boom edited this page Jul 12, 2016 · 9 revisions



Forms can be built using type safe builders or with FXML.

Fieldsets and Fields

A Fieldset contains a collection of Field entries. The Fieldset can have a title and optional icon. A Field has a label and icon as well, and a container for one or more input fields, much the same way as an HTML form.

Label position

Fieldsets have a labelPosition value of HORIZONTAL by default, causing labels to appear to the left the input fields. Set the labelPosition to VERTICAL to have the label appear above the inputs.

Responsive layout

By configuring the wrapWidth, a HORIZONTAL form will responsively fall back to a VERTICAL label layout to save space once the Form is resized to be smaller than the wrapWidth.

FXML Example

Code example with binding

class CustomerForm : View() {
    override val root = Form()

    val customer = Customer()

    init {
        title = "Register Customer"

        with (root) {
            fieldset("Personal Information", FontAwesomeIconView(USER)) {
                field("Name") {

                field("Birthday") {

            fieldset("Address", FontAwesomeIconView(HOME)) {
                field("Street") {
                field("Zip / City") {
                    textfield() {

            button("Save") {
                setOnAction {
                            .title("Customer saved!")
                            .text("${} was born ${customer.birthday}\nand lives in\n${customer.street}, ${} ${}")

                // Save button is disabled until every field has a value


There is an example application that showcases the above form in the TornadoFX-Samples project.

Styling with CSS

Take a look at the default CSS Stylesheet as a starting point. The substructure of a Form is described below.


  • form - VBox
    • fieldset - VBox
      • legend - Label
      • field - Field
        • label-container - HBox
          • label - Label
        • input-container - HBox
          • arbitrary input components

Next: ViewModel