All skills
lassejlv avatar

/build-gpui-apps

@52f4cfd
by Lasselassejlv/skills50 stars
1

Build, scaffold, refactor, debug, review, and validate native Rust desktop applications with GPUI. Recommend GPUI Kit and ask before adopting it; use gpui_kit imports after agreement, or preserve the chosen upstream GPUI stack. Includes the merged GPUI Kit component and design skills, full application/Base/Component/Shell documentation, coding and design guides, state, actions, async, input, accessibility, motion, themes, native integration, packaging, auto updates, testing, and production delivery. Use paper-to-gpui when the primary task is faithfully translating a selected Paper.design frame into an existing view.

Use this Skill: https://skilld.dev/gh/lassejlv/skills/build-gpui-apps

This session only. Nothing lands on disk.

referencesgpui-kitupstreamcomponentrating.md

≈1.2k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Rating

A star rating component that allows users to select a rating value. Supports different sizes, custom colors, disabled state, and click handlers.

Import

use gpui_kit::component::rating::Rating;

Usage

Basic Rating

Rating::new("my-rating")
    .value(3)
    .max(5)
    .on_click(|value, _, _| {
        println!("Rating changed to: {}", value);
    })

Controlled Rating

struct MyView {
    rating: usize,
}

impl Render for MyView {
    fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
        Rating::new("rating")
            .value(self.rating)
            .max(5)
            .on_click(cx.listener(|view, value: &usize, _, cx| {
                view.rating = *value;
                cx.notify();
            }))
    }
}

Different Sizes

The Rating component supports the Sizable trait for different sizes.

Rating::new("rating").xsmall().value(3).max(5)
Rating::new("rating").small().value(3).max(5)
Rating::new("rating").value(3).max(5) // default (Medium)
Rating::new("rating").large().value(3).max(5)

Custom Color

By default, the rating uses the theme's yellow color. You can customize it with the color method.

Rating::new("rating")
    .value(4)
    .max(5)
    .color(cx.theme().green)

Disabled State

Rating::new("rating")
    .value(2)
    .max(5)
    .disabled(true)

Custom Maximum

The default maximum is 5 stars, but you can set a different maximum value.

Rating::new("rating")
    .value(7)
    .max(10)

Click Behavior

The rating component has special click behavior:

  • Clicking on a star that's already filled will reduce the rating by 1
  • Clicking on an unfilled star will set the rating to that star's value

The on_click callback receives the new rating value as &usize.

Rating::new("rating")
    .value(3)
    .max(5)
    .on_click(|new_value, _, _| {
        println!("New rating: {}", new_value);
    })

API Reference

Methods

  • new(id: impl Into<ElementId>) - Create a new Rating component
  • with_size(size: impl Into<Size>) - Set the star size (implements Sizable)
  • value(value: usize) - Set the initial rating value (0..=max)
  • max(max: usize) - Set the maximum number of stars (default: 5)
  • color(color: impl Into<Hsla>) - Set the active color (default: theme yellow)
  • disabled(disabled: bool) - Disable interaction (implements Disableable)
  • on_click(handler: Fn(&usize, &mut Window, &mut App)) - Set click handler

Examples

Read-only Display

Rating::new("rating")
    .value(4)
    .max(5)
    .disabled(true)

Interactive Rating with State

struct ProductView {
    user_rating: usize,
}

impl Render for ProductView {
    fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
        v_flex()
            .gap_3()
            .child(
                Rating::new("product-rating")
                    .value(self.user_rating)
                    .max(5)
                    .on_click(cx.listener(|view, value: &usize, _, cx| {
                        view.user_rating = *value;
                        // Save rating to backend, etc.
                        cx.notify();
                    }))
            )
            .child(format!("Your rating: {}/5", self.user_rating))
    }
}

Large Rating with Custom Color

Rating::new("rating")
    .large()
    .value(5)
    .max(5)
    .color(cx.theme().orange)

Documentation license: original prose and illustrations for which GPUI Kit holds licensing rights are also offered under CC BY 4.0. When copying or adapting, credit GPUI Kit, link the source (https://gpui-kit.com/component/rating) and https://creativecommons.org/licenses/by/4.0/, and indicate changes. Code examples and software source use Apache-2.0; third-party material retains its terms; existing Apache-2.0 permissions remain.

Bundled from GPUI Kit. Documentation prose: CC BY 4.0; code examples: Apache-2.0. Changes: documentation links localized, asset URLs made absolute, and this attribution added.

Source: SKILL.md on GitHub

No alerts3d3 checks · Risk SAFE
  • Gen Agent Trust Hub3d

    The skill provides comprehensive documentation and reference material for building native desktop applications using Rust and GPUI. No security risks, prompt injections, or malicious behaviors were identified. External dependencies originate from reputable organizations in the Rust ecosystem.

  • Socket3d

    No alerts

  • Snyk3d

    Risk: LOW · No issues

Signed by skilld at 52f4cfd. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 4 days ago

README badge

README badge for lassejlv/skills/build-gpui-apps