Button's active css styling/animation is not the same with mobile and web #3622
-
dioxus.active.button.movIs there a way to make the button feel like it's being clicked (while it's being hold down). |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 10 replies
-
This is why we need to use dioxus-motion, an animation library for dioxus. (Promotion). Just kidding. Can you drop the button element with css? I can try during my spare time. |
Beta Was this translation helpful? Give feedback.
-
After having a look, Mobile browsers render the :active pseudo-class differently. #[component]
pub fn Button(text: String) -> Element {
rsx! {
button {
class: "
btn btn-outline my-2 mx-8 p-4
bg-violet-500 hover:bg-violet-600
active:bg-violet-700 active:scale-95
touch-active:bg-violet-700 touch-active:scale-95
active:shadow-inner touch-active:shadow-inner
transform transition-all duration-150 ease-in-out
shadow-lg hover:shadow-xl
origin-center rounded-lg
text-white font-semibold
select-none touch-none
",
"{text}"
}
}
} |
Beta Was this translation helpful? Give feedback.
-
Oh, I found what's missing. Thanks to this stack overflow. For some (magical) reason, adding use dioxus::prelude::*;
use daisy_rsx::Button as DaisyButton;
#[component]
pub fn Button(text: String) -> Element {
rsx! {
button {
class: "
btn btn-outline my-2 mx-8 p-4
bg-violet-500 hover:bg-violet-600",
ontouchstart: |_| {},
// focus:outline-none focus:ring focus:ring-violet-300
"{text}"
}
DaisyButton {
"{text}"
}
}
} |
Beta Was this translation helpful? Give feedback.
-
How much of Apple's latest WWDC24 animation / transition demo could be recreated using Dioxus-Motion? |
Beta Was this translation helpful? Give feedback.
Oh, I found what's missing. Thanks to this stack overflow.
For some (magical) reason, adding
ontouchstart
event makes both button recognize the button's active state.