mirror of
https://github.com/axzilla/templui.git
synced 2025-02-21 00:32:58 +00:00
change: add type to button component
This commit is contained in:
parent
21600ffc34
commit
fa59e4f47b
@ -56,6 +56,10 @@ type ButtonProps struct {
|
||||
// If string, it's treated as a JavaScript expression for dynamic disabling.
|
||||
Disabled any
|
||||
|
||||
// Type specifies the type of the button. Default: "button"
|
||||
// Default: "" (empty string)
|
||||
Type string
|
||||
|
||||
// Attributes allows passing additional HTML attributes to the button or anchor element.
|
||||
// Default: nil
|
||||
Attributes templ.Attributes
|
||||
@ -118,6 +122,7 @@ func getSizeClasses(size ButtonSize) string {
|
||||
// - Href: If provided, renders the button as an anchor tag with this URL. Default: "" (empty string)
|
||||
// - Target: The target attribute for the anchor tag (only used when Href is provided). Default: "" (empty string)
|
||||
// - Disabled: Can be either a bool or a string. If bool (Go), it directly controls the disabled state. If string, it's treated as a JavaScript expression for dynamic disabling. Default: nil
|
||||
// - Type: The type of the button. Default: "button"
|
||||
// - Attributes: Additional HTML attributes to apply to the button or anchor element. Default: nil
|
||||
templ Button(props ButtonProps) {
|
||||
if props.Href != "" {
|
||||
@ -156,6 +161,9 @@ templ Button(props ButtonProps) {
|
||||
templ.KV("w-full", props.FullWidth),
|
||||
props.Class,
|
||||
}
|
||||
if props.Type == "" {
|
||||
type={ props.Type }
|
||||
}
|
||||
if props.Disabled != nil {
|
||||
if disabledBool, ok := props.Disabled.(bool); ok {
|
||||
disabled?={ disabledBool }
|
||||
|
Loading…
x
Reference in New Issue
Block a user