htmgo/examples/simple-auth/ui/login.go
maddalax 8736c00fd5
htmgo - custom formatter (#47)
* format htmgo elements on save

* formatter updates

* ensure we maintain comments
2024-10-25 10:33:48 -05:00

36 lines
788 B
Go

package ui
import (
"github.com/maddalax/htmgo/framework/h"
)
type CenteredFormProps struct {
Title string
Children []h.Ren
SubmitText string
PostUrl string
}
func CenteredForm(props CenteredFormProps) *h.Element {
return h.Div(
h.Class("flex flex-col items-center justify-center min-h-screen bg-neutral-100"),
h.Div(
h.Class("bg-white p-8 rounded-lg shadow-lg w-full max-w-md"),
h.H2F(
props.Title,
h.Class("text-3xl font-bold text-center mb-6"),
),
h.Form(
h.TriggerChildren(),
h.Post(props.PostUrl),
h.Attribute("hx-swap", "none"),
h.Class("flex flex-col gap-4"),
h.Children(props.Children...),
// Error message
FormError(""),
// Submit button at the bottom
SubmitButton(props.SubmitText),
),
),
)
}