pub struct Input<T: 'static = String> { /* private fields */ }Expand description
Small box to write some text.
§Normal
fn app() -> impl IntoElement {
let value = use_state(String::new);
Input::new(value).placeholder("Type here")
}§Filled
fn app() -> impl IntoElement {
let value = use_state(String::new);
Input::new(value).placeholder("Type here").filled()
}§Flat
fn app() -> impl IntoElement {
let value = use_state(String::new);
Input::new(value).placeholder("Type here").flat()
}§Value types
The value can be of any type implementing InputType, for example numbers.
fn app() -> impl IntoElement {
let value = use_state(|| 50u8);
Input::new(value).placeholder("Age")
}§Preview
Implementations§
Source§impl<T: InputType> Input<T>
impl<T: InputType> Input<T>
pub fn new(value: impl Into<Writable<T>>) -> Self
pub fn enabled(self, enabled: impl Into<bool>) -> Self
pub fn placeholder(self, placeholder: impl Into<Cow<'static, str>>) -> Self
pub fn on_validate( self, on_validate: impl Into<EventHandler<InputValidator>>, ) -> Self
pub fn on_submit(self, on_submit: impl Into<EventHandler<T>>) -> Self
pub fn mode(self, mode: InputMode) -> Self
pub fn auto_focus(self, auto_focus: impl Into<bool>) -> Self
pub fn width(self, width: impl Into<Size>) -> Self
pub fn theme_colors(self, theme: InputColorsThemePartial) -> Self
pub fn theme_layout(self, theme: InputLayoutThemePartial) -> Self
pub fn text_align(self, text_align: impl Into<TextAlign>) -> Self
pub fn style_variant(self, style_variant: impl Into<InputStyleVariant>) -> Self
pub fn layout_variant( self, layout_variant: impl Into<InputLayoutVariant>, ) -> Self
Sourcepub fn filled(self) -> Self
pub fn filled(self) -> Self
Shortcut for Self::style_variant with InputStyleVariant::Filled.
Sourcepub fn flat(self) -> Self
pub fn flat(self) -> Self
Shortcut for Self::style_variant with InputStyleVariant::Flat.
Sourcepub fn compact(self) -> Self
pub fn compact(self) -> Self
Shortcut for Self::layout_variant with InputLayoutVariant::Compact.
Sourcepub fn expanded(self) -> Self
pub fn expanded(self) -> Self
Shortcut for Self::layout_variant with InputLayoutVariant::Expanded.
pub fn a11y_id(self, a11y_id: impl Into<AccessibilityId>) -> Self
Sourcepub fn leading(self, leading: impl Into<Element>) -> Self
pub fn leading(self, leading: impl Into<Element>) -> Self
Optional element rendered before the text input.
Sourcepub fn trailing(self, trailing: impl Into<Element>) -> Self
pub fn trailing(self, trailing: impl Into<Element>) -> Self
Optional element rendered after the text input.
Sourcepub fn on_pre_key_down(
self,
on_pre_key_down: impl Into<Callback<Event<KeyboardEventData>, bool>>,
) -> Self
pub fn on_pre_key_down( self, on_pre_key_down: impl Into<Callback<Event<KeyboardEventData>, bool>>, ) -> Self
Sets a pre-handler called for each key event. Return true to let the input process it,
false to skip. The callback may call stop_propagation() / prevent_default() directly.
Trait Implementations§
Source§impl<T: 'static> CornerRadiusExt for Input<T>
impl<T: 'static> CornerRadiusExt for Input<T>
Source§fn with_corner_radius(self, corner_radius: f32) -> Self
fn with_corner_radius(self, corner_radius: f32) -> Self
Round all four corners to the given radius in pixels.
§fn rounded_none(self) -> Self
fn rounded_none(self) -> Self
Shortcut for
corner_radius(0.) - removes border radius.§fn rounded_sm(self) -> Self
fn rounded_sm(self) -> Self
Shortcut for
corner_radius(4.) - small border radius.§fn rounded_md(self) -> Self
fn rounded_md(self) -> Self
Shortcut for
corner_radius(6.) - medium border radius.§fn rounded_lg(self) -> Self
fn rounded_lg(self) -> Self
Shortcut for
corner_radius(8.) - large border radius.§fn rounded_xl(self) -> Self
fn rounded_xl(self) -> Self
Shortcut for
corner_radius(12.) - extra large border radius.§fn rounded_2xl(self) -> Self
fn rounded_2xl(self) -> Self
Shortcut for
corner_radius(16.) - extra large border radius.§fn rounded_3xl(self) -> Self
fn rounded_3xl(self) -> Self
Shortcut for
corner_radius(24.) - extra large border radius.§fn rounded_4xl(self) -> Self
fn rounded_4xl(self) -> Self
Shortcut for
corner_radius(32.) - extra large border radius.§fn rounded_full(self) -> Self
fn rounded_full(self) -> Self
Shortcut for
corner_radius(99.) - fully rounded (pill shape).Source§impl<T: 'static> InputColorsThemePartialExt for Input<T>
impl<T: 'static> InputColorsThemePartialExt for Input<T>
fn background(self, background: impl Into<Color>) -> Self
fn focus_background(self, focus_background: impl Into<Color>) -> Self
fn border_fill(self, border_fill: impl Into<Color>) -> Self
fn focus_border_fill(self, focus_border_fill: impl Into<Color>) -> Self
fn color(self, color: impl Into<Color>) -> Self
fn placeholder_color(self, placeholder_color: impl Into<Color>) -> Self
Source§impl<T: 'static> InputLayoutThemePartialExt for Input<T>
impl<T: 'static> InputLayoutThemePartialExt for Input<T>
fn corner_radius(self, corner_radius: impl Into<CornerRadius>) -> Self
fn inner_margin(self, inner_margin: impl Into<Gaps>) -> Self
impl<T: 'static> StructuralPartialEq for Input<T>
Auto Trait Implementations§
impl<T> Freeze for Input<T>
impl<T = String> !RefUnwindSafe for Input<T>
impl<T = String> !Send for Input<T>
impl<T = String> !Sync for Input<T>
impl<T> Unpin for Input<T>
impl<T> UnsafeUnpin for Input<T>
impl<T = String> !UnwindSafe for Input<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> ComponentKey for Twhere
T: Component,
impl<T> ComponentKey for Twhere
T: Component,
fn default_key(&self) -> DiffKey
§impl<T> ComponentProps for T
impl<T> ComponentProps for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more