A UI component library for MoonBit web apps — dark & light themes, overlay motion, zero config
Dependencies
howtomakeaname/sumi does not have a README file
pub(all) enum ThemeMode {
Dark
Light
System
}dropdown_menu(
trigger=add_tile(aria_label="Add image"),
items=[...],
open=menu_open,
on_open_change=set_menu_open.map(v => _ => v),
)fn alert(message~ : String, variant? : AlertVariant, icon? : Html, id? : String, class? : String, attrs? : Attrs, style? : Array[String]) -> Htmlattachment_strip(
items=[
AttachmentItem::image("cover.png", label="Cover"),
AttachmentItem::document("Brief.pdf"),
],
on_add=pick_files,
on_remove=set_items.map(i => items => items.filteri(fn(j, _) { j != i })),
)fn[C : IsChildren] button(variant? : ButtonVariant, size? : ButtonSize, disabled? : Bool, pressed? : Bool, loading? : Bool, type_? : String, id? : String, class? : String, title? : String, name? : String, value? : String, autofocus? : Bool, on_click? : Cmd, attrs? : Attrs, style? : Array[String], children : C) -> Htmlfn[C : IsChildren] card(id? : String, class? : String, title? : String, attrs? : Attrs, style? : Array[String], children : C) -> Htmlfn[C : IsChildren] card_section(header~ : Html, id? : String, class? : String, attrs? : Attrs, style? : Array[String], children : C) -> Htmlcheckbox_menu(
groups=[
CheckboxMenuGroup::new(
[
CheckboxMenuItem::new("text", "Text", checked=true),
CheckboxMenuItem::new("date", "Date"),
],
title="Fields",
clear_label="Clear",
on_clear=clear_fields,
),
],
on_toggle=toggle_field.map(v => _ => v),
)chip("720P", selected=quality == "720p", on_click=set_quality.map(v => _ => "720p"))context_menu(
entries=[
Item(MenuItem::new("rename", "Rename", shortcut="R")),
Separator,
Item(MenuItem::new("delete", "Delete", shortcut="⌫")),
],
open=ctx_open,
on_open_change=set_ctx_open.map(v => _ => v),
on_select=set_action.map(v => _ => v),
[canvas_card],
)fn dropdown_menu(items~ : Array[MenuEntry], trigger~ : Html, open~ : Bool, on_open_change? : Emit[Bool], selected? : String, on_select? : Emit[String], align? : MenuAlign, side? : MenuSide, id? : String, class? : String, attrs? : Attrs, style? : Array[String], trigger_style? : Array[String], menu_style? : Array[String]) -> Htmldropdown_menu(
trigger=button(variant=Ghost, [text(model_label), menu_chevron()]),
open=menu_open,
on_open_change=set_menu_open.map(v => _ => v),
items=MenuEntry::items([MenuItem::new("sd", "Sketch Diffusion")]),
selected=model,
on_select=set_model.map(v => _ => v),
)favorite_toggle(
checked=starred,
on_change=set_starred.map(v => _ => v),
)fn icon_button(icon : Html, variant? : ButtonVariant, size? : ButtonSize, disabled? : Bool, pressed? : Bool, id? : String, class? : String, title? : String, aria_label? : String, on_click? : Cmd, attrs? : Attrs, style? : Array[String]) -> Htmlfn input(value~ : String, placeholder? : String, input_type? : InputType, on_input? : Emit[String], on_change? : Emit[String], on_clear? : Cmd, clearable? : Bool, prefix? : Html, suffix? : Html, error? : Bool, error_text? : String, disabled? : Bool, read_only? : Bool, name? : String, maxlength? : Int, autofocus? : Bool, id? : String, class? : String, title? : String, attrs? : Attrs, style? : Array[String]) -> Htmlpopover(
trigger=button(variant=Ghost, [text("16:9 · 2K"), menu_chevron()]),
open=panel_open,
on_open_change=set_panel_open.map(v => _ => v),
[my_panel_content],
)fn prompt_box(value~ : String, placeholder? : String, rows? : Int, on_input? : Emit[String], on_send? : Cmd, send_disabled? : Bool, send_loading? : Bool, disabled? : Bool, maxlength? : Int, show_count? : Bool, autofocus? : Bool, actions? : Html, id? : String, class? : String, attrs? : Attrs, style? : Array[String]) -> Htmlprompt_box(
value=prompt,
placeholder="Describe what to create",
on_input=emit.map(PromptChanged),
on_send=emit(Submit),
send_disabled=prompt.is_empty(),
maxlength=800,
show_count=true,
)select(
options=[@overlays.MenuItem::new("png", "PNG"), @overlays.MenuItem::new("webp", "WebP")],
value=format,
placeholder="Export format",
open=select_open,
on_open_change=set_select_open.map(v => _ => v),
on_select=set_format.map(v => _ => v),
)shortcuts_panel(
title="Shortcuts",
sections=[
ShortcutSection::new(
"General",
[
ShortcutItem::new("Toggle sidebar", "Cmd /"),
ShortcutItem::new("Send message", "Enter"),
],
),
],
on_close=close_panel,
)slider(
value=35,
value_tooltip=true,
on_input=set_strength.map(v => _ => v),
on_commit=emit(CommitStrength),
suffix="°",
)fn slider_field(value~ : Int, min? : Int, max? : Int, step? : Int, label? : String, unit? : String, ticks? : Array[Int], auto? : Bool, auto_label? : String, on_auto_change? : Emit[Bool], on_input? : Emit[Int], on_commit? : Emit[Int], disabled? : Bool, id? : String, class? : String, attrs? : Attrs, style? : Array[String]) -> Htmlslider_field(
value=duration,
min=0, max=180,
label="Total duration",
unit="s",
ticks=[0, 30, 60, 90, 120, 150, 180],
on_input=set_duration.map(v => _ => v),
)fn status_badge(state~ : StatusBadgeState, aria_label? : String, id? : String, class? : String, attrs? : Attrs, style? : Array[String]) -> Htmlstatus_badge(state=Running(45))
status_badge(state=Count(3))
status_badge(state=Complete)
status_badge(state=Warning)tabs(
items=[TabEntry::new("all", "All"), TabEntry::new("mine", "Mine")],
selected=tab,
on_select=set_tab.map(v => _ => v),
)fn[C : IsChildren] tag(variant? : TagVariant, on_remove? : Cmd, id? : String, class? : String, attrs? : Attrs, style? : Array[String], children : C) -> Htmlfn textarea(value~ : String, placeholder? : String, rows? : Int, on_input? : Emit[String], on_change? : Emit[String], disabled? : Bool, read_only? : Bool, name? : String, maxlength? : Int, autofocus? : Bool, id? : String, class? : String, title? : String, attrs? : Attrs, style? : Array[String]) -> Htmlfn[C : IsChildren] theme(mode? : ThemeMode, id? : String, class? : String, title? : String, attrs? : Attrs, style? : Array[String], children : C) -> Htmltheme(mode=Dark, [my_app_content])fn toast(message~ : String, open~ : Bool, variant? : ToastVariant, on_close? : Cmd, id? : String, class? : String, attrs? : Attrs, style? : Array[String]) -> Html// show for 2.4s
@cmd.batch([set_toast(_ => true), @cmd.delay(set_toast(_ => false), 2400)])fn[C : IsChildren] toolbar(id? : String, class? : String, title? : String, attrs? : Attrs, style? : Array[String], children : C) -> Htmlfn[C : IsChildren] tooltip(content~ : String, side? : TooltipSide, id? : String, class? : String, attrs? : Attrs, style? : Array[String], children : C) -> Htmltooltip(content="Upscale to 4K", button(variant=Ghost, "4K"))Install
Download zipA UI component library for MoonBit web apps — dark & light themes, overlay motion, zero config
Dependencies