-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathform.templ
More file actions
54 lines (52 loc) · 1.11 KB
/
form.templ
File metadata and controls
54 lines (52 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package popui
import (
"github.com/invopop/popui.go/props"
"github.com/invopop/popui.go/tailwind"
)
// Form groups a set of form fields together with correct vertical spacing and padding
// between fields. If the Variant is set to "card" it will also add a border and background
// to the form to visually separate it from the rest of the content.
templ Form(p ...props.Form) {
{{ form := props.First(p) }}
<form
if form.ID != "" {
id={ form.ID }
}
if form.Action != "" {
action={ form.Action }
}
if form.Method != "" {
method={ form.Method }
}
if form.Enctype != "" {
enctype={ form.Enctype }
}
if form.Target != "" {
target={ form.Target }
}
if form.Autocomplete != "" {
autocomplete={ form.Autocomplete }
}
if form.Novalidate {
novalidate
}
if form.AcceptCharset != "" {
accept-charset={ form.AcceptCharset }
}
if form.Name != "" {
name={ form.Name }
}
if form.Rel != "" {
rel={ form.Rel }
}
class={
tailwind.Merge(
"relative w-full flex-1 flex flex-col gap-4",
form.Class,
),
}
{ form.Attributes... }
>
{ children... }
</form>
}