Home

Awesome

<AnimatedFor /> component for Leptos

FLIP animations for element and component groups inspired by Vue's <TransitionGroup>.

<p align="center"> <img width="400" src="docs/preview.gif"> </p>

This crate exports a component similar to Leptos' built-in <For /> with additional properties for applying specific CSS classes to nodes that:

Each node has to be uniquely keyed, since the original <For />'s logic is used under the hood. Additionally, animations will break for unstable or duplicate keys. You can refer to the official <For /> guide for more detailed information.

Usage

view! {
    <AnimatedFor
        each=items
        key=|item| item.unique_key
        children=|item| view! { /* ... */ }
        enter_from_class="before-enter-animation"
        enter_class="enter-animation"
        move_class="move-animation"
        leave_class="leave-animation"
        appear=true
    />
}

Example usage with TailwindCSS:

view! {
     <AnimatedFor
        each=items
        key=|item| item.id
        children=|item| item.view
        enter_from_class="opacity-0"
        enter_class="duration-800"
        move_class="duration-1200"
        leave_class="opacity-0 duration-500"
        appear=true
    />
}

Check out examples directory for a complete code.

SSR support

It generally should just work. See this example.

Known issues

TODO

License

MIT License

Copyright (c) 2023-PRESENT Kajetan Welc

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.