Repository navigation
Form Components
Use these components to build forms. They include inputs, checkboxes, selects and more.
The input is a text field that is 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}"))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...")// 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
use blinc::prelude::signal;
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 they change in place. While the error is not empty, it shows instead of the description.
cn::input(..).suggestion(..) sets a full value that the field suggests while
the user types. It takes a string, a signal, or a computed. State
describes signals and computeds. With the suggestion maria@example.org, a
field that holds ma shows the rest, ria@example.org, after the caret in a
muted color. The rest is not part of the value, the selection, or the
clipboard.
The rest shows only while all of these are true:
- The field has focus.
- The value is not empty.
- The suggestion starts with the value.
- The caret is at the end of the value.
- Nothing is selected.
A password field and a disabled field never show a suggestion, and an empty
suggestion shows nothing. The match is case-sensitive, so Ma does not match
maria@example.org.
Tab, the right arrow, and End add the rest to the value. One undo removes the
added text, and on_change runs once with the whole new value. Showing the
rest does not run on_change.
The field keeps its value in its own data, not in a signal, so a computed cannot read the value directly. To suggest from a list of known values, such as contacts, do these steps:
- Make a signal for the typed text.
- In
on_change, set the signal to the new value. - Compute the suggestion from the signal, and pass it to
suggestion(..).
This example does all three steps. email is the data of the field, made with
text_input_data() as in the first example on this page:
use blinc::layout::widgets::text_input::text_input_data;
use blinc::prelude::{computed, signal};
let email = text_input_data();
let typed = signal(String::new());
let hint = computed(move |g| {
let text = g.get(typed).unwrap_or_default();
["maria@example.org", "mo@example.org"]
.iter()
.find(|c| !text.is_empty() && c.starts_with(text.as_str()))
.map(|c| c.to_string())
.unwrap_or_default()
});
cn::input(&email)
.placeholder("Email")
.on_change(move |value| typed.set(value.to_string()))
.suggestion(hint)suggestion_keys(..) sets the keys that accept the suggestion. The default
keys are SuggestionKey::Tab, SuggestionKey::Right, and SuggestionKey::End,
and a list that you pass replaces them. While the field shows a suggestion that
Tab accepts, Tab does not move focus. When no suggestion shows, Tab moves focus
to the next field, and Shift+Tab moves it to the previous field.
Enter is not a default key. While a suggestion shows, an Enter that accepts it does not submit the form. Without a suggestion, Enter submits as before. To accept with Enter, list all the keys that you want:
use blinc::layout::widgets::text_input::SuggestionKey;
cn::input(&email)
.suggestion(hint) // the computed from the example above
.suggestion_keys([
SuggestionKey::Tab,
SuggestionKey::Right,
SuggestionKey::End,
SuggestionKey::Enter,
])The rest is a text element in the field with the class
blinc-input-suggestion. Its color is var(--text-tertiary). To change the
color, add a rule to your stylesheet:
.blinc-input-suggestion { color: #6b7280; }The field is one element with the class cn-input. While it is hovered,
focused, invalid or disabled, CSS rules set its border and fill. A CSS
transition makes these changes smooth. The rules use :hover, :focus,
[data-invalid] and :disabled. While the error is not empty, or while a value
fails validation, the field has data-invalid. To restyle the field, write your
own rules:
.my-field:focus { border-color: #16a34a; outline-color: #16a34a; }idle_border_color(..) and idle_bg_color(..) set the idle values as inline
style. The component rules do not replace these values. The hover_*,
focused_*, error_* and grouped color setters are removed. Use rules instead.
The OTP input has separate segments for a one-time code:
use blinc::cn::prelude::*;
let code = ctx.use_signal(String::new());
cn::input_otp(code, 6)
.numeric_only(true)
.on_complete(|code| println!("complete code: {code}"))Tab and Shift+Tab reach each enabled slot, then continue to the controls before or after the OTP input. When you type, the focus still advances automatically. Backspace in an empty slot moves back. When you paste a code, the input spreads it across the slots. Disabled slots are skipped.
cn::input_otp(code, 6)
.numeric_only(true)
.masked(false)
.group_every(3)
.error(has_error) // a bool, Signal or ComputedThe textarea is a text input with multiple lines. It is bound to a
SharedTextAreaState:
use blinc::layout::widgets::text_area::text_area_state;
let description = text_area_state();
cn::textarea(&description)
.label("Description")
.placeholder("Enter description...")
.rows(4)
.on_change(|value| println!("description: {value}")).error("msg") shows the message and turns the border red. .disabled(true)
dims the field. The message under a field has the class .cn-field-error. For
.description(..), the class is .cn-field-description. The rules for these
classes color the message.
The textarea is styled like Input. It is one element with the class
cn-textarea. The :hover, :focus, [data-invalid] and :disabled rules
set its border and fill for each state, and a transition makes the changes
smooth. Its placeholder, description and error follow signals, as they do on an
input.
cn::textarea(..).suggestion(..) offers text for the user to add at the caret.
It takes a string, a signal, or a computed. The text starts where the caret is
when the suggestion is set. For a computed, that is each time its value
changes. This differs from the input, where the suggestion is a
whole value that the typed text must start with.
With the suggestion compute(1) set while the caret is at the end of
let x = , the textarea shows compute(1) after the caret in a muted color. If
the user types co, it shows mpute(1). The muted text is not part of the
text, the selection, or the clipboard.
It shows only while all of these are true:
- The textarea has focus and is not empty.
- The caret is at the end of the line where the suggestion started.
- The text typed since the suggestion started is the start of the suggestion.
- Nothing is selected.
Any other edit, and any move of the caret, hides it. If the user deletes the text that did not match, it shows again.
A suggestion can have several lines. The first line shows after the caret, and the other lines show on rows under it. The text below moves down while they show.
Tab, the right arrow, and End add all of the suggestion at the caret, and
on_change runs once with the whole new text. suggestion_keys(..) takes a
list of SuggestionKey values, as on the input. The type is
blinc::layout::widgets::suggestion::SuggestionKey, and its variants are Tab,
Right, End and Enter. Enter is not a default key. If you list Enter, it
accepts the suggestion instead of starting a new line, but only while a
suggestion shows. While the textarea shows a suggestion that Tab accepts, Tab
does not move focus. With no suggestion, Tab moves focus to the next field.
on_change gives your code the text but not the caret, so compute the
suggestion from the text. This example offers a sign-off after Best,:
use blinc::layout::widgets::text_area::text_area_state;
use blinc::prelude::{computed, signal};
let message = text_area_state();
let typed = signal(String::new());
let sign_off = computed(move |g| {
if g.get(typed).unwrap_or_default().ends_with("Best,") {
"\nAna".to_string()
} else {
String::new()
}
});
cn::textarea(&message)
.rows(5)
.on_change(move |text| typed.set(text.to_string()))
.suggestion(sign_off)After the user types Best,, the textarea shows Ana on a row under the caret.
Tab adds a new line and Ana to the text.
The muted text has the class blinc-input-suggestion, the same class as in the
input. Its color is var(--text-tertiary), and a rule for the class changes it.
The number input shows a number between a − button and a + button. It is bound
to a Signal<f64>:
let qty = ctx.use_signal(1.0);
cn::number_input(qty)
.min(0.0)
.max(99.0)
.step(1.0)
.precision(0)
.size(InputSize::Medium)
.on_change(|value| println!("qty: {value}")).size(..) selects from a size scale that belongs to the number input. This
scale is one step smaller than the scale of a text input, so the control fits in
a row beside other controls. The group stores the size as data-size, and your
rules can select on it:
| Size | data-size |
Row | Steps | Field (at least) | Text |
|---|---|---|---|---|---|
InputSize::Small |
sm |
24px | 24px | 40px | 12px |
InputSize::Medium (default) |
md |
32px | 32px | 48px | 13px |
InputSize::Large |
lg |
40px | 36px | 52px | 14px |
Typing, the Up and Down keys, the buttons and the mouse wheel all keep the value
between min and max. One wheel line is one step, and wheel up increases the
value. Trackpad movement adds up into steps. A disabled input ignores the wheel.
The width of the control depends on the bounds, not on the value. Thus, typing
never changes the width.
The group is one element with a border (.cn-number-input-group). It contains
a field with no border and two step buttons (.cn-number-input-step--dec and
--inc). On :hover and :active, a step button gets a tint. If a step cannot
change the value, its button is disabled, so it is dimmed and does not
respond. Rules with a transition define these looks. To restyle them, write
your own rules.
A checkbox reads and writes the Signal<bool> that you give to it:
let accepted = ctx.use_signal(false);
checkbox(accepted)
.label("Accept terms and conditions")
.on_change(|checked| println!("checked: {checked}"))checkbox(accepted).size(CheckboxSize::Large)
checkbox(accepted).disabled(locked) // a bool, Signal or ComputedThe label also takes a string, Signal or Computed.
While a checkbox is checked, its element has a checked attribute. While it cannot be used, it has
disabled. The .blinc-checkbox rules of the layout stylesheet set its look: the fill, the border,
the hover look, the disabled colors and the fade-in of the check mark. The .cn-checkbox rules set
the checked colors. You can change them with the variables --cn-checkbox-checked-bg,
--cn-checkbox-checked-border and --cn-checkbox-checked-color. To restyle the checkbox, you can
also write your own rules:
@layer components {
.my-checkbox:checked {
background: #16a34a !important;
border-color: #16a34a !important;
}
}
.my-checkbox:hover:not(:disabled):not(:checked) { border-color: #16a34a; }checkbox(accepted).class("my-checkbox")let dark = ctx.use_signal(false);
switch(dark)
.label("Dark mode")
.on_change(|on| println!("dark: {on}"))switch(dark).size(SwitchSize::Small) // Small, Medium, Large
switch(dark).disabled(locked) // a bool, Signal or ComputedThe switch element is the track, and a thumb is inside it. .class() and .id() name the track. While the switch is
on, the track has a checked attribute. The thumb slides by a transform. While
pressed, the thumb shrinks slightly. The .cn-switch rules of CN_STYLES
define all of this for each size (.cn-switch--sm, --md, --lg):
@layer components {
.my-switch:checked {
background: #16a34a !important;
}
.my-switch:checked:hover:not(:disabled) {
background: #15803d !important;
}
}switch(dark).class("my-switch")A group reads and writes a Signal<String> that holds the selected value:
let size = ctx.use_signal("md".to_string());
radio_group(size)
.label("Size")
.option("sm", "Small")
.option("md", "Medium")
.option("lg", "Large")
.on_change(|value| println!("size: {value}"))radio_group(size).horizontal()
radio_group(size).size(RadioSize::Large)
radio_group(size).option_disabled("lg", "Large") // one option
radio_group(size).disabled(locked) // all of them; a bool, Signal or ComputedWhile its option is selected, each ring has a checked attribute. While the option cannot be chosen,
the ring has disabled. The .blinc-radio rules of the layout stylesheet set the look of the ring,
the fade-in of the dot, the hover look and the disabled fill. The .cn-radio and .cn-radio-dot
rules set the colors. You can change them with the variables --cn-radio-border,
--cn-radio-hover-border, --cn-radio-selected and --cn-radio-dot, or with rules:
@layer components {
.my-radio:checked {
border-color: #16a34a !important;
}
.my-radio:checked > .cn-radio-dot {
background: #16a34a !important;
}
}A toggle is a button that stays pressed. Use it, for example, as a formatting toggle in a toolbar or as a filter.
let bold = ctx.use_signal(false);
cn::toggle(bold)
.label("B")
.on_change(|on| println!("bold: {on}"))// An icon, with or without a label
cn::toggle(bold).icon(to_svg(icons::BOLD, 16.0))
// Outline variant: a hairline in both states
cn::toggle(bold).label("B").variant(cn::ToggleVariant::Outline)
// Sizes: Small (32px), Medium (36px), Large (40px)
cn::toggle(bold).label("B").size(cn::ToggleSize::Small)
cn::toggle(bold).label("B").disabled(locked) // a bool, Signal or ComputedA toggle is one element that carries data-state="on" or "off",
data-variant, data-size and disabled. While on, it also has a checked
attribute.
The .blinc-toggle rules of the layout stylesheet define its look. When off,
the toggle is transparent. When on, it has a faint tint of the text color. On
hover, it has a lighter tint. While pressed, it shrinks slightly. A
transition makes all of these changes smooth.
The rules select sizes and variants with attribute selectors, so your own rules can do the same:
@layer components {
#my-toggle[data-state="on"] {
background: #16a34a !important;
color: white !important;
}
}
#my-toggle[data-size="lg"] { min-width: 48px; }cn::toggle(bold).id("my-toggle")A toggle group is a row of toggles in which one value is selected, such as a
text alignment. The group reads and writes a Signal<String>:
let align = ctx.use_signal("left".to_string());
cn::toggle_group(align)
.variant(cn::ToggleVariant::Outline)
.item(cn::toggle_item("left").label("Left"))
.item(cn::toggle_item("center").label("Centre"))
.item(cn::toggle_item("right").label("Right"))
.on_change(|value| println!("align: {value}"))
// Items take an icon too, with or without a label
cn::toggle_item("add").icon(to_svg(icons::PLUS, 16.0)).label("Add")If you click the selected item, it stays selected. To clear the selection, set
the signal to "" yourself. .size(..) and .disabled(..) (a bool, Signal or
Computed) on the group work as on a toggle. toggle_item(..).disabled(true)
does the same for one item.
Each item is a toggle, so the rules above apply to it. The group sets
data-variant and data-size for its items. The rules of the group
(.blinc-toggle-group) give a 4px gap, and .gap(..) overrides this gap.
With a select, you choose a value from a dropdown list. It is bound to a
Signal<String> that holds the selected value:
let fruit = ctx.use_signal(String::new());
cn::select(fruit)
.label("Fruit")
.option("apple", "Apple")
.option("banana", "Banana")
.option_disabled("durian", "Durian")
.placeholder("Select a fruit...")
.size(SelectSize::Medium)
.w(240.0)
.on_change(|value| println!("selected: {value}")).disabled(..) makes the whole select inactive. It takes a bool, Signal or
Computed.
The open list grows to 300px and then scrolls. It opens with the chosen option
in the middle. For a long list, use .virtual_rows(row_height). It builds only
the rows in view, and each row is row_height pixels tall. Thus, a list with
hundreds of options opens immediately:
let year = ctx.use_signal("2026".to_string());
cn::select(year)
.options((1900..=2100).map(|y| SelectOption::new(y.to_string(), y.to_string())))
.virtual_rows(32.0)The trigger is one element with the class cn-select-trigger. While disabled,
it has a disabled attribute. While nothing is chosen, it has
data-placeholder. While its list is open, it has data-state="open".
Thus, rules set its look, and a transition makes the changes smooth. The rules
give a faint tint on :hover and a stronger tint on :active. While the list
is open, they give a darker border. A disabled trigger uses the disabled
palette.
The shown text inherits the color of the trigger, and the placeholder and
disabled rules dim this color. To restyle the trigger, write your own rules:
.cn-select-trigger[data-state="open"] { border-color: #16a34a; }The calendar shows the days of a month, and you pick a date from them. It is
bound to a Signal<Option<CalendarDay>>:
let picked = ctx.use_signal(None::<CalendarDay>);
cn::calendar(picked)
.week_start(1) // Monday first; 0 (Sunday) is the default
.min_year(2020)
.max_year(2030)
.on_change(|day| println!("{}-{}-{}", day.year, day.month, day.day))CalendarDay holds a year, a month from 1 to 12 and a day.
CalendarDay::today() is the local date. add_days, add_months and
weekday do the date arithmetic.
To change the month, use the month and year selects, or the buttons on either side of them. If you drag or swipe with two fingers across the days, the month moves with your movement. If you let go after you move far enough, the month changes (a leftward movement shows the next month). Otherwise, the month springs back. If the pointer moves off the days, the drag or swipe is canceled.
Vertical scrolling still moves the page. If you choose a day of the previous or next month, the calendar changes to that month.
To use the keyboard, Tab to the day grid, or click a day. Then use these keys:
- The arrow keys move by a day or a week.
- Page Up and Page Down move by a month.
- Home and End move to the ends of the week.
- Enter or Space chooses the day that the keys are on.
If you need a compact trigger that opens this calendar in a popover, use Date Picker.
.events(..) marks days with their events, such as meetings, the weather or
deadlines. It takes a list, or a Signal or Computed of a list, and the marks
follow it in place. A day shows up to three marks along its bottom. Each mark is
a dot or, with .icon(..), the icon of the event:
let events = ctx.use_signal(vec![
CalendarEvent::new(CalendarDay::new(2026, 11, 3), "Standup").kind("meeting"),
CalendarEvent::new(CalendarDay::new(2026, 11, 4), "Rain")
.kind("rain")
.icon(to_svg(icons::CLOUD_RAIN, 8.0)),
]);
cn::calendar(picked).events(events)To show the events of a day beside the calendar, get the list with
events_on(&events, day).
The parts are .cn-calendar, -header, -caption and -nav (with
data-step="prev" or "next"). The other parts are -body, -weekdays,
-weekday, -months, -page, -grid and -day.
A day carries data-outside, data-today, data-selected and data-events.
While the keys are on it, it also carries data-focus-visible. Outside the
allowed years, it carries disabled.
When the month changes, two grids move. While the new grid slides in, it
carries data-enter. While the old grid slides out, it carries data-leaving.
Each value is "next" or "prev". The grids slide by the cn-calendar-*
keyframes.
The mark of an event is .cn-calendar-event with its data-kind. If the mark
is an icon, it also has .cn-calendar-event--icon. To color a dot, set its
background. To color an icon, set its color:
.cn-calendar-event[data-kind="rain"] { color: #38bdf8; }
.cn-calendar-event[data-kind="deadline"] { background: var(--error); }
.cn-calendar-day[data-today] { background: transparent; }The combobox is a select that you can search. It is bound to a Signal<String>
that holds the selected value:
use blinc::cn::components::combobox::ComboboxSize;
let framework = ctx.use_signal(String::new());
cn::combobox(framework)
.option("react", "React")
.option("vue", "Vue")
.option_disabled("angular", "Angular")
.placeholder("Select a framework...")
.size(ComboboxSize::Medium)
.w(240.0)
.allow_custom(false)
.on_change(|value| println!("selected: {value}"))The text that you type in the search field of the list filters the options.
cn::combobox_multi is bound to a Signal<Vec<String>>. A click on an option
adds its value to the list. If the list already has the value, the click
removes it. The list stays open, and the search field clears after each click.
The list keeps the values in the order that you chose them:
let people = ctx.use_signal(Vec::<String>::new());
cn::combobox_multi(people)
.option("ada", "Ada")
.option("grace", "Grace")
.option("alan", "Alan")
.placeholder("Assign people...")
.on_change(|value| println!("added or removed: {value}"))The builder is the one of cn::combobox, so the options, the label, the size,
disabled and allow_custom work the same way. on_change gets the value
that was added or removed.
The trigger shows each value as a chip with the class cn-combobox-chip. The
button of a chip has the class cn-combobox-chip-remove, and a click on it
removes the value. If the chips do not fit on one line, the trigger grows and
the list stays below it. Each chosen row of the list has the attribute
data-selected.
The trigger is one element with the class cn-combobox-trigger. While disabled,
it has a disabled attribute. While its list is open, it has
data-state="open".
Thus, rules set its border, and a transition makes the changes smooth. On
:hover, the border is darker. While the list is open, the trigger uses the
focus border. A disabled trigger uses the disabled palette.
The search field is a text input with the class cn-combobox-search. To restyle
the trigger or the search field, write your own rules.
With a slider, you pick a number along a track. It is bound to a Signal<f32>
or Signal<f64>:
let volume = ctx.use_signal(50.0);
cn::slider(volume)
.min(0.0)
.max(100.0)
.step(1.0)
.label("Volume")
.show_value()
.on_change(|value| println!("volume: {value}"))To set the value, click the position that you want on the track, or drag the thumb. The wheel also steps the value. After a click, the arrow keys, Page Up/Down and Home/End move the value too. If you do not set a step, one arrow or wheel step moves one hundredth of the range.
.size(SliderSize::Small) sets the size. .w(px) sets the length of the track.
If you do not set it, the length is 300px. .disabled(..) takes a bool, Signal
or Computed and follows it in place.
The label and live value form one adjustable element in the accessibility snapshot. Assistive adjustment uses the same step, bounds and change callback. Disabled sliders reject it.
The slider is a .cn-slider row of .cn-slider-fill, .cn-slider-thumb and
.cn-slider-rest. If the slider has a label or shows its value, this row is
inside a .cn-slider-field. That field has a .cn-slider-header
(.cn-slider-label, .cn-slider-value).
The rules for these classes set the colors. To recolor one slider, use
--cn-slider-fill-bg, --cn-slider-track-bg and --cn-slider-thumb-bg. Under
the pointer, the thumb grows. While held, it grows more. A disabled slider
carries disabled:
.cn-slider:disabled > .cn-slider-fill { background: var(--border); }If you need two ends on one control, use a Number Range Gauge.
The number gauge shows a number as a fill, with the value written over it:
let opacity = ctx.use_signal(64.0);
cn::number_gauge(opacity)
.range(0.0..=100.0) // the default
.step(1.0) // the default
.size(GaugeSize::Medium) // Small, Medium, Large
.format(|n| format!("{n} %"))
.disabled(locked) // a bool, Signal or Computed
.on_change(|n| println!("opacity: {n}"))To change the value, drag the gauge, click the position that you want, or scroll over it. After a click, the arrow keys, Page Up/Down and Home/End move it too. Values snap to the step.
The gauge is as wide as its longest value needs, so a drag does not change its
width. .w(px) sets a width instead.
This gauge has two ends. One Signal<RangeInclusive<f64>> holds them:
let band = ctx.use_signal(18.0..=24.0);
cn::number_range_gauge(band)
.range(10.0..=30.0)
.step(0.5)
.format(|r| format!("{}–{} °C", r.start(), r.end()))A click or a scroll moves the nearer end. The ends never cross.
Each gauge is a .cn-number-gauge, and the range gauge is also a
.cn-number-range-gauge. Each one holds .cn-number-gauge-fill,
.cn-number-gauge-thumb and .cn-number-gauge-rest. The value is in
.cn-number-gauge-value. In the range gauge, the fill, thumb and rest of each
end are in a .cn-number-gauge-layer with data-endpoint="lower" or "upper".
During a drag, the gauge has data-state="dragging". After a key moves the
gauge, it has data-focus-visible. It can also have disabled. The rules of
CN_STYLES set the colors, the border, the radius for each size
(.cn-number-gauge--sm, --md, --lg) and the cursor:
.my-gauge > .cn-number-gauge-fill { background: color-mix(in srgb, #16a34a 25%, var(--input-bg)); }
.my-gauge > .cn-number-gauge-thumb { color: #16a34a; }cn::number_gauge(opacity).class("my-gauge")Inputs, selects and checkboxes have their own .label(..). The text of a
standalone label is a string, a Signal<String> or a Computed<String>. The
label follows a signal in place:
cn::label("Email").required() // marks the field required
cn::label("Notes").size(LabelSize::Small)
cn::label(status) // a Signal<String>use blinc::core::reactive::computed;
use blinc::layout::widgets::text_input::{InputType, text_input_data};
let name = text_input_data();
let email = text_input_data();
let country = ctx.use_signal(String::new());
let accepted = ctx.use_signal(false);
// Submit stays disabled until the terms are accepted.
let blocked = computed(move |g| !g.get(accepted).unwrap_or(false));
div()
.flex_col()
.gap(6.0) // 6 × 4px
.max_w(400.0)
.child(cn::input(&name).label("Name").placeholder("Ada Lovelace"))
.child(
cn::input(&email)
.label("Email")
.input_type(InputType::Email)
.placeholder("ada@example.com"),
)
.child(
cn::select(country)
.label("Country")
.placeholder("Select a country...")
.option("us", "United States")
.option("uk", "United Kingdom")
.option("ca", "Canada"),
)
.child(cn::checkbox(accepted).label("I accept the terms and conditions"))
.child(cn::button("Submit").disabled(blocked).on_click(|_| submit()))An Email, Number, Integer or Url input tests its own value. The required and min_length
constraints of the input data also test it. While the value is not valid, the input sets
data-invalid, and the .cn-input rules show a red border. To show your own message, write it to a
signal, and show the signal in a label:
let email = text_input_data();
let problem = ctx.use_signal(String::new());
div()
.flex_col()
.gap(1.0)
.child(
cn::input(&email)
.label("Email")
.input_type(InputType::Email)
.on_change(move |value| {
problem.set(if value.is_empty() || value.contains('@') {
String::new()
} else {
"Enter an email address".into()
})
}),
)
.child(cn::label(problem).size(LabelSize::Small))Getting Started
Migrating
Mobile Development
Example Gallery
- Example Gallery
- Canvas Element
- Canvas Kit Interactive
- Carousel Demo - Selector API Showcase
- Chrome-Style Tabs
- blinc_cn Components
- Run with
cargo run -p blinc_app_examples --features cn --example cn_pickers_demo. - 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. - Gpu Pass 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
- Wet Glass
- Windowed Application
Web Development
Core Concepts
- Elements & Layout
- Styling & Materials
- CSS Styling
- Theming
- Event Handling
- Accessibility
- State Management
- Lists & Conditional Content
- Element Refs
Animation
Components
Component Library (blinc_cn)
- Overview
- Button
- Card
- Icons
- Typography
- Dialog
- Form Components
- Date, Time and Colour Pickers
- Rich Text Editor
- Code Editor
- Navigation
- Feedback
- Layout
- Data Display
Widgets
- Buttons & Inputs
- Text & Rich Text
- Code Editor
- Scroll Containers
- Virtualized List
- Canvas Drawing
- Gestures
- Notched Surfaces
- 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 reloading
Architecture
Contributing