# Field Row with Flex Style
# Demonstrates how to use component.field-row with flex ratios
# to control the proportional width of form fields in a row layout.
title: Field Row with Flex Style
type: jig.default
header:
type: component.jig-header
options:
height: medium
children:
type: component.image
options:
source:
uri: https://images.unsplash.com/photo-1588333489536-0ec90908a41f?q=80&w=1447&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D
children:
# Section 1: Equal 1:1:2 ratio
# Three text fields in a single row.
# Title and Initials each occupy 1 unit of width; Last name occupies 2 units.
# Resulting layout: [Title 25%] [Initials 25%] [Last name 50%]
- type: component.section
options:
title: Field row (Flex ratio -Equal 1:1:2)
children:
- type: component.field-row
options:
children:
# Flex 1 - takes up 1/4 of the available row width
- type: component.text-field
instanceId: title
options:
label: Title
style:
flex: 1
# Flex 1 - takes up 1/4 of the available row width
- type: component.text-field
instanceId: initials
options:
label: Initials
style:
flex: 1
# Flex 2 - takes up 2/4 (half) of the available row width
- type: component.text-field
instanceId: lastName
options:
label: Last name
style:
flex: 2
# Section 2: Equal 2:1 ratio
# Two dropdowns in a single row.
# Country occupies 2 units; Code occupies 1 unit.
# Resulting layout: [Country ~67%] [Code ~33%]
- type: component.section
options:
title: Field row (Flex ratio -Equal 2:1)
children:
- type: component.field-row
options:
children:
# Flex 2 - takes up 2/3 of the available row width
# Populated from the dial-code datasource; value = country name
- type: component.dropdown
instanceId: country
options:
label: Country
data: =@ctx.datasources.dial-code
item:
type: component.dropdown-item
options:
title: =@ctx.current.item.country
value: =@ctx.current.item.country
style:
flex: 2
# Flex 1 - takes up 1/3 of the available row width
# Populated from the dial-code datasource; value = dial code
- type: component.dropdown
instanceId: code
options:
label: Code
data: =@ctx.datasources.dial-code
item:
type: component.dropdown-item
options:
title: =@ctx.current.item.code
value: =@ctx.current.item.code
style:
flex: 1
# Section 3: Equal 1:2:2 ratio
# Three number fields in a single row.
# Amount takes 1 unit; Tax and Total each take 2 units.
# Resulting layout: [Amount 20%] [Tax 40%] [Total 40%]
- type: component.section
options:
title: Field row (Flex ratio -Equal 1:2:2)
children:
# Flex 1 - takes up 1/5 of the available row width
# Raw numeric input for the base amount
- type: component.field-row
options:
children:
- type: component.number-field
instanceId: amount
options:
label: Amount
style:
flex: 1
# Flex 2 - takes up 2/5 of the available row width
# Displayed as a percentage (e.g. 0.05 - 5%)
- type: component.number-field
instanceId: tax
options:
label:
text: Tax %
format:
numberStyle: percent
value: 0.05
style:
flex: 2
# Flex 2 - takes up 2/5 of the available row width
# Read-only computed field
# Uses component state to reactively reference sibling field values
- type: component.number-field
instanceId: total
options:
label:
text: Total
format:
numberStyle: currency
currency: USD
value: =@ctx.components.amount.state.value * @ctx.components.tax.state.value
style:
flex: 2