pub struct FieldProps {Show 22 fields
pub id: &'static str,
pub name: &'static str,
pub type: &'static str,
pub label: &'static str,
pub placeholder: &'static str,
pub helper_text: &'static str,
pub validation_state: ValidationState,
pub required: bool,
pub disabled: bool,
pub full_width: bool,
pub variant: Variant,
pub color: Color,
pub size: Size,
pub pattern: &'static str,
pub maxlength: Option<usize>,
pub minlength: Option<usize>,
pub class: &'static str,
pub style: &'static str,
pub handle: RwSignal<String>,
pub valid_handle: RwSignal<bool>,
pub validate_function: fn(String) -> bool,
pub data_testid: &'static str,
}lep only.Expand description
Props for the Field component.
A convenience composition of Control, FormLabel, Input, and
Helper into a single validated form field for Leptos.
Uses input-rs for the underlying <input> element with HTML5 validation.
ยงExamples
use form_rs::leptos::Field;
use leptos::prelude::*;
#[component]
pub fn EmailInput() -> impl IntoView {
let handle = RwSignal::new(String::new());
let valid = RwSignal::new(true);
view! {
<Field
id="email"
name="email"
r#type="email"
label="Email address"
placeholder="ferris@opensass.org"
required=true
handle=handle
valid_handle=valid
validate_function=|v: String| !v.is_empty() && v.contains('@')
/>
}
}ยงRequired Props
- id: [
&'static str]- The unique
idfor the<input>element.
- The unique
- handle:
RwSignal<String>- Controlled value signal.
- valid_handle:
RwSignal<bool>- Validity signal.
- validate_function: [
fn(String) -> bool]- Validation function.
ยงOptional Props
- name: [
&'static str]- The
nameattribute for the<input>.
- The
- r#type: [
&'static str]- The input type.
- label: [
&'static str]- Label text displayed above the input.
- placeholder: [
&'static str]- Placeholder text.
- helper_text: [
&'static str]- Helper text below the input.
- validation_state:
ValidationState- Validation state.
- required:
bool- Whether the field is required.
- disabled:
bool- Whether the field is disabled.
- full_width:
bool- Whether the field takes the full container width.
- variant:
Variant- Visual variant.
- color:
Color- Color theme.
- size:
Size- Size.
- pattern: [
&'static str]- HTML5
patternfor native regex validation.
- HTML5
- maxlength:
usize- Max character count.
- minlength:
usize- Min character count.
- class: [
&'static str]- Outer
<div>CSS class.
- Outer
- style: [
&'static str]- Outer
<div>inline CSS.
- Outer
- data_testid: [
&'static str]data-testidfor automated testing.
Fieldsยง
ยงid: &'static strThe unique id for the <input> element.
name: &'static strThe name attribute for the <input>.
type: &'static strThe input type.
label: &'static strLabel text displayed above the input.
placeholder: &'static strPlaceholder text.
helper_text: &'static strHelper text below the input.
validation_state: ValidationStateValidation state.
required: boolWhether the field is required.
disabled: boolWhether the field is disabled.
full_width: boolWhether the field takes the full container width.
variant: VariantVisual variant.
color: ColorColor theme.
size: SizeSize.
pattern: &'static strHTML5 pattern for native regex validation.
maxlength: Option<usize>Max character count.
minlength: Option<usize>Min character count.
class: &'static strOuter <div> CSS class.
style: &'static strOuter <div> inline CSS.
handle: RwSignal<String>Controlled value signal.
valid_handle: RwSignal<bool>Validity signal.
validate_function: fn(String) -> boolValidation function.
data_testid: &'static strdata-testid for automated testing.
Implementationsยง
Sourceยงimpl FieldProps
impl FieldProps
Sourcepub fn builder() -> FieldPropsBuilder<((), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ())>
pub fn builder() -> FieldPropsBuilder<((), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ())>
Create a builder for building FieldProps.
On the builder, call .id(...), .name(...)(optional), .r#type(...)(optional), .label(...)(optional), .placeholder(...)(optional), .helper_text(...)(optional), .validation_state(...)(optional), .required(...)(optional), .disabled(...)(optional), .full_width(...)(optional), .variant(...)(optional), .color(...)(optional), .size(...)(optional), .pattern(...)(optional), .maxlength(...)(optional), .minlength(...)(optional), .class(...)(optional), .style(...)(optional), .handle(...), .valid_handle(...), .validate_function(...), .data_testid(...)(optional) to set the values of the fields.
Finally, call .build() to create the instance of FieldProps.
Trait Implementationsยง
Auto Trait Implementationsยง
impl Freeze for FieldProps
impl RefUnwindSafe for FieldProps
impl Send for FieldProps
impl Sync for FieldProps
impl Unpin for FieldProps
impl UnsafeUnpin for FieldProps
impl UnwindSafe for FieldProps
Blanket Implementationsยง
impl<Token, Builder, How> AllPropsFor<Builder, How> for Tokenwhere
Builder: Buildable<Token>,
<Builder as Buildable<Token>>::WrappedToken: HasAllProps<<Builder as Buildable<Token>>::Output, How>,
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> HasAllProps<(), T> for T
Sourceยงimpl<T> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
Sourceยงfn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
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 moreSourceยงimpl<T> IntoPropValue<Option<T>> for T
impl<T> IntoPropValue<Option<T>> for T
Sourceยงfn into_prop_value(self) -> Option<T>
fn into_prop_value(self) -> Option<T>
self to a value of a Properties struct.Sourceยงimpl<T> IntoPropValue<T> for T
impl<T> IntoPropValue<T> for T
Sourceยงfn into_prop_value(self) -> T
fn into_prop_value(self) -> T
self to a value of a Properties struct.