From b9a9417b3b59db43284e1b4c9155295110c2cf2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20D=C3=B6ll?= Date: Fri, 15 Nov 2024 12:39:09 +0000 Subject: [PATCH] feat: add new form component --- components/forms/form.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 components/forms/form.go diff --git a/components/forms/form.go b/components/forms/form.go new file mode 100644 index 0000000..25c9ee6 --- /dev/null +++ b/components/forms/form.go @@ -0,0 +1,22 @@ +package forms + +import htmx "github.com/zeiss/fiber-htmx" + +// FormProps represents the properties for a form element. +type FormProps struct { + ClassNames htmx.ClassNames // The class names for the form element. +} + +// Form returns a form element based on the provided properties. +func Form(p FormProps, children ...htmx.Node) htmx.Node { + return htmx.Form( + htmx.Merge( + htmx.ClassNames{ + "form": true, + "group": true, + }, + p.ClassNames, + ), + htmx.Group(children...), + ) +}