Documentation
¶
Overview ¶
Package buttongroup implements button groups.
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/a-h/templ"
"github.com/jfbus/templui/components/button"
"github.com/jfbus/templui/components/buttongroup"
"github.com/jfbus/templui/components/icon"
"github.com/jfbus/templui/components/size"
"github.com/jfbus/templui/components/style"
)
func main() {
c := buttongroup.C(buttongroup.D{
Size: size.S,
Buttons: []button.D{
{
Icon: icon.ArrowDownNarrowWide,
Label: "Sort",
Style: button.StyleHideLabelAlways,
CustomStyle: style.Custom{
"button": style.D{
style.ReplaceVariants("bg", "bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600"),
},
},
Attributes: templ.Attributes{
"@click": "$dispatch('input', '')",
},
},
{
Icon: icon.Heart,
Label: "Rating",
Style: button.StyleHideLabelAlways,
Attributes: templ.Attributes{
"@click": "$dispatch('input', 'rating')",
},
},
{
Icon: icon.Banknote,
Label: "Price",
Style: button.StyleHideLabelAlways,
Attributes: templ.Attributes{
"@click": "$dispatch('input', 'price')",
},
},
},
Attributes: templ.Attributes{
"x-model": "sort",
},
})
_ = c.Render(context.TODO(), os.Stdout)
}
Output:
Types ¶
type D ¶
type D struct {
// Buttons is the list of buttons to display.
//playground:import:github.com/jfbus/templui/components/button
//playground:default:[]button.D{{Label:"A"},{Label:"B"},{Label:"C"},{Label:"D"}}
Buttons []button.D
// Size defines the buttons size (shortcut for Buttons.Size).
Size size.Size
// CustomStyle defines a custom style.
// style.Custom{
// "buttongroup": style.D{style.Add("...")},
// "buttongroup/button": style.D{style.Add("...")},
// }
CustomStyle style.Custom
// Attributes stores additional attributes (e.g. HTMX attributes).
Attributes templ.Attributes
}
Click to show internal directories.
Click to hide internal directories.