Documentation
¶
Overview ¶
Package selectfield implements select fields. `select` being a reserved keyword, the package cannot be named select.
templ: version: v0.2.793
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func C ¶
Example ¶
package main
import (
"context"
"os"
"github.com/jfbus/templui/components/selectfield"
"github.com/jfbus/templui/components/selectfield/option"
)
func main() {
c := selectfield.C(selectfield.D{
Name: "country",
Label: "Country",
Options: []option.D{{
Label: "Select a country",
}, {
Value: "FR",
Label: "France",
}, {
Value: "DE",
Label: "Germany",
}, {
Value: "UK",
Label: "United Kingdom",
}},
Selected: "DE",
})
c.Render(context.TODO(), os.Stdout)
}
Output:
Types ¶
type D ¶
type D struct {
// ID is the tag id.
ID string
// Name is the tag name.
Name string
// Style is the style (style.Default, style.Valid or style.Invalid).
Style style.Style
// Label is the label (either a string or a label.D).
Label any
// Options is the list of options.
//playground:import:github.com/jfbus/templui/components/selectfield/option
//playground:default:[]option.D{{Label:"Select a value"},{Label:"Option 1"},{Label:"Option 2"}}
Options []option.D
// Select is the selected value.
Selected string
// Disabled disables the select.
Disabled bool
// Size is the size.
Size size.Size
// Message adds a validation message below the field.
// Just add &message.D{} to add automatic validation.
//playground:import:github.com/jfbus/templui/components/form/validation/message
//playground:default:&message.D{Message: "Validation message"}
Message *message.D
// CustomStyle defines a custom style.
// style.Custom{
// "select": style.D{style.Add("...")},
// "select/input": style.D{style.Add("...")},
// "select/label": style.D{style.Add("...")},
// }
CustomStyle style.Custom
// Attributes add additional attributes.
Attributes templ.Attributes
}
D is the select definition.
Click to show internal directories.
Click to hide internal directories.