Fetching an Element and Toggling an Active class from Rust #1722
Closed
LucasErrNotFound
started this conversation in
General
Replies: 2 comments
-
You can create a hook that stores the current state of the classes and then display that hook into the let classes = use_state(cx, Vec:new);
let all_the_classes = classes.join(" ");
render!{
div {
class: "{all_the_classes}",
onclick: |_| move {
classes.set(vec!["myclasses"]
}
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
I managed to get it to work by applying your answer. Somehow it didn't work at first, but I realized it was in the wrong class scope. Thanks a lot! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Problem
I'm no web developer so forgive me if I said the wrong terminologies. The idea is, when the user clicks the
Sign Up
andSign In
button, the classcontainer
should be in an active state and will execute the followingcss
styles:Apparently, I already saw a solution from a YouTube video to execute the styles but it is written in JavaScript and not Rust:
This is the Rust code (This is just a mock up of the Sign Up section because the original source code is too long):
Expected Behavior
When the
Sign Up
orSign In
button is clicked, it should animate so that the create account section or login section should appear via animations like this:SignUp.mp4
Questionnaires
onclick
, how can I get the element by Id and somehow add aclassList
like from that JavaScript file? (If that is even possible)Beta Was this translation helpful? Give feedback.
All reactions