-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfieldset.templ
More file actions
34 lines (32 loc) · 975 Bytes
/
fieldset.templ
File metadata and controls
34 lines (32 loc) · 975 Bytes
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
package popui
import (
"github.com/invopop/popui.go/classes"
"github.com/invopop/popui.go/props"
"github.com/invopop/popui.go/tailwind"
)
// Fieldset 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 fieldset to visually separate it from the rest of the form.
templ Fieldset(p ...props.Fieldset) {
{{ fieldset := props.First(p) }}
<fieldset
if fieldset.ID != "" {
id={ fieldset.ID }
}
class={
tailwind.Merge(
"relative w-full flex-1 flex flex-col gap-4",
classes.If(fieldset.Variant == props.FieldsetVariantCard, "border border-border-default-secondary rounded-md bg-background p-4"),
fieldset.Class,
),
}
{ fieldset.Attributes... }
>
if fieldset.Legend != "" {
<legend class="float-left text-lg font-medium text-foreground">
{ fieldset.Legend }
</legend>
}
{ children... }
</fieldset>
}