pub struct FormProps {Show 17 fields
pub children: Children,
pub class: &'static str,
pub style: &'static str,
pub id: &'static str,
pub action: &'static str,
pub method: Method,
pub enc_type: EncType,
pub target: Target,
pub novalidate: bool,
pub autocomplete: &'static str,
pub name: &'static str,
pub validation_behavior: ValidationBehavior,
pub on_submit: Option<Callback<SubmitEvent>>,
pub on_reset: Option<Callback<Event>>,
pub aria_label: &'static str,
pub aria_labelledby: &'static str,
pub data_testid: &'static str,
}lep only.Expand description
Props for the Form component.
A semantic <form> wrapper that provides validation context to descendant fields.
Propagates FormContext via Leptos context so that Control,
FormLabel, and Helper can read validation mode and submission
state without prop drilling.
ยงAccessibility
- Renders as a native
<form>element (implicit"form"ARIA role). - Supply
aria_labeloraria_labelledbyto create a named form landmark.
ยงExamples
use form_rs::leptos::{Form, Control, FormLabel};
use leptos::prelude::*;
use leptos::ev::SubmitEvent;
#[component]
pub fn LoginForm() -> impl IntoView {
view! {
<Form aria_label="Login" on_submit=Callback::new(|e: SubmitEvent| e.prevent_default())>
<Control input_id="email">
<FormLabel html_for="email">"Email"</FormLabel>
</Control>
</Form>
}
}ยงRequired Props
- children:
Children- Form content: fields, buttons, and other interactive controls.
ยงOptional Props
- class: [
&'static str]- Additional CSS class names on the
<form>element.
- Additional CSS class names on the
- style: [
&'static str]- Inline CSS on the
<form>element.
- Inline CSS on the
- id: [
&'static str]idattribute on the<form>element.
- action: [
&'static str]- URL that processes the form submission.
- method:
Method- HTTP method for form submission.
- enc_type:
EncType- MIME encoding type for submitted data.
- target:
Target- Where to display the form response.
- novalidate:
bool- When
true, disables native browser validation.
- When
- autocomplete: [
&'static str]- Browser autocomplete hint.
- name: [
&'static str]- Name of the form.
- validation_behavior:
ValidationBehavior- Controls whether validation is native or ARIA-based.
- on_submit:
Callback<SubmitEvent>- Handler called when the form is submitted.
- on_reset:
Callback<Event>- Handler called when the form is reset.
- aria_label: [
&'static str]- Accessible label for screen readers.
- aria_labelledby: [
&'static str]- ID of element that labels this form.
- data_testid: [
&'static str]data-testidfor automated testing.
Fieldsยง
ยงchildren: ChildrenForm content: fields, buttons, and other interactive controls.
class: &'static strAdditional CSS class names on the <form> element.
style: &'static strInline CSS on the <form> element.
id: &'static strid attribute on the <form> element.
action: &'static strURL that processes the form submission.
method: MethodHTTP method for form submission.
enc_type: EncTypeMIME encoding type for submitted data.
target: TargetWhere to display the form response.
novalidate: boolWhen true, disables native browser validation.
autocomplete: &'static strBrowser autocomplete hint.
name: &'static strName of the form.
validation_behavior: ValidationBehaviorControls whether validation is native or ARIA-based.
on_submit: Option<Callback<SubmitEvent>>Handler called when the form is submitted.
on_reset: Option<Callback<Event>>Handler called when the form is reset.
aria_label: &'static strAccessible label for screen readers.
aria_labelledby: &'static strID of element that labels this form.
data_testid: &'static strdata-testid for automated testing.
Implementationsยง
Sourceยงimpl FormProps
impl FormProps
Sourcepub fn builder() -> FormPropsBuilder<((), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ())>
pub fn builder() -> FormPropsBuilder<((), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ())>
Create a builder for building FormProps.
On the builder, call .children(...), .class(...)(optional), .style(...)(optional), .id(...)(optional), .action(...)(optional), .method(...)(optional), .enc_type(...)(optional), .target(...)(optional), .novalidate(...)(optional), .autocomplete(...)(optional), .name(...)(optional), .validation_behavior(...)(optional), .on_submit(...)(optional), .on_reset(...)(optional), .aria_label(...)(optional), .aria_labelledby(...)(optional), .data_testid(...)(optional) to set the values of the fields.
Finally, call .build() to create the instance of FormProps.
Trait Implementationsยง
Auto Trait Implementationsยง
impl !RefUnwindSafe for FormProps
impl !Sync for FormProps
impl !UnwindSafe for FormProps
impl Freeze for FormProps
impl Send for FormProps
impl Unpin for FormProps
impl UnsafeUnpin for FormProps
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.