// Code generated by wa-generator. DO NOT EDIT. // Source: Web Awesome wa-option package wa import ( "github.com/a-h/templ" ) // Options define the selectable items within a select component. // // Web Awesome component: // OptionProps holds all properties for the wa-option component type OptionProps struct { // The option's value. When selected, the containing form control will receive this value. The value must be unique Value string `attr:"value"` // Draws the option in a disabled state, preventing selection. Disabled bool `attr:"disabled"` // Selects an option initially. Selected bool `attr:"selected"` // The option’s plain text label. Label string `attr:"label"` // Events // Slots contains named slot content Slots OptionSlots // Attrs contains additional HTML attributes Attrs templ.Attributes } // OptionSlots holds named slot content for the component type OptionSlots struct { // An element, such as , placed before the label. Start templ.Component // An element, such as , placed after the label. End templ.Component } // OptionBuilder provides a fluent API for constructing OptionProps type OptionBuilder struct { props OptionProps } // NewOption creates a new builder for wa-option func NewOption() *OptionBuilder { return &OptionBuilder{} } // Value sets the value attribute // The option's value. When selected, the containing form control will receive this value. The value must be unique func (b *OptionBuilder) Value(v string) *OptionBuilder { b.props.Value = v return b } // Disabled sets the disabled attribute // Draws the option in a disabled state, preventing selection. func (b *OptionBuilder) Disabled(v bool) *OptionBuilder { b.props.Disabled = v return b } // Selected sets the selected attribute // Selects an option initially. func (b *OptionBuilder) Selected(v bool) *OptionBuilder { b.props.Selected = v return b } // Label sets the label attribute // The option’s plain text label. func (b *OptionBuilder) Label(v string) *OptionBuilder { b.props.Label = v return b } // StartSlot sets the start slot content // An element, such as , placed before the label. func (b *OptionBuilder) StartSlot(c templ.Component) *OptionBuilder { b.props.Slots.Start = c return b } // EndSlot sets the end slot content // An element, such as , placed after the label. func (b *OptionBuilder) EndSlot(c templ.Component) *OptionBuilder { b.props.Slots.End = c return b } // Attr adds a custom HTML attribute func (b *OptionBuilder) Attr(name, value string) *OptionBuilder { if b.props.Attrs == nil { b.props.Attrs = templ.Attributes{} } b.props.Attrs[name] = value return b } // Attrs merges multiple attributes func (b *OptionBuilder) Attrs(attrs templ.Attributes) *OptionBuilder { if b.props.Attrs == nil { b.props.Attrs = templ.Attributes{} } for k, v := range attrs { b.props.Attrs[k] = v } return b } // Props returns the built properties func (b *OptionBuilder) Props() OptionProps { return b.props } // Build returns the props (alias for Props for semantic clarity) func (b *OptionBuilder) Build() OptionProps { return b.props } // Option renders the wa-option component templ Option(props OptionProps) { if props.Slots.Start != nil {
@props.Slots.Start
} if props.Slots.End != nil {
@props.Slots.End
} { children... }
} // OptionFunc renders with a builder function for inline configuration templ OptionFunc(fn func(*OptionBuilder)) { {{ b := NewOption(); fn(b) }} @Option(b.Props()) { { children... } } }