Cross-platform and non-web GUI library for Rust powered by Skia.
# Freya
[Website](https://freyaui.dev) | [Documentation](https://docs.rs/freya/) | [Discord](https://discord.gg/sYejxCdewG) | [Contact](#contact)
**Freya** is a **cross-platform, native, declarative** GUI library for Rust .
### Usage
Latest stable release:
```toml
freya = "0.4"
```
Next release:
```toml
freya = "0.5.0-rc.6"
```
`main` branch:
```toml
freya = { git = "https://github.com/marc2332/freya", branch = "main" }
```
### Trying it out
Make sure to have [Development Setup](https://docs.rs/freya/latest/freya/_docs/development_setup/index.html) ready.
> ⚠️ **This repo uses git submodules**, cloning without `--recurse-submodules` will make the examples fail to compile.
```shell
git clone --recurse-submodules https://github.com/marc2332/freya.git
cd freya
```
> **Already cloned without submodules?** Run `git submodule update --init --recursive` to fetch them.
Then run an example:
```shell
cargo run --example counter
```
> ⚠️ If you happen to be on Windows using `windows-gnu` and get compile errors, maybe go check this [issue](https://github.com/marc2332/freya/issues/794).
### Components & State
Freya’s component model lets you create reusable UI elements that automatically re-render when the state they depend on changes. Components can hold their own internal state or subscribe to shared state, and they produce UI as their output. Any type that implements the `Component` trait can be a component, while the root (`app`) component can simply be a function. Built-in examples include components like `Button` and `Switch`.
### Out of the box components
Freya comes with a set of components out of the box, from simple like `Button`, `Switch`, `Slider` to more complex like `VirtualScrollView`, `Calendar`, `ColorPicker`, etc.
You can check all the examples that start with `component_` in the [examples folder](https://github.com/marc2332/freya/blob/main/examples/).
Example of [`component_input.rs`](https://github.com/marc2332/freya/blob/main/examples/component_input.rs):
### Smooth Animations
Create transitions for colors, sizes, positions, and other visual properties. The animation API gives you full control over timing, easing functions, and animation sequences.
Code
```
…
```
[Portal example](https://github.com/marc2332/freya/blob/main/examples/animation_portal.rs)
[Component Portal](https://github.com/user-attachments/assets/720dd8ec-2a76-4f80-8787-25b3ebb06611)
### Rich Text Editing
Freya provides text editing capabilities that go beyond simple input fields. You can create rich text editors with cursor management, text selection, keyboard shortcuts, custom formatting, virtulization and more.
Code
```
…
```
### Code Editor
Create and control text Code Editors. It is state agnostic so as long as it can be turned into a `Writable` it will work. Uses Rope for text editing and tree-sitter for syntax highlighting. You bring your own tree-sitter grammar and its highlights query, so any language can be supported.
Enable with the `code-editor` feature.
Code
```
…
```
### Markdown
Render Markdown documents with the `MarkdownViewer` component.
Enable with the `markdown` feature.
Code
```rust
fn app() -> impl IntoElement {
MarkdownViewer::new("# Hello World\n\nThis is **bold** and *italic* text.")
}
```
### Routing & Navigation
Define routes, manage navigation state, and transition between different views.
Enable with the `router` feature.
Code
```
…
```
### Global State Management
Freya's `freya-radio` state management system provides efficient global state management through a channels system. Components subscribe to specific "channels" and only receive updates when data is mutated and notified through their channel.
Enable with the `radio` feature.
Code
```
…
```
### Icon Library
Easily integrate icons into your applications, only supports Lucide at the moment.
Code
```rust
use freya::prelude::*;
use freya::icons;
fn app() -> impl IntoElement {
SvgViewer::new(icons::lucide::antenna())
.color((120, 50, 255))
.expanded()
}
```
### Headless Testing
Using `freya-testing` you can test your Freya components in a no-window (headless) environment. You can decide to render the app at any moment to a file though. `freya-testing` is actually used by Freya itself to test all the out of the box components and other APIs.
Code
```
…
```
### Advanced Plotting & Charts
Using the Plotters library, you can create charts, graphs, and data visualizations directly within your application.
Enable with the `ploters` feature.
Code
```
…
```
[Plots](https://github.com/user-attachments/assets/236285ea-a2c2-4739-a59d-029a7c3ef601)
### Internationalization (i18n)
Freya supports internationalization with built-in support for the [Fluent](https://github.com/projectfluent/fluent-rs) localization system. Easily manage translations, pluralization, and locale-specific formatting.
Enable with the `i18n` feature.
Code
```
…
```
### Material Design Components
Freya provides Material Design-inspired style modifiers.
Enable with the `material-design` feature.
Code
```rust
use freya::prelude::*;
use freya::material_design::*;
fn app() -> impl IntoElement {
rect().center().expanded().child(
Button::new()
.on_press(|_| println!("Material button pressed"))
.ripple() // Adds Material Design ripple effect
.child("Material Button"),
)
}
```
### WebView Integration
Integrate web content into your native applications with Freya's WebView support. Embed web applications, or simply display web-based content alongside your native UI components.
Enable with the `webview` feature.
Code
```
…
```
### Terminal Emulation
Freya includes terminal emulation capabilities with full PTY (pseudo-terminal) support. Create integrated terminal applications, SSH clients, or development tools.
Enable with the `terminal-pty` feature.
Code
```
…
```
### Developer Tools
Examine the component tree in real-time.
Enable the `devtools` feature in `freya` and then run the devtools app.
### Contributing ♂️
If you are interested in contributing please make sure to have read the [Contributing](CONTRIBUTING.md) guide first!
### Contact
You may contact me for questions, collaboration or anything that comes to your mind at [
[email protected]](mailto:
[email protected]).
### Support
If you are interested in supporting the development of this project feel free to donate to my [Github Sponsor](https://github.com/sponsors/marc2332/) page.
Thanks to my sponsors for supporting this project!
### Special thanks
- [Jonathan Kelley](https://github.com/jkelleyrtp) and [Evan Almloff](https://github.com/ealmloff) for making [Dioxus](https://dioxuslabs.com/) and all their help, specially when I was still creating Freya.
- [Armin](https://github.com/pragmatrix) for making [rust-skia](https://github.com/rust-skia/rust-skia/) and all his help and making the favor of hosting prebuilt binaries of skia for the combo of features use by Freya.
- [geom3trik](https://github.com/geom3trik) for helping me figure out how to add incremental rendering.
- [Tropical](https://github.com/Tropix126) for this contributions to improving accessibility and rendering.
- [Aiving](https://github.com/Aiving) for having made heavy contributions to [rust-skia](https://github.com/rust-skia/rust-skia/) for better SVG support, and helped optimizing images rendering in Freya.
- [RobertasJ](https://github.com/RobertasJ) for having added nested parenthesis to the `calc()` function and also pushed for improvements in the animation APIs.
- And to the rest of contributors and anybody who gave me any kind of feedback!
- [SparkyTD](https://github.com/SparkyTD) for contributing support for Android.
### History with Dioxus
Freya 0.1, 0.2 and 0.3 were based on the core crates of Dioxus. Starting 0.4 Freya does no longer use Dioxus, instead it uses its own reactive core, partially inspired by Dioxus but yet with lots of differences.
### Claude Code Skill
A Claude Code skill with Freya best practices and patterns is available. Install it with:
```
/plugin marketplace add marc2332/freya
/plugin install freya@freya-marketplace
```
For other AI coding agents, you can use the skill document directly as context: [plugins/freya/skills/freya/SKILL.md](plugins/freya/skills/freya/SKILL.md)
### License
[MIT License](./LICENSE.md)