Interactive form inputs, buttons, and form handling examples
Input(type: "text", name: "username", placeholder: "Enter username")
Input(type: "email", name: "email", placeholder: "user@example.com")
Input(type: "password", name: "password", placeholder: "Enter password")
Input(type: "number", name: "age", placeholder: "Age")
.attribute("min", "0")
.attribute("max", "120")
Dropdown selection with multiple options.
Select(name: "country") {
Option("Choose a country", value: "")
Option("United States", value: "us")
Option("United Kingdom", value: "uk")
Option("Canada", value: "ca")
}
<select name="country">
<option value="">Choose a country</option>
<option value="us">United States</option>
<option value="uk">United Kingdom</option>
<option value="ca">Canada</option>
</select>
Multi-line text input for longer content.
TextArea(name: "message", rows: 4, placeholder: "Enter your message...")
<textarea name="message" rows="4" placeholder="Enter your message..."></textarea>
Different button types with custom styling.
HStack(spacing: 16) {
Button("Submit", type: "submit")
.class("btn btn-primary")
Button("Reset", type: "reset")
.class("btn btn-secondary")
Button("Click Me", type: "button")
.class("btn btn-success")
}
<div class="hstack" style="gap: 16px">
<button type="submit" class="btn btn-primary">Submit</button>
<button type="reset" class="btn btn-secondary">Reset</button>
<button type="button" class="btn btn-success">Click Me</button>
</div>
This form uses @FormValue property wrappers to access submitted data