Struct Input
pub struct Input<T = String>where
T: 'static,{ /* 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§
§impl<T> Input<T>where
T: InputType,
impl<T> Input<T>where
T: InputType,
pub fn new(value: impl Into<Writable<T>>) -> Input<T>
pub fn enabled(self, enabled: impl Into<bool>) -> Input<T>
pub fn placeholder(self, placeholder: impl Into<Cow<'static, str>>) -> Input<T>
pub fn on_validate( self, on_validate: impl Into<EventHandler<InputValidator>>, ) -> Input<T>
pub fn on_submit(self, on_submit: impl Into<EventHandler<T>>) -> Input<T>
pub fn mode(self, mode: InputMode) -> Input<T>
pub fn auto_focus(self, auto_focus: impl Into<bool>) -> Input<T>
pub fn width(self, width: impl Into<Size>) -> Input<T>
pub fn theme_colors(self, theme: InputColorsThemePartial) -> Input<T>
pub fn theme_layout(self, theme: InputLayoutThemePartial) -> Input<T>
pub fn text_align(self, text_align: impl Into<TextAlign>) -> Input<T>
pub fn style_variant( self, style_variant: impl Into<InputStyleVariant>, ) -> Input<T>
pub fn layout_variant( self, layout_variant: impl Into<InputLayoutVariant>, ) -> Input<T>
pub fn filled(self) -> Input<T>
pub fn filled(self) -> Input<T>
Shortcut for Self::style_variant with InputStyleVariant::Filled.
pub fn flat(self) -> Input<T>
pub fn flat(self) -> Input<T>
Shortcut for Self::style_variant with InputStyleVariant::Flat.
pub fn compact(self) -> Input<T>
pub fn compact(self) -> Input<T>
Shortcut for Self::layout_variant with InputLayoutVariant::Compact.
pub fn expanded(self) -> Input<T>
pub fn expanded(self) -> Input<T>
Shortcut for Self::layout_variant with InputLayoutVariant::Expanded.
pub fn a11y_id(self, a11y_id: impl Into<NodeId>) -> Input<T>
pub fn leading(self, leading: impl Into<Element>) -> Input<T>
pub fn leading(self, leading: impl Into<Element>) -> Input<T>
Optional element rendered before the text input.
pub fn trailing(self, trailing: impl Into<Element>) -> Input<T>
pub fn trailing(self, trailing: impl Into<Element>) -> Input<T>
Optional element rendered after the text input.
pub fn on_pre_key_down(
self,
on_pre_key_down: impl Into<Callback<Event<KeyboardEventData>, bool>>,
) -> Input<T>
pub fn on_pre_key_down( self, on_pre_key_down: impl Into<Callback<Event<KeyboardEventData>, bool>>, ) -> Input<T>
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§
§impl<T> Component for Input<T>where
T: InputType,
impl<T> Component for Input<T>where
T: InputType,
fn render(&self) -> impl IntoElement
fn render_key(&self) -> DiffKey
§impl<T> CornerRadiusExt for Input<T>where
T: 'static,
impl<T> CornerRadiusExt for Input<T>where
T: 'static,
§fn with_corner_radius(self, corner_radius: f32) -> Input<T>
fn with_corner_radius(self, corner_radius: f32) -> Input<T>
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).§impl<T> InputColorsThemePartialExt for Input<T>where
T: 'static,
impl<T> InputColorsThemePartialExt for Input<T>where
T: 'static,
fn background(self, background: impl Into<Color>) -> Input<T>
fn focus_background(self, focus_background: impl Into<Color>) -> Input<T>
fn border_fill(self, border_fill: impl Into<Color>) -> Input<T>
fn focus_border_fill(self, focus_border_fill: impl Into<Color>) -> Input<T>
fn color(self, color: impl Into<Color>) -> Input<T>
fn placeholder_color(self, placeholder_color: impl Into<Color>) -> Input<T>
§impl<T> InputLayoutThemePartialExt for Input<T>where
T: 'static,
impl<T> InputLayoutThemePartialExt for Input<T>where
T: 'static,
fn corner_radius(self, corner_radius: impl Into<CornerRadius>) -> Input<T>
fn inner_margin(self, inner_margin: impl Into<Gaps>) -> Input<T>
impl<T> StructuralPartialEq for Input<T>where
T: 'static,
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§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§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