Skip to content

Instantly share code, notes, and snippets.

View ealmloff's full-sized avatar

Evan Almloff ealmloff

View GitHub Profile
@ealmloff
ealmloff / dxp.rs
Created October 8, 2025 14:05
A user-saved Dioxus Playground snippet.
//! The simplest Dioxus app
use dioxus::prelude::*;
fn main() {
dioxus::launch(App);
}
#[component]
fn App() -> Element {
@ealmloff
ealmloff / dxp.rs
Created October 8, 2025 14:02
A user-saved Dioxus Playground snippet.
//! The simplest Dioxus app
use dioxus::prelude::*;
fn main() {
dioxus::launch(App);
}
#[component]
fn App() -> Element {
@ealmloff
ealmloff / dxp.rs
Created October 8, 2025 13:57
A user-saved Dioxus Playground snippet.
//! The simplest Dioxus app
use dioxus::prelude::*;
fn main() {
dioxus::launch(App);
}
#[component]
fn App() -> Element {
@ealmloff
ealmloff / dxp.rs
Created October 8, 2025 13:56
A user-saved Dioxus Playground snippet.
//! The simplest Dioxus app
use dioxus::prelude::*;
fn main() {
dioxus::launch(App);
}
#[component]
fn App() -> Element {
use dioxus::prelude::*;
use dioxus_primitives::select::{
Select, SelectGroup, SelectGroupLabel, SelectItemIndicator, SelectList, SelectOption,
SelectTrigger, SelectValue,
};
use strum::{EnumCount, IntoEnumIterator};
#[derive(Debug, Clone, Copy, PartialEq, strum::EnumCount, strum::EnumIter, strum::Display)]
enum Fruit {
Apple,
// candle-core = "0.8.4"
use candle_core::Module;
fn main() {
let mut q_data = [[0f32; 256]; 256];
q_data[0][0] = 1.;
q_data[0][1] = 2.;
q_data[0][2] = 3.;
q_data[1][0] = 3.;

Here is an overview of the state management system in dioxus. This doesn't cover all the internals, but it should serve as a pretty good reference:

State

Signal is like a fancy version of RefCell for UIs. Just like RefCell, it checks borrows at runtime. It has a bunch of helper methods to make it easier to use. Calling it like a function will clone the inner value. You can also call a few traits like AddAssign on it directly without writing to it manually.

// create a signal
let signal = use_signal(|| 0);
use criterion::*;
criterion_group!(benches, leptos_ssr_bench, dioxus_ssr_bench);
criterion_main!(benches);
fn leptos_ssr_bench(c: &mut Criterion) {
use leptos::*;
let r = create_runtime();
c.bench_function("leptos ssr", |b| {
b.iter(|| {
use kalosm::language::*;
#[tokio::main]
async fn main() {
let local_source = LlamaSource::new(
FileSource::Local("path/to/llama/model".into()),
FileSource::Local("path/to/llama/tokenizer.json".into()),
)
.with_group_query_attention(
// 1 for llama, 8 for mistral