Components / display
Rating builder
A controlled scalar rating rendered as token-sized stars.
A builder is RenderOnce. Construct and mount it in one expression.
use gpui_kit::display::rating::Rating;
Reviewed in rating.
Construct
new(ident: impl Into<Ident>) -> Self
Options
Chain onto the value.
label(label: impl Into<SharedString>) -> Self
value(value: Option<f32>) -> Self
maximum(maximum: usize) -> Self
precision(precision: RatingPrecision) -> Self
clearable(clearable: bool) -> Self
on_change(handler: impl Fn(Option<f32>, &mut Window, &mut App) + 'static) -> Self
Example · rating
fn rating(_window: &mut Window, cx: &mut App) -> AnyElement {
let theme = cx.theme().clone();
stack(&theme)
.w(px(520.0))
.child(caption(
&theme,
"A numeric rating is distinct from helpful or unhelpful feedback",
))
.child(
Rating::new("scene.rating.precise")
.label("Quality")
.value(Some(3.5))
.precision(RatingPrecision::Half)
.clearable(true)
.on_change(|_, _, _| {}),
)
.child(
Rating::new("scene.rating.unrated")
.label("Not reviewed")
.maximum(10)
.value(None)
.on_change(|_, _, _| {}),
)
.child(
Rating::new("scene.rating.disabled")
.label("Managed score")
.value(Some(4.0))
.disabled(true)
.on_change(|_, _, _| {}),
)
.into_any_element()
}