2023-05-15 01:52:02 +01:00
|
|
|
# Get Started
|
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
|
|
|
```shell
|
|
|
|
cargo add leptos-use
|
|
|
|
```
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
2023-05-27 03:00:08 +01:00
|
|
|
- [Examples Directory](https://github.com/Synphonyte/leptos-use/tree/main/examples)
|
2023-05-15 01:52:02 +01:00
|
|
|
|
|
|
|
## Usage Example
|
|
|
|
|
|
|
|
Simply import the functions you need from `leptos-use`
|
|
|
|
|
|
|
|
```rust,noplayground
|
2023-06-02 13:38:01 +01:00
|
|
|
use leptos::*;
|
|
|
|
use leptos_use::{use_mouse, UseMouseReturn};
|
2023-05-15 01:52:02 +01:00
|
|
|
|
|
|
|
#[component]
|
2023-06-02 13:38:01 +01:00
|
|
|
fn Demo(cx: Scope) -> impl IntoView {
|
2023-05-15 01:52:02 +01:00
|
|
|
let UseMouseReturn { x, y, .. } = use_mouse(cx);
|
|
|
|
|
|
|
|
view! { cx,
|
2023-06-02 13:38:01 +01:00
|
|
|
{x} " x " {y}
|
2023-05-15 01:52:02 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2023-06-24 01:37:15 +01:00
|
|
|
Please refer to the [functions list](functions.md) for more details.
|
|
|
|
|
|
|
|
## Stable Rust
|
|
|
|
|
|
|
|
By default — like `leptos` — the library assumes you're using the
|
|
|
|
nightly Rust toolchain. This allows for more ergonomic use of signals.
|
|
|
|
If you want to use stable Rust, you have to enable the `stable` crate feature.
|
|
|
|
|
|
|
|
```toml
|
|
|
|
leptos-use = { version = "...", features = ["stable"] }
|
|
|
|
```
|