pub struct TextField { /* private fields */ }Expand description
TextField — port of @heroui/text-field (v3).
The composition-friendly field: a label, an Input, and a description or
validation message. Input is the bare control; TextField is the labelled
wrapper most applications reach for.
Implementations§
Source§impl TextField
impl TextField
Sourcepub fn new(state: impl Borrow<Entity<InputState>>) -> Self
pub fn new(state: impl Borrow<Entity<InputState>>) -> Self
Builds the labelled field over state, borrowed or owned — see
Input::new.
Sourcepub fn input_type(self, input_type: InputType) -> Self
pub fn input_type(self, input_type: InputType) -> Self
type — the HTML input type, which v3 sets on the field and this port
forwards to the inner Input.
Sourcepub fn label(self, text: impl Into<SharedString>) -> Self
pub fn label(self, text: impl Into<SharedString>) -> Self
Sets the visible label.
Sourcepub fn content(
self,
render: impl Fn(TextFieldRenderState) -> AnyElement + 'static,
) -> Self
pub fn content( self, render: impl Fn(TextFieldRenderState) -> AnyElement + 'static, ) -> Self
v3’s field children-as-a-function, handed the complete resolved field
state.
Sourcepub fn placeholder(self, text: impl Into<SharedString>) -> Self
pub fn placeholder(self, text: impl Into<SharedString>) -> Self
Sets the placeholder shown while the value is empty.
Sourcepub fn description(self, text: impl Into<SharedString>) -> Self
pub fn description(self, text: impl Into<SharedString>) -> Self
Sets the description text.
Sourcepub fn auto_focus(self, v: bool) -> Self
pub fn auto_focus(self, v: bool) -> Self
autoFocus — see Input::auto_focus.
Sourcepub fn name(self, name: impl Into<SharedString>) -> Self
pub fn name(self, name: impl Into<SharedString>) -> Self
name — see Input::name.
Sourcepub fn default_value(self, text: impl Into<SharedString>) -> Self
pub fn default_value(self, text: impl Into<SharedString>) -> Self
defaultValue — see Input::default_value.
Sourcepub fn value(self, text: impl Into<SharedString>) -> Self
pub fn value(self, text: impl Into<SharedString>) -> Self
value — see Input::value.
Sourcepub fn validation_behavior(self, behavior: ValidationBehavior) -> Self
pub fn validation_behavior(self, behavior: ValidationBehavior) -> Self
validationBehavior — see crate::input::Input::validation_behavior.
Sourcepub fn validate(
self,
f: impl Fn(&str) -> Option<SharedString> + 'static,
) -> Self
pub fn validate( self, f: impl Fn(&str) -> Option<SharedString> + 'static, ) -> Self
validate — see Input::validate.
Sourcepub fn validation_errors(
self,
errors: impl IntoIterator<Item = impl Into<SharedString>>,
) -> Self
pub fn validation_errors( self, errors: impl IntoIterator<Item = impl Into<SharedString>>, ) -> Self
validationErrors — see Input::validation_errors.
Sourcepub fn error_message(self, text: impl Into<SharedString>) -> Self
pub fn error_message(self, text: impl Into<SharedString>) -> Self
Sets the error message shown when the field is invalid.
Sourcepub fn variant(self, variant: FieldVariant) -> Self
pub fn variant(self, variant: FieldVariant) -> Self
Sets the field variant.
Sourcepub fn full_width(self) -> Self
pub fn full_width(self) -> Self
Makes the field fill its parent’s width.
Sourcepub fn height(self, h: impl Into<Pixels>) -> Self
pub fn height(self, h: impl Into<Pixels>) -> Self
The single-line box height — see Input::height.
Sourcepub fn padding_x(self, p: impl Into<Pixels>) -> Self
pub fn padding_x(self, p: impl Into<Pixels>) -> Self
The box’s horizontal padding — see Input::padding_x.
Sourcepub fn recipe(self, name: impl Into<SharedString>) -> Self
pub fn recipe(self, name: impl Into<SharedString>) -> Self
Named theme recipe — see Input::recipe.
Sourcepub fn text_size(self, size: impl Into<Pixels>) -> Self
pub fn text_size(self, size: impl Into<Pixels>) -> Self
The field text size — see Input::text_size.
Sourcepub fn radius(self, r: impl Into<Pixels>) -> Self
pub fn radius(self, r: impl Into<Pixels>) -> Self
The box’s corner radius — see Input::radius.
Sourcepub fn is_bare(self, v: bool) -> Self
pub fn is_bare(self, v: bool) -> Self
Drops the field’s chrome — see Input::is_bare.
Sourcepub fn focus_ring(self, v: bool) -> Self
pub fn focus_ring(self, v: bool) -> Self
Shows or hides only the inner field’s visual focus ring — see
Input::focus_ring.
Sourcepub fn font_family(self, family: impl Into<SharedString>) -> Self
pub fn font_family(self, family: impl Into<SharedString>) -> Self
The field text’s font family — see Input::font_family.
Sourcepub fn start_content(self, el: impl IntoElement) -> Self
pub fn start_content(self, el: impl IntoElement) -> Self
Leading content inside the box — see Input::start_content.
Sourcepub fn is_disabled(self, v: bool) -> Self
pub fn is_disabled(self, v: bool) -> Self
Sets whether the field is disabled.
Sourcepub fn is_read_only(self, v: bool) -> Self
pub fn is_read_only(self, v: bool) -> Self
Sets whether the field is read-only.
Sourcepub fn is_required(self, v: bool) -> Self
pub fn is_required(self, v: bool) -> Self
Sets whether the field is required.
Sourcepub fn is_invalid(self, v: bool) -> Self
pub fn is_invalid(self, v: bool) -> Self
Sets whether the field is invalid.
Sourcepub fn on_change(
self,
handler: impl Fn(&str, &mut Window, &mut App) + 'static,
) -> Self
pub fn on_change( self, handler: impl Fn(&str, &mut Window, &mut App) + 'static, ) -> Self
Sets the handler called with the new value whenever it changes.
Sourcepub fn on_submit(
self,
handler: impl Fn(&str, &mut Window, &mut App) + 'static,
) -> Self
pub fn on_submit( self, handler: impl Fn(&str, &mut Window, &mut App) + 'static, ) -> Self
Sets the handler called with the current value when Enter is pressed.
Sourcepub fn sx(self, style: impl FnOnce(Div) -> Div) -> Self
pub fn sx(self, style: impl FnOnce(Div) -> Div) -> Self
The one slot for caller-owned low-level styling: GPUI’s styling methods
(bg, text_color, w, h, p, rounded, border_color, …)
applied to the field’s root element after every value the variant and
the active theme chose, so they win. The wrapper renders no element of
its own, so the slot rides the inner Input and lands on that root.
Trait Implementations§
Source§impl Disableable for TextField
impl Disableable for TextField
Source§fn is_disabled(self, disabled: bool) -> Self
fn is_disabled(self, disabled: bool) -> Self
isDisabled — whether the component is disabled.Source§impl IntoElement for TextField
impl IntoElement for TextField
Source§type Element = ViewElement<TextField>
type Element = ViewElement<TextField>
Source§fn into_element(self) -> Self::Element
fn into_element(self) -> Self::Element
Element.Source§fn into_any_element(self) -> AnyElement
fn into_any_element(self) -> AnyElement
AnyElement.Source§impl RenderOnce for TextField
impl RenderOnce for TextField
Source§fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement
fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement
Render::render() method
which takes a mutable reference.Auto Trait Implementations§
impl !RefUnwindSafe for TextField
impl !Send for TextField
impl !Sync for TextField
impl !UnwindSafe for TextField
impl Freeze for TextField
impl Unpin for TextField
impl UnsafeUnpin for TextField
Blanket Implementations§
Source§impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
Source§fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
Source§fn with_animations(
self,
id: impl Into<ElementId>,
animations: Vec<Animation>,
animator: impl Fn(Self, usize, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animations(
self,
id: impl Into<ElementId>,
animations: Vec<Animation>,
animator: impl Fn(Self, usize, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
Source§fn with_spring<T>(
self,
id: impl Into<ElementId>,
animation: SpringAnimation<T>,
animator: impl FnOnce(Self, <T as SpringTarget>::Output) -> Self + 'static,
) -> SpringAnimationElement<Self>
fn with_spring<T>( self, id: impl Into<ElementId>, animation: SpringAnimation<T>, animator: impl FnOnce(Self, <T as SpringTarget>::Output) -> Self + 'static, ) -> SpringAnimationElement<Self>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> FluentBuilder for Twhere
T: IntoElement,
impl<T> FluentBuilder for Twhere
T: IntoElement,
Source§fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
Source§fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
Source§fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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> ⓘ
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> ⓘ
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