pub struct ControlLabelProps {
pub control: AnyView,
pub label: Option<AnyView>,
pub class: &'static str,
pub style: &'static str,
pub id: &'static str,
pub checked: bool,
pub disabled: bool,
pub label_placement: LabelPlacement,
pub required: bool,
pub value: &'static str,
pub data_testid: &'static str,
}lep only.Expand description
Props for the ControlLabel component.
A label wrapper that pairs a control with its descriptive text.
Renders a <label> element containing both the control and its text,
with configurable label placement (start, end, top, bottom).
ยงExamples
use form_rs::leptos::ControlLabel;
use form_rs::LabelPlacement;
use leptos::prelude::*;
#[component]
pub fn TermsCheckbox() -> impl IntoView {
view! {
<ControlLabel
control=view! { <input type="checkbox" /> }.into_any()
label=view! { <span>"I agree to the terms"</span> }.into_any()
/>
}
}ยงRequired Props
- control:
AnyView- The control element.
ยงOptional Props
- label:
AnyView- The label text or content.
- class: [
&'static str]- Additional CSS class names.
- style: [
&'static str]- Inline CSS.
- id: [
&'static str]idattribute.
- checked:
bool- Whether the control appears checked.
- disabled:
bool- When
true, all elements within are visually disabled.
- When
- label_placement:
LabelPlacement- Position of the label text relative to the control.
- required:
bool- Whether the label indicates a required field.
- value: [
&'static str]- The value associated with this labeled control.
- data_testid: [
&'static str]data-testidfor automated testing.
Fieldsยง
ยงcontrol: AnyViewThe control element.
label: Option<AnyView>The label text or content.
class: &'static strAdditional CSS class names.
style: &'static strInline CSS.
id: &'static strid attribute.
checked: boolWhether the control appears checked.
disabled: boolWhen true, all elements within are visually disabled.
label_placement: LabelPlacementPosition of the label text relative to the control.
required: boolWhether the label indicates a required field.
value: &'static strThe value associated with this labeled control.
data_testid: &'static strdata-testid for automated testing.
Implementationsยง
Sourceยงimpl ControlLabelProps
impl ControlLabelProps
Sourcepub fn builder() -> ControlLabelPropsBuilder<((), (), (), (), (), (), (), (), (), (), ())>
pub fn builder() -> ControlLabelPropsBuilder<((), (), (), (), (), (), (), (), (), (), ())>
Create a builder for building ControlLabelProps.
On the builder, call .control(...), .label(...)(optional), .class(...)(optional), .style(...)(optional), .id(...)(optional), .checked(...)(optional), .disabled(...)(optional), .label_placement(...)(optional), .required(...)(optional), .value(...)(optional), .data_testid(...)(optional) to set the values of the fields.
Finally, call .build() to create the instance of ControlLabelProps.
Trait Implementationsยง
Auto Trait Implementationsยง
impl !Sync for ControlLabelProps
impl Freeze for ControlLabelProps
impl RefUnwindSafe for ControlLabelProps
impl Send for ControlLabelProps
impl Unpin for ControlLabelProps
impl UnsafeUnpin for ControlLabelProps
impl UnwindSafe for ControlLabelProps
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.