Add FormInput component
All checks were successful
Push Workflows / rustfmt (push) Successful in 5s
Push Workflows / tailwind-build (push) Successful in 4s
Push Workflows / docs (push) Successful in 19s
Push Workflows / clippy (push) Successful in 17s
Push Workflows / test (push) Successful in 25s
Push Workflows / build (push) Successful in 51s
Push Workflows / nix-build (push) Successful in 5m13s
All checks were successful
Push Workflows / rustfmt (push) Successful in 5s
Push Workflows / tailwind-build (push) Successful in 4s
Push Workflows / docs (push) Successful in 19s
Push Workflows / clippy (push) Successful in 17s
Push Workflows / test (push) Successful in 25s
Push Workflows / build (push) Successful in 51s
Push Workflows / nix-build (push) Successful in 5m13s
This commit is contained in:
33
src/components/form_input.rs
Normal file
33
src/components/form_input.rs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
use dioxus::prelude::*;
|
||||||
|
|
||||||
|
/// A simple styled input box
|
||||||
|
#[component]
|
||||||
|
pub fn FormInput(
|
||||||
|
/// The placeholder text and label. When text is entered in the input, the label is shown above
|
||||||
|
/// the input box.
|
||||||
|
label: String,
|
||||||
|
#[props(default)] name: Option<String>,
|
||||||
|
#[props(default)] required: bool,
|
||||||
|
#[props(default)] r#type: String,
|
||||||
|
) -> Element {
|
||||||
|
let name = name.unwrap_or(label.to_lowercase());
|
||||||
|
|
||||||
|
rsx! {
|
||||||
|
div {
|
||||||
|
class: "group",
|
||||||
|
|
||||||
|
label {
|
||||||
|
class: "label opacity-0 not-group-has-placeholder-shown:opacity-100 transition-opacity pl-2",
|
||||||
|
{label.clone()}
|
||||||
|
}
|
||||||
|
|
||||||
|
input {
|
||||||
|
class: "input",
|
||||||
|
name,
|
||||||
|
required,
|
||||||
|
r#type,
|
||||||
|
placeholder: label,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1 +1,2 @@
|
|||||||
pub mod footer;
|
pub mod footer;
|
||||||
|
pub mod form_input;
|
||||||
|
|||||||
Reference in New Issue
Block a user