module
kit
The helpers the components are built from: prop binding (kit::Bind, prop, text, flag), class merging (classes, cls, cx), the part builder and the shared styles. Components copied into a project with weft ui add use them through use weft::ui::kit::*;.
Structs
- AlertStyle
Styling for
Alerttones. - Bar
One bar of a bar chart, in chart coordinates.
- Bind
Fluent scope builder for component setup functions.
- FieldCtx
What a Field shares with the control, label, description and error inside it (context
"field"), so they link up with ARIA. - ShellCtx
Shared by the AppShell parts: whether the sidebar is open on small screens.
Functions
add_months
pub fn add_months(y: i32, m: u32, delta: i32) -> (i32, u32)The month after/before (y, m) by delta months.
alert_style
pub fn alert_style(tone: &str) -> AlertStyleThe classes and icon for an alert of tone (info, success, warning, danger).
arc_midpoint
pub fn arc_midpoint(cx: f32, cy: f32, r: f32, start: f32, end: f32) -> (f32, f32)The point at radius r halfway along an arc from start to end (degrees clockwise from 12 o'clock).
bar_layout
pub fn bar_layout(values: &[(String, f64)], width: f32, height: f32, pad: f32) -> Vec<Bar>Lay out bars inside a width × height box with pad margins.
button_classes
pub fn button_classes(variant: &str, size: &str, full: bool) -> StringClasses for Button variants and sizes.
chart_color
pub fn chart_color(i: usize) -> &'static strThe chart palette's colour for series i (it repeats after the last).
civil_from_days
pub fn civil_from_days(z: i64) -> (i32, u32, u32)Days since 1970-01-01 → (year, month, day) (Howard Hinnant's algorithm).
classes
pub fn classes(p: &Props, own: &str) -> Stringown classes with the caller's class prop winning; with unstyled, only the caller's.
cls
pub fn cls(own: &str, caller: &str) -> StringA part's own classes combined with the caller's class, the caller's winning — over the part's responsive and state variants too (see weft_tailwind::merge_override).
cx
pub fn cx(parts: &[&str]) -> StringJoin non-empty class fragments with single spaces.
Conflicting classes are merged so later ones win (cx(&["px-5 py-2", "p-10"]) → "p-10"), which lets a component's class prop override its own styling.
donut_segments
pub fn donut_segments(values: &[f64], gap_deg: f32) -> Vec<(f32, f32)>Start/end angles (degrees, clockwise from 12 o'clock) for donut slices.
flag
pub fn flag(p: &Props, name: &str, default: bool) -> boolProp name as a flag, or default: a bare attribute or true is true.
format_number
pub fn format_number(n: f64) -> StringThousands separators for large/whole numbers; up to two decimals for small fractional ones.
hover_columns
pub fn hover_columns(points: &[(f32, f32)], left: f32, right: f32) -> Vec<(f32, f32)>Horizontal (start, end) bands, one per point, splitting the space left..right halfway between neighbours — so hovering anywhere picks the nearest point.
line_points
pub fn line_points(values: &[f64], width: f32, height: f32, pad: f32) -> Vec<(f32, f32)>Points of a line chart (minimum at the bottom, including 0).
month_grid
pub fn month_grid(y: i32, m: u32) -> Vec<[Option<u32>; 7]>Weeks of a month (Monday first); None pads days outside it.
pagination_window
pub fn pagination_window(page: usize, pages: usize) -> Vec<Option<usize>>Page numbers to show (1-based) with None for ellipses.
parse_date
pub fn parse_date(s: &str) -> Option<(i32, u32, u32)>"YYYY-MM-DD" → (year, month, day) if valid.
part
pub fn part(name: &str, tag: &str, own: &'static str) -> ComponentA part: one element with default classes and a slot; the caller's class wins and other attributes and handlers are forwarded.
prop
pub fn prop(p: &Props, name: &str) -> Option<Value>Prop lookup that accepts both snake_case and kebab-case names. Only a missing (or null) prop is None: an empty string is a value ("nothing here"), so defaults never replace it.
responsive
pub fn responsive(p: &Props, name: &str, default: &str, to_classes: impl Fn(&str) -> String) -> StringA styling prop's classes, with a value per breakpoint (see crate::styles::responsive_classes).
responsive_classes
pub fn responsive_classes(value: &str, default: &str, to_classes: impl Fn(&str) -> String) -> StringA styling prop's classes, with a value per breakpoint: "vertical md:horizontal" gives to_classes("vertical") plus to_classes("horizontal") under md:. Without a plain value, default applies below the first breakpoint. A prefix starts with a letter, so 16:9 stays one value.
roving_target
pub fn roving_target(key: &str, index: usize, count: usize) -> Option<usize>Arrow/Home/End navigation within a group of count items.
smooth_samples
pub fn smooth_samples(points: &[(f32, f32)], per_segment: usize) -> Vec<(f32, f32)>Sample a Catmull-Rom curve through points (per_segment samples per segment, passing through every point) — used for smooth chart areas.
tip_style
pub fn tip_style(x: f32, y: f32, w: f32, h: f32) -> Stringleft/top (in % of the drawing) for a tooltip anchored at (x, y).