Skip to main content

Input

Struct Input 

Source
pub struct Input { /* private fields */ }
Expand description

Text input field styled like shadcn/ui

§Example

use armas_basic::components::Input;

let mut text = String::new();
let response = Input::new("Email")
    .label("Email address")
    .show(ui, &mut text);

if response.changed {
    // text was modified
}

Implementations§

Source§

impl Input

Source

pub fn new(placeholder: impl Into<String>) -> Self

Create a new input field

Source

pub fn id(self, id: impl Into<Id>) -> Self

Set ID for state persistence

Source

pub const fn variant(self, variant: InputVariant) -> Self

Set the variant (for backwards compatibility)

Source

pub const fn state(self, state: InputState) -> Self

Set the validation state

Source

pub fn label(self, label: impl Into<String>) -> Self

Set a label above the input

Source

pub fn description(self, text: impl Into<String>) -> Self

Set description/helper text below the input

Source

pub fn helper_text(self, text: impl Into<String>) -> Self

Alias for description (backwards compatibility)

Source

pub fn left_icon(self, icon: impl Into<String>) -> Self

Set left icon (emoji or character)

Source

pub fn right_icon(self, icon: impl Into<String>) -> Self

Set right icon (emoji or character)

Source

pub const fn width(self, width: f32) -> Self

Set width

Source

pub const fn height(self, height: f32) -> Self

Set explicit height (overrides variant-based height)

Source

pub const fn password(self, enabled: bool) -> Self

Set as password field

Source

pub const fn disabled(self, disabled: bool) -> Self

Set disabled state

Source

pub const fn font_size(self, _size: f32) -> Self

Backwards compatibility aliases

Source

pub const fn text_color(self, _color: Color32) -> Self

Set text color (currently ignored - uses theme colors)

Source

pub fn show(self, ui: &mut Ui, text: &mut String) -> InputResponse

Show the input field

Trait Implementations§

Source§

impl Default for Input

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Input

§

impl RefUnwindSafe for Input

§

impl Send for Input

§

impl Sync for Input

§

impl Unpin for Input

§

impl UnsafeUnpin for Input

§

impl UnwindSafe for Input

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.