Documentation
¶
Overview ¶
Package checkbox implements checkbox fields.
templ: version: v0.2.793
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type D ¶
type D struct {
// ID is the input id (Name if not set).
ID string
// Name is the input name.
Name string
// Label is the input label (either a string, a label.D or a templ.Component).
//playground:edit:input
Label any
// Value is the input value.
Value string
Checked bool
// Disabled disables the input.
Disabled bool
// CustomStyle defines a custom style.
// style.Custom{
// "checkbox": style.D{style.Add("...")},
// "checkbox/input": style.D{style.Add("...")},
// "checkbox/label": style.D{style.Add("...")},
// }
CustomStyle style.Custom
Attributes templ.Attributes
}
D is the definition for checkbox fields.
Example ¶
package main
import (
"context"
"os"
"github.com/jfbus/templui/components/checkbox"
"github.com/jfbus/templui/components/style"
"github.com/jfbus/templui/skin"
)
func main() {
style.SetSkin(skin.Default)
c := checkbox.C(checkbox.D{
Name: "accept",
Label: "Title",
})
_ = c.Render(context.TODO(), os.Stdout)
}
Output: <div class="flex items-center"><input type="checkbox" id="accept" name="accept" class="ms-2 w-4 h-4 focus:ring-2 rounded text-blue-600 bg-gray-100 border-gray-300 focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 dark:bg-gray-700 dark:border-gray-600"><label for="accept" class="ms-2 text-sm font-medium" :class="hasError('') && 'text-red-700 dark:text-red-500'">Title</label></div>
Click to show internal directories.
Click to hide internal directories.