Forms

Input

A text field with a label, placeholder, validation and reactive feedback.

Open ↗
Input interaction recorded with the Blinc headless renderer
Hybrid · dark · native recording · 2×

Usage and properties

Keep SharedTextInputData across rebuilds. The browser host forwards committed text, composition and clipboard events into the Blinc editor. Its hidden textarea is an input bridge; the visible field is rendered by Blinc.

Use the installation guide to add blinc_cn and its component stylesheet. Create the fixture bindings once, and return the demo from your UI builder. Values marked Bound accept Signal/Computed sources where the API supports them; structural options configure the component at construction.

PropertyTypeUpdate modelThis example
dataSharedTextInputDataPersistent editor stateEmpty text
label / placeholderStringBoundYour name / Ada Lovelace
disabledboolBoundfalse
sizeInputSizeStructuralMedium
on_changeFn(&str)CallbackUpdate the greeting Signal

Keyboard and interaction

:hover, :focus, :disabled, :focus-visible and [data-invalid]. Tab focuses the editor; ordinary editing keys, selection and clipboard shortcuts apply.

Customizing it

Add application CSS after the default component layer. These selectors are the restyling surface for this component:

  • .cn-input-group
  • .cn-input
  • .cn-input--sm
  • .cn-input--md
  • .cn-input--lg
  • .cn-label
  • .cn-label-text
  • .blinc-ime-composition

Theme and component variables: --input-bg, --input-bg-hover, --input-bg-focus, --input-bg-disabled, --border, --focus-ring, --text-primary.

Built-in themes

The Live theme control installs Blinc's own theme bundles, including their colours, focus rings, corner shapes and motion tokens.

pub fn theme_bundle_for(name: &str) -> blinc_theme::ThemeBundle {
    match name {
        "restrained" => blinc_theme::RestrainedTheme::bundle(),
        "expressive" => blinc_theme::ExpressiveTheme::bundle(),
        _ => blinc_theme::HybridTheme::bundle(),
    }
    .with_css(blinc_cn::cn_styles::CN_STYLES)
}

Download the default widget and component stylesheets. Sample assets and licenses are available in the asset guide.

Documentation

From the canonical component guide.

Text input field, bound to a SharedTextInputData:

use blinc::cn::prelude::*;
use blinc::layout::widgets::text_input::text_input_data;

let name = text_input_data();

cn::input(&name)
    .label("Name")
    .placeholder("Enter your name...")
    .on_change(|value| println!("name: {value}"))

Input Types

use blinc::layout::widgets::text_input::InputType;

cn::input(&email).input_type(InputType::Email).placeholder("Email")
cn::input(&password).password().placeholder("Password")
cn::input(&age).input_type(InputType::Number).placeholder("Age")
cn::input(&query).input_type(InputType::Search).placeholder("Search...")

Input States

// Disabled
cn::input(&name).disabled(true)

// With an error message; the border turns red, also while hovered or focused
cn::input(&name).error("Name is required")

// Text that follows signals: an empty error clears it
let placeholder = signal("you@example.com".to_string());
let error = signal(String::new());
cn::input(&email)
    .placeholder(placeholder)
    .description("We never share it")
    .error(error)

The placeholder, description and error each take a string or a signal and change in place. While the error is non-empty it shows in place of the description.

Styling

The field is one element with the class cn-input. Its border and fill while hovered, focused, invalid or disabled are rules, eased by a CSS transition: :hover, :focus, [data-invalid] (set while the error is non-empty, and while a value fails validation) and :disabled. Restyle it with rules of your own:

.my-field:focus { border-color: #16a34a; outline-color: #16a34a; }

idle_border_color(..) and idle_bg_color(..) set the idle values as inline style, which the component rules do not replace. The hover_*, focused_*, error_* and grouped colour setters are removed; use rules.

Platforms and version

The component API is available in Blinc 0.6.0. The Live example runs in a dedicated worker and requires a compatible GPU surface. Preview and Code remain available when Live cannot start. The canvas has a descriptive label; a full screen-reader DOM mirror is not provided. The gallery integration is based on revision e2e55c24e078.

Recordings and live demos use the default Hybrid theme with bundled Noto Sans. The recording uses a 560 × 320 logical viewport at twice that resolution. Live follows its container and actual display density. Source base revision · Exact build source · Artifact versions and checksums · Font license.