pub struct ControlProps {Show 16 fields
pub children: Children,
pub class: &'static str,
pub style: &'static str,
pub id: &'static str,
pub input_id: &'static str,
pub disabled: bool,
pub error: bool,
pub focused: bool,
pub full_width: bool,
pub hidden_label: bool,
pub margin: Margin,
pub required: bool,
pub size: Size,
pub variant: Variant,
pub color: Color,
pub data_testid: &'static str,
}lep only.Expand description
Props for the Control component.
A context provider that wraps a single form field with its label and helper text.
Provides ControlContext to FormLabel and Helper
descendants so they reflect error, disabled, required, variant, and color
states automatically.
ยงExamples
use form_rs::leptos::{Control, FormLabel, Helper};
use form_rs::Variant;
use leptos::prelude::*;
#[component]
pub fn EmailField() -> impl IntoView {
view! {
<Control input_id="email" required=true variant=Variant::Outlined>
<FormLabel html_for="email">"Email"</FormLabel>
<Helper>"We'll never share your email."</Helper>
</Control>
}
}ยงRequired Props
ยงOptional Props
- class: [
&'static str]- Additional CSS class names on the wrapper
<div>.
- Additional CSS class names on the wrapper
- style: [
&'static str]- Inline CSS on the wrapper
<div>.
- Inline CSS on the wrapper
- id: [
&'static str]idattribute on the wrapper<div>.
- input_id: [
&'static str]- The
idof the inner<input>element.
- The
- disabled:
bool- When
true, renders all children in a disabled state.
- When
- error:
bool- When
true, renders the label and helper text in the error color.
- When
- focused:
bool- When
true, applies the focused style.
- When
- full_width:
bool- When
true, the component takes up full container width.
- When
- hidden_label:
bool- When
true, the label is hidden.
- When
- margin:
Margin- Vertical spacing adjustment.
- required:
bool- Whether the field is required.
- size:
Size- Size of the component.
- variant:
Variant- Visual style variant.
- color:
Color- Color theme.
- data_testid: [
&'static str]data-testidfor automated testing.
Fieldsยง
ยงchildren: Childrenยงclass: &'static strAdditional CSS class names on the wrapper <div>.
style: &'static strInline CSS on the wrapper <div>.
id: &'static strid attribute on the wrapper <div>.
input_id: &'static strThe id of the inner <input> element.
disabled: boolWhen true, renders all children in a disabled state.
error: boolWhen true, renders the label and helper text in the error color.
focused: boolWhen true, applies the focused style.
full_width: boolWhen true, the component takes up full container width.
When true, the label is hidden.
margin: MarginVertical spacing adjustment.
required: boolWhether the field is required.
size: SizeSize of the component.
variant: VariantVisual style variant.
color: ColorColor theme.
data_testid: &'static strdata-testid for automated testing.
Implementationsยง
Sourceยงimpl ControlProps
impl ControlProps
Sourcepub fn builder() -> ControlPropsBuilder<((), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ())>
pub fn builder() -> ControlPropsBuilder<((), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ())>
Create a builder for building ControlProps.
On the builder, call .children(...), .class(...)(optional), .style(...)(optional), .id(...)(optional), .input_id(...)(optional), .disabled(...)(optional), .error(...)(optional), .focused(...)(optional), .full_width(...)(optional), .hidden_label(...)(optional), .margin(...)(optional), .required(...)(optional), .size(...)(optional), .variant(...)(optional), .color(...)(optional), .data_testid(...)(optional) to set the values of the fields.
Finally, call .build() to create the instance of ControlProps.
Trait Implementationsยง
Auto Trait Implementationsยง
impl !RefUnwindSafe for ControlProps
impl !Sync for ControlProps
impl !UnwindSafe for ControlProps
impl Freeze for ControlProps
impl Send for ControlProps
impl Unpin for ControlProps
impl UnsafeUnpin for ControlProps
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.