24 lines
611 B
Text
24 lines
611 B
Text
|
|
package ui
|
||
|
|
|
||
|
|
// ButtonProps is the input to the Button templ component.
|
||
|
|
//
|
||
|
|
// Type defaults to "button" when empty. Attrs is a pass-through for arbitrary
|
||
|
|
// attributes (notably hx-* HTMX attributes).
|
||
|
|
type ButtonProps struct {
|
||
|
|
Label string
|
||
|
|
Variant ButtonVariant
|
||
|
|
Tone ButtonTone
|
||
|
|
Size Size
|
||
|
|
Type string
|
||
|
|
Attrs templ.Attributes
|
||
|
|
}
|
||
|
|
|
||
|
|
templ Button(props ButtonProps) {
|
||
|
|
{{ btnType := props.Type }}
|
||
|
|
if btnType == "" {
|
||
|
|
{{ btnType = "button" }}
|
||
|
|
}
|
||
|
|
{{ class := ButtonClass(props.Variant, props.Tone, props.Size) }}
|
||
|
|
<button type={ btnType } class={ class } { props.Attrs... }>{ props.Label }</button>
|
||
|
|
}
|