xtablo-source/backend/internal/web/ui/button.templ

24 lines
611 B
Text
Raw Normal View History

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>
}