Current section

Files

Jump to
glaze_basecoat src glaze@basecoat@button.erl
Raw

src/glaze@basecoat@button.erl

-module(glaze@basecoat@button).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/glaze/basecoat/button.gleam").
-export([group/2, button/2, secondary/2, destructive/2, outline/2, ghost/2, link_style/2, icon/2, icon_outline/2, icon_destructive/2, link/2, link_secondary/2, link_outline/2, link_ghost/2, link_destructive/2, small/0, large/0, secondary_sm/2, destructive_sm/2, outline_sm/2, ghost_sm/2, link_style_sm/2, secondary_lg/2, destructive_lg/2, outline_lg/2, ghost_lg/2, link_style_lg/2, link_sm/2, link_secondary_sm/2, link_outline_sm/2, link_ghost_sm/2, link_destructive_sm/2, link_lg/2, link_secondary_lg/2, link_outline_lg/2, link_ghost_lg/2, link_destructive_lg/2, full_width/0, disabled/0, loading/0, submit/2, reset/2]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(
" Basecoat documentation: <https://basecoatui.com/components/button/>\n"
"\n"
" The [`button`](#button) helpers style interactive actions and links with a\n"
" consistent API.\n"
"\n"
" Use regular buttons for in-page actions, and use [`link`](#link) when the\n"
" interaction navigates to a different location.\n"
"\n"
" ## Anatomy\n"
"\n"
" A button setup usually has one interactive element and optional button groups.\n"
" `group` wraps multiple actions in a semantic menu/list structure so spacing\n"
" and alignment stay consistent.\n"
"\n"
" ## Recipes\n"
"\n"
" ### A primary action button\n"
"\n"
" ```gleam\n"
" import glaze/basecoat/button\n"
" import lustre/element/html\n"
"\n"
" fn save_button() {\n"
" button.button([], [html.text(\"Save\")])\n"
" }\n"
" ```\n"
"\n"
" ### A grouped action row\n"
"\n"
" ```gleam\n"
" import glaze/basecoat/button\n"
" import lustre/element/html\n"
"\n"
" fn actions() {\n"
" button.group([], [\n"
" button.button([button.outline()], [html.text(\"Cancel\")]),\n"
" button.button([], [html.text(\"Continue\")]),\n"
" ])\n"
" }\n"
" ```\n"
"\n"
" ### A link styled as button\n"
"\n"
" ```gleam\n"
" import glaze/basecoat/button\n"
" import lustre/attribute\n"
" import lustre/element/html\n"
"\n"
" fn docs_link() {\n"
" button.link([attribute.href(\"/docs\"), button.outline()], [\n"
" html.text(\"Read docs\"),\n"
" ])\n"
" }\n"
" ```\n"
"\n"
" ## Variants\n"
"\n"
" - [`primary`](#primary) - Primary button (default `btn`)\n"
" - [`secondary`](#secondary) - Secondary button\n"
" - [`destructive`](#destructive) - Destructive/danger button\n"
" - [`outline`](#outline) - Outline button\n"
" - [`ghost`](#ghost) - Ghost button\n"
" - [`link`](#link) - Link-styled button\n"
"\n"
" ## Sizes\n"
"\n"
" Size can be set via the [`small`](#small) or [`large`](#large) attribute\n"
" helpers when using a primary button. For other variants, pass the size to\n"
" the variant function directly (e.g., `outline_sm`, `destructive_lg`) to\n"
" produce the correct compound CSS class (e.g., `btn-sm-outline`).\n"
"\n"
).
-file("src/glaze/basecoat/button.gleam", 77).
-spec group(
list(lustre@vdom@vattr:attribute(PQD)),
list(lustre@vdom@vnode:element(PQD))
) -> lustre@vdom@vnode:element(PQD).
group(Attrs, Children) ->
lustre@element@html:'div'(
[lustre@attribute:class(<<"flex items-center gap-2"/utf8>>) | Attrs],
Children
).
-file("src/glaze/basecoat/button.gleam", 84).
-spec button(
list(lustre@vdom@vattr:attribute(PQJ)),
list(lustre@vdom@vnode:element(PQJ))
) -> lustre@vdom@vnode:element(PQJ).
button(Attrs, Children) ->
lustre@element@html:button(
[lustre@attribute:class(<<"btn"/utf8>>),
lustre@attribute:type_(<<"button"/utf8>>) |
Attrs],
Children
).
-file("src/glaze/basecoat/button.gleam", 94).
-spec secondary(
list(lustre@vdom@vattr:attribute(PQP)),
list(lustre@vdom@vnode:element(PQP))
) -> lustre@vdom@vnode:element(PQP).
secondary(Attrs, Children) ->
lustre@element@html:button(
[lustre@attribute:class(<<"btn-secondary"/utf8>>),
lustre@attribute:type_(<<"button"/utf8>>) |
Attrs],
Children
).
-file("src/glaze/basecoat/button.gleam", 104).
-spec destructive(
list(lustre@vdom@vattr:attribute(PQV)),
list(lustre@vdom@vnode:element(PQV))
) -> lustre@vdom@vnode:element(PQV).
destructive(Attrs, Children) ->
lustre@element@html:button(
[lustre@attribute:class(<<"btn-destructive"/utf8>>),
lustre@attribute:type_(<<"button"/utf8>>) |
Attrs],
Children
).
-file("src/glaze/basecoat/button.gleam", 114).
-spec outline(
list(lustre@vdom@vattr:attribute(PRB)),
list(lustre@vdom@vnode:element(PRB))
) -> lustre@vdom@vnode:element(PRB).
outline(Attrs, Children) ->
lustre@element@html:button(
[lustre@attribute:class(<<"btn-outline"/utf8>>),
lustre@attribute:type_(<<"button"/utf8>>) |
Attrs],
Children
).
-file("src/glaze/basecoat/button.gleam", 124).
-spec ghost(
list(lustre@vdom@vattr:attribute(PRH)),
list(lustre@vdom@vnode:element(PRH))
) -> lustre@vdom@vnode:element(PRH).
ghost(Attrs, Children) ->
lustre@element@html:button(
[lustre@attribute:class(<<"btn-ghost"/utf8>>),
lustre@attribute:type_(<<"button"/utf8>>) |
Attrs],
Children
).
-file("src/glaze/basecoat/button.gleam", 134).
-spec link_style(
list(lustre@vdom@vattr:attribute(PRN)),
list(lustre@vdom@vnode:element(PRN))
) -> lustre@vdom@vnode:element(PRN).
link_style(Attrs, Children) ->
lustre@element@html:button(
[lustre@attribute:class(<<"btn-link"/utf8>>),
lustre@attribute:type_(<<"button"/utf8>>) |
Attrs],
Children
).
-file("src/glaze/basecoat/button.gleam", 144).
-spec icon(
list(lustre@vdom@vattr:attribute(PRT)),
list(lustre@vdom@vnode:element(PRT))
) -> lustre@vdom@vnode:element(PRT).
icon(Attrs, Children) ->
lustre@element@html:button(
[lustre@attribute:class(<<"btn-icon"/utf8>>),
lustre@attribute:type_(<<"button"/utf8>>) |
Attrs],
Children
).
-file("src/glaze/basecoat/button.gleam", 154).
-spec icon_outline(
list(lustre@vdom@vattr:attribute(PRZ)),
list(lustre@vdom@vnode:element(PRZ))
) -> lustre@vdom@vnode:element(PRZ).
icon_outline(Attrs, Children) ->
lustre@element@html:button(
[lustre@attribute:class(<<"btn-icon-outline"/utf8>>),
lustre@attribute:type_(<<"button"/utf8>>) |
Attrs],
Children
).
-file("src/glaze/basecoat/button.gleam", 164).
-spec icon_destructive(
list(lustre@vdom@vattr:attribute(PSF)),
list(lustre@vdom@vnode:element(PSF))
) -> lustre@vdom@vnode:element(PSF).
icon_destructive(Attrs, Children) ->
lustre@element@html:button(
[lustre@attribute:class(<<"btn-icon-destructive"/utf8>>),
lustre@attribute:type_(<<"button"/utf8>>) |
Attrs],
Children
).
-file("src/glaze/basecoat/button.gleam", 178).
-spec link(
list(lustre@vdom@vattr:attribute(PSL)),
list(lustre@vdom@vnode:element(PSL))
) -> lustre@vdom@vnode:element(PSL).
link(Attrs, Children) ->
lustre@element@html:a(
[lustre@attribute:class(<<"btn"/utf8>>) | Attrs],
Children
).
-file("src/glaze/basecoat/button.gleam", 185).
-spec link_secondary(
list(lustre@vdom@vattr:attribute(PSR)),
list(lustre@vdom@vnode:element(PSR))
) -> lustre@vdom@vnode:element(PSR).
link_secondary(Attrs, Children) ->
lustre@element@html:a(
[lustre@attribute:class(<<"btn-secondary"/utf8>>) | Attrs],
Children
).
-file("src/glaze/basecoat/button.gleam", 192).
-spec link_outline(
list(lustre@vdom@vattr:attribute(PSX)),
list(lustre@vdom@vnode:element(PSX))
) -> lustre@vdom@vnode:element(PSX).
link_outline(Attrs, Children) ->
lustre@element@html:a(
[lustre@attribute:class(<<"btn-outline"/utf8>>) | Attrs],
Children
).
-file("src/glaze/basecoat/button.gleam", 199).
-spec link_ghost(
list(lustre@vdom@vattr:attribute(PTD)),
list(lustre@vdom@vnode:element(PTD))
) -> lustre@vdom@vnode:element(PTD).
link_ghost(Attrs, Children) ->
lustre@element@html:a(
[lustre@attribute:class(<<"btn-ghost"/utf8>>) | Attrs],
Children
).
-file("src/glaze/basecoat/button.gleam", 206).
-spec link_destructive(
list(lustre@vdom@vattr:attribute(PTJ)),
list(lustre@vdom@vnode:element(PTJ))
) -> lustre@vdom@vnode:element(PTJ).
link_destructive(Attrs, Children) ->
lustre@element@html:a(
[lustre@attribute:class(<<"btn-destructive"/utf8>>) | Attrs],
Children
).
-file("src/glaze/basecoat/button.gleam", 213).
-spec small() -> lustre@vdom@vattr:attribute(any()).
small() ->
lustre@attribute:class(<<"btn-sm"/utf8>>).
-file("src/glaze/basecoat/button.gleam", 217).
-spec large() -> lustre@vdom@vattr:attribute(any()).
large() ->
lustre@attribute:class(<<"btn-lg"/utf8>>).
-file("src/glaze/basecoat/button.gleam", 223).
-spec secondary_sm(
list(lustre@vdom@vattr:attribute(PTT)),
list(lustre@vdom@vnode:element(PTT))
) -> lustre@vdom@vnode:element(PTT).
secondary_sm(Attrs, Children) ->
lustre@element@html:button(
[lustre@attribute:class(<<"btn-sm-secondary"/utf8>>),
lustre@attribute:type_(<<"button"/utf8>>) |
Attrs],
Children
).
-file("src/glaze/basecoat/button.gleam", 233).
-spec destructive_sm(
list(lustre@vdom@vattr:attribute(PTZ)),
list(lustre@vdom@vnode:element(PTZ))
) -> lustre@vdom@vnode:element(PTZ).
destructive_sm(Attrs, Children) ->
lustre@element@html:button(
[lustre@attribute:class(<<"btn-sm-destructive"/utf8>>),
lustre@attribute:type_(<<"button"/utf8>>) |
Attrs],
Children
).
-file("src/glaze/basecoat/button.gleam", 243).
-spec outline_sm(
list(lustre@vdom@vattr:attribute(PUF)),
list(lustre@vdom@vnode:element(PUF))
) -> lustre@vdom@vnode:element(PUF).
outline_sm(Attrs, Children) ->
lustre@element@html:button(
[lustre@attribute:class(<<"btn-sm-outline"/utf8>>),
lustre@attribute:type_(<<"button"/utf8>>) |
Attrs],
Children
).
-file("src/glaze/basecoat/button.gleam", 253).
-spec ghost_sm(
list(lustre@vdom@vattr:attribute(PUL)),
list(lustre@vdom@vnode:element(PUL))
) -> lustre@vdom@vnode:element(PUL).
ghost_sm(Attrs, Children) ->
lustre@element@html:button(
[lustre@attribute:class(<<"btn-sm-ghost"/utf8>>),
lustre@attribute:type_(<<"button"/utf8>>) |
Attrs],
Children
).
-file("src/glaze/basecoat/button.gleam", 263).
-spec link_style_sm(
list(lustre@vdom@vattr:attribute(PUR)),
list(lustre@vdom@vnode:element(PUR))
) -> lustre@vdom@vnode:element(PUR).
link_style_sm(Attrs, Children) ->
lustre@element@html:button(
[lustre@attribute:class(<<"btn-sm-link"/utf8>>),
lustre@attribute:type_(<<"button"/utf8>>) |
Attrs],
Children
).
-file("src/glaze/basecoat/button.gleam", 275).
-spec secondary_lg(
list(lustre@vdom@vattr:attribute(PUX)),
list(lustre@vdom@vnode:element(PUX))
) -> lustre@vdom@vnode:element(PUX).
secondary_lg(Attrs, Children) ->
lustre@element@html:button(
[lustre@attribute:class(<<"btn-lg-secondary"/utf8>>),
lustre@attribute:type_(<<"button"/utf8>>) |
Attrs],
Children
).
-file("src/glaze/basecoat/button.gleam", 285).
-spec destructive_lg(
list(lustre@vdom@vattr:attribute(PVD)),
list(lustre@vdom@vnode:element(PVD))
) -> lustre@vdom@vnode:element(PVD).
destructive_lg(Attrs, Children) ->
lustre@element@html:button(
[lustre@attribute:class(<<"btn-lg-destructive"/utf8>>),
lustre@attribute:type_(<<"button"/utf8>>) |
Attrs],
Children
).
-file("src/glaze/basecoat/button.gleam", 295).
-spec outline_lg(
list(lustre@vdom@vattr:attribute(PVJ)),
list(lustre@vdom@vnode:element(PVJ))
) -> lustre@vdom@vnode:element(PVJ).
outline_lg(Attrs, Children) ->
lustre@element@html:button(
[lustre@attribute:class(<<"btn-lg-outline"/utf8>>),
lustre@attribute:type_(<<"button"/utf8>>) |
Attrs],
Children
).
-file("src/glaze/basecoat/button.gleam", 305).
-spec ghost_lg(
list(lustre@vdom@vattr:attribute(PVP)),
list(lustre@vdom@vnode:element(PVP))
) -> lustre@vdom@vnode:element(PVP).
ghost_lg(Attrs, Children) ->
lustre@element@html:button(
[lustre@attribute:class(<<"btn-lg-ghost"/utf8>>),
lustre@attribute:type_(<<"button"/utf8>>) |
Attrs],
Children
).
-file("src/glaze/basecoat/button.gleam", 315).
-spec link_style_lg(
list(lustre@vdom@vattr:attribute(PVV)),
list(lustre@vdom@vnode:element(PVV))
) -> lustre@vdom@vnode:element(PVV).
link_style_lg(Attrs, Children) ->
lustre@element@html:button(
[lustre@attribute:class(<<"btn-lg-link"/utf8>>),
lustre@attribute:type_(<<"button"/utf8>>) |
Attrs],
Children
).
-file("src/glaze/basecoat/button.gleam", 327).
-spec link_sm(
list(lustre@vdom@vattr:attribute(PWB)),
list(lustre@vdom@vnode:element(PWB))
) -> lustre@vdom@vnode:element(PWB).
link_sm(Attrs, Children) ->
lustre@element@html:a(
[lustre@attribute:class(<<"btn-sm"/utf8>>) | Attrs],
Children
).
-file("src/glaze/basecoat/button.gleam", 334).
-spec link_secondary_sm(
list(lustre@vdom@vattr:attribute(PWH)),
list(lustre@vdom@vnode:element(PWH))
) -> lustre@vdom@vnode:element(PWH).
link_secondary_sm(Attrs, Children) ->
lustre@element@html:a(
[lustre@attribute:class(<<"btn-sm-secondary"/utf8>>) | Attrs],
Children
).
-file("src/glaze/basecoat/button.gleam", 341).
-spec link_outline_sm(
list(lustre@vdom@vattr:attribute(PWN)),
list(lustre@vdom@vnode:element(PWN))
) -> lustre@vdom@vnode:element(PWN).
link_outline_sm(Attrs, Children) ->
lustre@element@html:a(
[lustre@attribute:class(<<"btn-sm-outline"/utf8>>) | Attrs],
Children
).
-file("src/glaze/basecoat/button.gleam", 348).
-spec link_ghost_sm(
list(lustre@vdom@vattr:attribute(PWT)),
list(lustre@vdom@vnode:element(PWT))
) -> lustre@vdom@vnode:element(PWT).
link_ghost_sm(Attrs, Children) ->
lustre@element@html:a(
[lustre@attribute:class(<<"btn-sm-ghost"/utf8>>) | Attrs],
Children
).
-file("src/glaze/basecoat/button.gleam", 355).
-spec link_destructive_sm(
list(lustre@vdom@vattr:attribute(PWZ)),
list(lustre@vdom@vnode:element(PWZ))
) -> lustre@vdom@vnode:element(PWZ).
link_destructive_sm(Attrs, Children) ->
lustre@element@html:a(
[lustre@attribute:class(<<"btn-sm-destructive"/utf8>>) | Attrs],
Children
).
-file("src/glaze/basecoat/button.gleam", 364).
-spec link_lg(
list(lustre@vdom@vattr:attribute(PXF)),
list(lustre@vdom@vnode:element(PXF))
) -> lustre@vdom@vnode:element(PXF).
link_lg(Attrs, Children) ->
lustre@element@html:a(
[lustre@attribute:class(<<"btn-lg"/utf8>>) | Attrs],
Children
).
-file("src/glaze/basecoat/button.gleam", 371).
-spec link_secondary_lg(
list(lustre@vdom@vattr:attribute(PXL)),
list(lustre@vdom@vnode:element(PXL))
) -> lustre@vdom@vnode:element(PXL).
link_secondary_lg(Attrs, Children) ->
lustre@element@html:a(
[lustre@attribute:class(<<"btn-lg-secondary"/utf8>>) | Attrs],
Children
).
-file("src/glaze/basecoat/button.gleam", 378).
-spec link_outline_lg(
list(lustre@vdom@vattr:attribute(PXR)),
list(lustre@vdom@vnode:element(PXR))
) -> lustre@vdom@vnode:element(PXR).
link_outline_lg(Attrs, Children) ->
lustre@element@html:a(
[lustre@attribute:class(<<"btn-lg-outline"/utf8>>) | Attrs],
Children
).
-file("src/glaze/basecoat/button.gleam", 385).
-spec link_ghost_lg(
list(lustre@vdom@vattr:attribute(PXX)),
list(lustre@vdom@vnode:element(PXX))
) -> lustre@vdom@vnode:element(PXX).
link_ghost_lg(Attrs, Children) ->
lustre@element@html:a(
[lustre@attribute:class(<<"btn-lg-ghost"/utf8>>) | Attrs],
Children
).
-file("src/glaze/basecoat/button.gleam", 392).
-spec link_destructive_lg(
list(lustre@vdom@vattr:attribute(PYD)),
list(lustre@vdom@vnode:element(PYD))
) -> lustre@vdom@vnode:element(PYD).
link_destructive_lg(Attrs, Children) ->
lustre@element@html:a(
[lustre@attribute:class(<<"btn-lg-destructive"/utf8>>) | Attrs],
Children
).
-file("src/glaze/basecoat/button.gleam", 399).
-spec full_width() -> lustre@vdom@vattr:attribute(any()).
full_width() ->
lustre@attribute:class(<<"w-full"/utf8>>).
-file("src/glaze/basecoat/button.gleam", 403).
-spec disabled() -> lustre@vdom@vattr:attribute(any()).
disabled() ->
lustre@attribute:disabled(true).
-file("src/glaze/basecoat/button.gleam", 407).
-spec loading() -> lustre@vdom@vattr:attribute(any()).
loading() ->
lustre@attribute:disabled(true).
-file("src/glaze/basecoat/button.gleam", 411).
-spec submit(
list(lustre@vdom@vattr:attribute(PYP)),
list(lustre@vdom@vnode:element(PYP))
) -> lustre@vdom@vnode:element(PYP).
submit(Attrs, Children) ->
lustre@element@html:button(
[lustre@attribute:class(<<"btn"/utf8>>),
lustre@attribute:type_(<<"submit"/utf8>>) |
Attrs],
Children
).
-file("src/glaze/basecoat/button.gleam", 421).
-spec reset(
list(lustre@vdom@vattr:attribute(PYV)),
list(lustre@vdom@vnode:element(PYV))
) -> lustre@vdom@vnode:element(PYV).
reset(Attrs, Children) ->
lustre@element@html:button(
[lustre@attribute:class(<<"btn"/utf8>>),
lustre@attribute:type_(<<"reset"/utf8>>) |
Attrs],
Children
).