Code Monkey home page Code Monkey logo

floem's Introduction

Floem

A native Rust UI library with fine-grained reactivity

crates.io docs.rs Discord

The project is still maturing. We will make occasional breaking changes and add missing features on our way to v1.

Quickstart

Quickstart

use floem::reactive::create_signal;
use floem::view::View;
use floem::views::{h_stack, label, v_stack, Decorators};
use floem::widgets::button;

fn app_view() -> impl View {
    // Create a reactive signal with a counter value, defaulting to 0
    let (counter, set_counter) = create_signal(0);

    // Create a vertical layout
    v_stack((
        // The counter value updates automatically, thanks to reactivity
        label(move || format!("Value: {}", counter.get())),
        // Create a horizontal layout
        h_stack((
            button(|| "Increment").on_click_stop(move |_| {
                set_counter.update(|value| *value += 1);
            }),
            button(|| "Decrement").on_click_stop(move |_| {
                set_counter.update(|value| *value -= 1);
            }),
        )),
    ))
}

fn main() {
    floem::launch(app_view);
}

Features

Inspired by Xilem, Leptos and rui, Floem aims to be a high performance declarative UI library requiring minimal user effort.

  • Cross-platform support: Supports Windows, macOS and Linux with rendering using Wgpu. In case a GPU is unavailable, a CPU renderer powered by tiny-skia will be used.
  • Fine-grained reactivity: The entire library is built around reactive primitives inspired by leptos_reactive. The reactive "signals" allow you to keep your UI up-to-date with minimal effort, all while maintaining very high performance.
  • Performance: The view tree is only run once, safeguarding you from accidentally create a bottleneck in a view generation function that slows down your entire application. Floem also provides tools to help you write efficient UI code, such as a virtual list.
  • Flexbox layout: Using taffy, the library provides the Flexbox (or Grid) layout system, which can be applied to any View node.
  • Customizable widgets: Don't want the default look? You can change pretty much anything you want using the styling API, or install a third-party theme.
  • Element inspector: Inspired by your browser's developer tools, Floem provides a diagnostic tool to debug your layout.

To sample Floem's capabilities, check out the repo and run the widget gallery example with cargo.

Widget gallery

To help you master Floem, we provide documentation and code examples.

Contributions

Contributions welcome! If you'd like to improve how Floem works and fix things, feel free to open an issue or submit a PR. If you'd like a conversation with Floem devs, you can join in the #floem channel on this Discord.

floem's People

Contributors

dzhou121 avatar zoxc avatar jrmoulton avatar presiyan-ivanov avatar pieterdd avatar dominikwilkowski avatar matthewgapp avatar minusgix avatar waywardmonkeys avatar panekj avatar tk103331 avatar 0hypercube avatar wcubed avatar thewizzy avatar maun avatar sudormrfbin avatar andystopia avatar domesticmouse avatar cupnfish avatar djmcnab avatar jaredmoulton avatar keshi avatar kakoc avatar lukaslihotzki avatar nicoburns avatar golota60 avatar victorcrimea avatar czadowanie avatar imbev avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.