pub enum FormVariant {
Default,
Inline,
Stacked,
}Expand description
Form component with proper accessibility and validation
The Form component provides accessible form functionality with proper ARIA attributes, validation, error handling, and flexible styling.
§Features
- Proper form semantics and accessibility
- Form validation and error handling
- Field state management
- Multiple variants and layouts
- Event handling (submit, reset, change)
- Integration with form controls
§Example
use leptos::prelude::*;
use radix_leptos_primitives::*;
#[component]
fn MyForm() -> impl IntoView {
let (form_data, set_form_data) = create_signal(FormData::default());
let (errors, set_errors) = create_signal(FormErrors::default());
let handle_submit = move |e: web_sys::Event| {
e.prevent_default();
// Handle form submission
};
view! {
<Form
on_submit=handle_submit
data=form_data
errors=errors
>
<FormField name="email" required=true>
<FormLabel>"Email"</FormLabel>
<FormInput type="email" />
<FormError />
</FormField>
<FormField name="password" required=true>
<FormLabel>"Password"</FormLabel>
<FormInput type="password" />
<FormError />
</FormField>
<FormSubmit>
<Button type="submit">"Submit"</Button>
</FormSubmit>
</Form>
}
}Variants§
Implementations§
Trait Implementations§
Source§impl Clone for FormVariant
impl Clone for FormVariant
Source§fn clone(&self) -> FormVariant
fn clone(&self) -> FormVariant
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FormVariant
impl Debug for FormVariant
Source§impl PartialEq for FormVariant
impl PartialEq for FormVariant
impl Copy for FormVariant
impl StructuralPartialEq for FormVariant
Auto Trait Implementations§
impl Freeze for FormVariant
impl RefUnwindSafe for FormVariant
impl Send for FormVariant
impl Sync for FormVariant
impl Unpin for FormVariant
impl UnwindSafe for FormVariant
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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> SerializableKey for T
impl<T> SerializableKey for T
Source§impl<T> StorageAccess<T> for T
impl<T> StorageAccess<T> for T
Source§fn as_borrowed(&self) -> &T
fn as_borrowed(&self) -> &T
Borrows the value.
Source§fn into_taken(self) -> T
fn into_taken(self) -> T
Takes the value.