-
-
Notifications
You must be signed in to change notification settings - Fork 14
Form Components
github-actions[bot] edited this page Jul 8, 2026
·
3 revisions
Components for building forms: inputs, checkboxes, selects, and more.
Text input field:
use blinc_cn::prelude::*;
input()
.placeholder("Enter your name...")
.value(name)
.on_change(|value| set_name(value))// Text (default)
input().placeholder("Name")
// Email
input().input_type("email").placeholder("Email")
// Password
input().input_type("password").placeholder("Password")
// Number
input().input_type("number").placeholder("Age")
// Search
input().input_type("search").placeholder("Search...")// Disabled
input().disabled(true)
// Read-only
input().readonly(true)
// With error
input().error(true)Segmented one-time-code input:
use blinc_cn::prelude::*;
let code = ctx.use_state_keyed("verification_code", || String::new());
cn::input_otp(&code, 6)
.numeric_only(true)
.on_complete(|code| println!("complete code: {code}"))cn::input_otp(&code, 6)
.numeric_only(true)
.masked(false)
.group_every(3)
.error(has_error)Multi-line text input:
textarea()
.placeholder("Enter description...")
.rows(4)
.value(description)
.on_change(|value| set_description(value))checkbox()
.checked(is_checked)
.on_change(|checked| set_checked(checked))
.child(label("Accept terms and conditions"))checkbox()
.checked(some_checked)
.indeterminate(some_checked && !all_checked)
.on_change(|checked| toggle_all(checked))
.child(label("Select all"))Toggle switch:
switch_()
.checked(is_enabled)
.on_change(|enabled| set_enabled(enabled))div()
.flex_row()
.items_center()
.gap(8.0)
.child(switch_().checked(dark_mode).on_change(|v| set_dark_mode(v)))
.child(label("Dark mode"))radio_group()
.value(selected)
.on_change(|value| set_selected(value))
.child(
div().flex_col().gap(8.0)
.child(radio_item("small").child(label("Small")))
.child(radio_item("medium").child(label("Medium")))
.child(radio_item("large").child(label("Large")))
)Dropdown selection:
select()
.value(selected)
.on_change(|value| set_selected(value))
.child(select_trigger()
.child(select_value().placeholder("Select option...")))
.child(select_content()
.child(select_item("opt1").child(text("Option 1")))
.child(select_item("opt2").child(text("Option 2")))
.child(select_item("opt3").child(text("Option 3"))))select()
.child(select_trigger().child(select_value()))
.child(select_content()
.child(select_group()
.child(select_label("Fruits"))
.child(select_item("apple").child(text("Apple")))
.child(select_item("banana").child(text("Banana"))))
.child(select_separator())
.child(select_group()
.child(select_label("Vegetables"))
.child(select_item("carrot").child(text("Carrot")))
.child(select_item("broccoli").child(text("Broccoli")))))Searchable select with autocomplete:
combobox()
.value(selected)
.on_change(|value| set_selected(value))
.child(combobox_trigger()
.child(combobox_input().placeholder("Search...")))
.child(combobox_content()
.child(combobox_empty().child(text("No results found")))
.child(combobox_item("react").child(text("React")))
.child(combobox_item("vue").child(text("Vue")))
.child(combobox_item("svelte").child(text("Svelte"))))Range slider:
slider()
.value(volume)
.min(0.0)
.max(100.0)
.step(1.0)
.on_change(|value| set_volume(value))slider()
.value_range(min_price, max_price)
.min(0.0)
.max(1000.0)
.on_change_range(|min, max| {
set_min_price(min);
set_max_price(max);
})// Associated with input via for
label("Email").for_id("email-input")
// Direct child of input
checkbox()
.child(label("Remember me"))div()
.flex_col()
.gap(24.0)
.max_w(400.0)
// Name field
.child(
div().flex_col().gap(4.0)
.child(label("Name"))
.child(input()
.placeholder("John Doe")
.value(&name)
.on_change(|v| set_name(v)))
)
// Email field
.child(
div().flex_col().gap(4.0)
.child(label("Email"))
.child(input()
.input_type("email")
.placeholder("john@example.com")
.value(&email)
.on_change(|v| set_email(v)))
)
// Country select
.child(
div().flex_col().gap(4.0)
.child(label("Country"))
.child(select()
.value(&country)
.on_change(|v| set_country(v))
.child(select_trigger().child(select_value()))
.child(select_content()
.child(select_item("us").child(text("United States")))
.child(select_item("uk").child(text("United Kingdom")))
.child(select_item("ca").child(text("Canada")))))
)
// Terms checkbox
.child(
checkbox()
.checked(accepted_terms)
.on_change(|v| set_accepted_terms(v))
.child(label("I accept the terms and conditions"))
)
// Submit button
.child(
button("Submit")
.full_width(true)
.disabled(!accepted_terms)
.on_click(|| submit_form())
)let email = use_state_keyed("form_email", || String::new());
let email_error = use_derived(|| {
let value = email.get();
if value.is_empty() {
None
} else if !value.contains('@') {
Some("Invalid email address")
} else {
None
}
});
div().flex_col().gap(4.0)
.child(label("Email"))
.child(input()
.value(&email)
.error(email_error.is_some())
.on_change({
let email = email.clone();
move |v| email.set(v)
}))
.child(
email_error.map(|err|
text(err).size(12.0).color(Color::RED)
)
)Getting Started
Mobile Development
Example Gallery
- Example Gallery
- Canvas Element
- Canvas Kit Interactive
- Carousel Demo - Selector API Showcase
- Chrome-Style Tabs
- blinc_cn Components
- Code Element
- Complex SVG
- CSS Debug
- CSS Visual Features
- Layer Effects
- Emoji and HTML Entities
- @flow Shader
- Fluid Surface
- Skeleton animation with glTF +
blinc_canvas_kit. DrawContext::run_gpu_passend-to-end demo.- Image CSS Styling
- Image Layer Test
- Keyframe Animation Canvas
- Markdown Editor
- 3D Mesh Demo — renders the Khronos glTF
DamagedHelmetsample model - Motion Demo
- Music Player Glass Card
- Node-editor demo — pre-wired graph with three node types, typed
- Notch Menu Bar
- Overflow Fade
- Overlay System
- Pointer Query
- Rich Text Element
- Rich Text Editor
- Scroll Container
- Semantic @flow
- Sortable
- Stateful API + Signal-bound modifiers demo.
- End-to-end 3D demo wiring Blinc's SceneKit3D renderer up to
- Unified Styling API
- SVG Animation
- Table Builder
- Tabler Icons
- Minimal text positioning test
- Text Input Widgets
- KHR_texture_transform
- Theme System
- Timeline Animation
- Typography
- Video Player
- Wet Glass
- Windowed Application
Web Development
Core Concepts
Animation
Components
Component Library (blinc_cn)
Widgets
- Buttons & Inputs
- Text & Rich Text
- Code Editor
- Scroll Containers
- Virtualized List
- Canvas Drawing
- Images & SVG
- Audio & Video
- Markdown Rendering
Canvas Kit
Advanced
- Routing & Navigation
- Multi-Window
- System Integration
- Element Query API
- Overlay System
- Custom State Machines
- Pointer Query
- Performance Tips
- Flow Shaders
- 3D Rendering
- Custom GPU Passes
- Hot-reload (experimental)
Architecture
Contributing