Documentation
¶
Overview ¶
templ: version: v0.2.778
templ: version: v0.2.778
templ: version: v0.2.778
templ: version: v0.2.778
templ: version: v0.2.778
templ: version: v0.2.778
templ: version: v0.2.778
templ: version: v0.2.778
templ: version: v0.2.778
templ: version: v0.2.778
templ: version: v0.2.778
templ: version: v0.2.778
templ: version: v0.2.778
templ: version: v0.2.778
templ: version: v0.2.778
templ: version: v0.2.778
templ: version: v0.2.778
templ: version: v0.2.778
templ: version: v0.2.778
templ: version: v0.2.778
templ: version: v0.2.778
Index ¶
- Constants
- Variables
- func Accordion(props AccordionProps) templ.Component
- func Alert(props AlertProps) templ.Component
- func AlertDescription() templ.Component
- func AlertTitle() templ.Component
- func Avatar(props AvatarProps) templ.Component
- func AvatarInitials(name string) string
- func AvatarSizeClasses(size AvatarSize) string
- func Button(props ButtonProps) templ.Component
- func Card(props CardProps) templ.Component
- func CardContent() templ.Component
- func CardDescription() templ.Component
- func CardFooter() templ.Component
- func CardHeader() templ.Component
- func CardTitle() templ.Component
- func Checkbox(props CheckboxProps) templ.Component
- func DarkIcon() templ.Component
- func Datepicker(props DatepickerProps) templ.Component
- func DropdownMenu(props DropdownMenuProps) templ.Component
- func DynamicThemeIcon() templ.Component
- func Footer() templ.Component
- func Input(props InputProps) templ.Component
- func LightIcon() templ.Component
- func Modal(props ModalProps) templ.Component
- func ModalBody() templ.Component
- func ModalClose(id string) templ.Component
- func ModalFooter() templ.Component
- func ModalHeader() templ.Component
- func ModalTrigger(id string) templ.Component
- func Navbar() templ.Component
- func NavbarMobileMenu() templ.Component
- func RadioGroup(props RadioGroupProps) templ.Component
- func RadioGroupItem(props RadioGroupItemProps) templ.Component
- func Select(props SelectProps) templ.Component
- func Sheet(props SheetProps) templ.Component
- func SheetClose(text string) templ.Component
- func SheetRoot() templ.Component
- func SheetTrigger(text string, side SheetSide) templ.Component
- func Sidebar() templ.Component
- func SidebarRight() templ.Component
- func Slider(props SliderProps) templ.Component
- func Tabs(props TabsProps) templ.Component
- func Textarea(props TextareaProps) templ.Component
- func ThemeSwitcher() templ.Component
- func Toggle(props ToggleProps) templ.Component
- type AccordionItem
- type AccordionProps
- type AlertProps
- type AlertVariant
- type AvatarProps
- type AvatarSize
- type ButtonProps
- type ButtonSize
- type ButtonVariant
- type CardProps
- type CheckboxProps
- type DatepickerProps
- type DropdownMenuItem
- type DropdownMenuProps
- type InputProps
- type InputType
- type ModalProps
- type RadioGroupItemProps
- type RadioGroupProps
- type SelectOption
- type SelectProps
- type SheetProps
- type SheetSide
- type SidebarRightLItem
- type SliderProps
- type Tab
- type TabsProps
- type TextareaProps
- type ToggleLabelPlacement
- type ToggleProps
- type ToggleSize
Constants ¶
const ( // Button style variants Default ButtonVariant = "default" // Primary action button Destructive ButtonVariant = "destructive" // Dangerous/warning action Outline ButtonVariant = "outline" // Bordered button Secondary ButtonVariant = "secondary" // Less prominent action Ghost ButtonVariant = "ghost" // Minimal styling Link ButtonVariant = "link" // Appears as a text link // Button sizes Md ButtonSize = "md" // Standard size Sm ButtonSize = "sm" // Compact size Lg ButtonSize = "lg" // Large size ButtonIcon ButtonSize = "icon" // Square icon button )
Variables ¶
var SidebarRightLinks = []SidebarRightLItem{
{
ImageSrc: "https://templ.guide/img/logo.svg",
Url: "https://templ.guide",
Text: "Elevate your Go projects with type-safe, efficient HTML templating.",
},
{
ImageSrc: "https://alpinejs.dev/alpine_long.svg",
Url: "https://alpinejs.dev",
Text: "Simplify your JavaScript with a lightweight, powerful framework.",
},
{
ImageSrc: "https://tailwindcss.com/_next/static/media/tailwindcss-logotype-white.944c5d0ef628083bb316f9b3d643385c86bcdb3d.svg",
Url: "https://tailwindcss.com",
Text: "Create beautiful, responsive designs with ease.",
},
}
var TemplFiles embed.FS
Functions ¶
func Accordion ¶
func Accordion(props AccordionProps) templ.Component
Accordion renders a collapsible content section component with expand/collapse functionality. For detailed examples and usage guides, visit https://goilerplate.com/docs/components/accordion
Props: - Items: Array of accordion sections with ID, trigger and content - Class: Additional CSS classes - Attributes: Additional HTML attributes (e.g. data-testid)
func Alert ¶
func Alert(props AlertProps) templ.Component
Alert renders a notification box component for messages, warnings and errors. For detailed examples and usage guides, visit https://goilerplate.com/docs/components/alert
Props: - Variant: Visual style (DefaultAlert or DestructiveAlert) - Class: Additional CSS classes
func AlertDescription ¶
AlertDescription renders the description of the alert.
func Avatar ¶
func Avatar(props AvatarProps) templ.Component
Avatar renders a circular image or initials for user representation. For detailed examples and usage guides, visit https://goilerplate.com/docs/components/avatar
Props: - ImageSrc: URL for the avatar image - Name: Text to generate initials from when no image is provided - Size: Avatar dimensions (small, medium, large) - Class: Additional CSS classes - Attributes: Additional HTML attributes
func AvatarInitials ¶
AvatarInitials generates a 1-2 character initial from the given name
func AvatarSizeClasses ¶
func AvatarSizeClasses(size AvatarSize) string
AvatarSizeClasses maps sizes to their corresponding CSS classes
func Button ¶
func Button(props ButtonProps) templ.Component
Button renders an interactive button or link component with consistent styling. For detailed examples and usage guides, visit https://goilerplate.com/docs/components/button
Props: - Class: Additional CSS classes - Text: Button label text - Variant: Visual style (default, destructive, outline, etc) - Size: Button dimensions (sm, md, lg, icon) - FullWidth: Expand to fill container - Href: Optional URL for link buttons - Target: Link target attribute - Disabled: Interactivity state - Type: Button type attribute - Attributes: Additional HTML attributes - IconLeft: Icon component before text - IconRight: Icon component after text
func Card ¶
Card renders a container component with consistent styling and structure. For detailed examples and usage guides, visit https://goilerplate.com/docs/components/card
Props: - Class: Additional CSS classes - Attributes: Additional HTML attributes
func CardContent ¶
CardContent renders the main card body section Contains the primary content area
func CardDescription ¶
CardDescription renders secondary text below the title Uses muted styling for visual hierarchy
func CardFooter ¶
CardFooter renders the bottom section of the card Typically contains actions or summary information
func CardHeader ¶
CardHeader renders the top section of the card Typically contains title and description
func Checkbox ¶ added in v0.20.4
func Checkbox(props CheckboxProps) templ.Component
Checkbox renders a styled checkbox input with optional label. For detailed examples and usage guides, visit https://goilerplate.com/docs/components/checkbox
Props: - ID: Unique identifier for the input - Name: Form field name - Value: Checkbox value - Label: Optional text label - Class: Additional CSS classes - Attributes: Additional HTML attributes
func Datepicker ¶
func Datepicker(props DatepickerProps) templ.Component
Datepicker renders a calendar input component with popup date selection. Uses Alpine.js for interactions and supports dark mode via Tailwind. For detailed examples and usage guides, visit https://goilerplate.com/docs/components/datepicker
Props: - ID: Unique identifier for the input - Name: Form field name - Placeholder: Helper text when empty - Format: Date display format - Class: Additional CSS classes - Attributes: Additional HTML attributes
func DropdownMenu ¶ added in v0.20.3
func DropdownMenu(props DropdownMenuProps) templ.Component
DropdownMenu renders a customizable popup menu with positioning and nesting support. Uses Alpine.js for interactions and supports keyboard navigation. For detailed examples and usage guides, visit https://goilerplate.com/docs/components/dropdown-menu
Props: - Items: Menu structure and content - Trigger: Custom trigger element (optional) - Class: Additional CSS classes - Position: Preferred placement
Features: - Nested submenus (up to 3 levels) - Automatic position adjustment - Keyboard navigation - ARIA support
func DynamicThemeIcon ¶ added in v0.20.3
func Input ¶
func Input(props InputProps) templ.Component
Input renders a form input field with optional label and validation. For detailed examples and usage guides, visit https://goilerplate.com/docs/components/input
Props: - Type: Input field behavior type - Placeholder: Helper text when empty - Value: Current input value - Name: Form field name - ID: Unique identifier - Label: Text label - Description: Helper text - Error: Validation message - Class: Additional CSS classes - FileAccept: Allowed file types - Attributes: Additional HTML attributes
func Modal ¶
func Modal(props ModalProps) templ.Component
Modal renders a popup dialog window with customizable content. Uses Alpine.js for interactions and animations. For detailed examples and usage guides, visit https://goilerplate.com/docs/components/modal
Props: - ID: Unique identifier for control - Class: Additional CSS classes
func ModalClose ¶
ModalClose creates clickable elements that close a modal ID parameter must match the target modal's ID
func ModalFooter ¶
ModalFooter renders the modal action buttons section
func ModalTrigger ¶
ModalTrigger creates clickable elements that open a modal ID parameter must match the target modal's ID
func NavbarMobileMenu ¶
func RadioGroup ¶ added in v0.20.8
func RadioGroup(props RadioGroupProps) templ.Component
RadioGroup renders a set of mutually exclusive radio button options. For detailed examples and usage guides, visit https://goilerplate.com/docs/components/radio-group
Props: - Name: Groups related radio buttons - Class: Additional CSS classes - Attributes: Additional HTML attributes
func RadioGroupItem ¶ added in v0.20.8
func RadioGroupItem(props RadioGroupItemProps) templ.Component
RadioGroupItem renders an individual radio button with label. Must be used within a RadioGroup component.
Props: - Value: Radio button value - Name: Matches parent group name - ID: Unique identifier - Label: Button label - Class: Additional CSS classes - Attributes: Additional HTML attributes
func Select ¶ added in v0.22.0
func Select(props SelectProps) templ.Component
Select renders a dropdown menu component with keyboard navigation. For detailed examples and usage guides, visit https://goilerplate.com/docs/components/select
Props: - ID: Unique identifier - Name: Form field name - Placeholder: Default text - Options: Available choices - Class: Additional CSS classes - Attributes: Additional HTML attributes
Features: - Keyboard navigation - Disabled state support - Alpine.js integration - Custom styling via Tailwind
func Sheet ¶
func Sheet(props SheetProps) templ.Component
Sheet renders a slide-in panel with backdrop. Uses Alpine.js for animations and state management. For detailed examples and usage guides, visit https://goilerplate.com/docs/components/sheet
Props: - Title: Header text - Description: Subheading text - Side: Slide-in direction
Features: - Responsive sizing - Animated transitions - Backdrop blur - ESC key closing
func SheetClose ¶
SheetClose creates a button that closes the sheet Must be used within Sheet
func SheetRoot ¶
SheetRoot initializes Alpine.js state and event handlers Must wrap Sheet components and triggers
func SheetTrigger ¶
SheetTrigger creates elements that open the sheet Must be used within SheetRoot
func SidebarRight ¶
func Slider ¶ added in v0.22.0
func Slider(props SliderProps) templ.Component
Slider renders a range input component with support for labels, value display and external binding. For detailed examples and usage guides, visit https://goilerplate.com/docs/components/slider
Props:
- ID: Unique identifier for the slider
- Name: Input name attribute
- Min: Minimum value (default: 0)
- Max: Maximum value (default: 100)
- Step: Value increment (default: 1)
- Value: Initial value
- Label: Optional label text
- ShowValue: Show current value
- ValueFormat: Optional format suffix (e.g. "%", "°C")
- Class: Additional CSS classes
- Disabled: Disables the slider
- Attributes: Additional HTML attributes (e.g. x-model for binding)
func Tabs ¶
Tabs renders a tabbed interface with animated transitions. Uses Alpine.js for state management and interactions. For detailed examples and usage guides, visit https://goilerplate.com/docs/components/tabs
Props: - Tabs: Tab definitions and content - TabsContainerClass: Additional classes for header - ContentContainerClass: Additional classes for content
Features: - Animated tab switching - Keyboard navigation - Responsive layout - ARIA support
func Textarea ¶ added in v0.22.0
func Textarea(props TextareaProps) templ.Component
Textarea renders a multi-line text input with optional validation. Uses Alpine.js for autoresize functionality when enabled. For detailed examples and usage guides, visit https://goilerplate.com/docs/components/textarea
Props: - ID: Unique identifier - Name: Form field name - Value: Initial content - Placeholder: Helper text when empty - Label: Text label - Description: Helper text - Error: Validation message - Rows: Initial height in lines - Class: Additional CSS classes - AutoResize: Enable dynamic sizing - Attributes: Additional HTML attributes
func ThemeSwitcher ¶
func Toggle ¶ added in v0.21.0
func Toggle(props ToggleProps) templ.Component
Toggle renders a switch control for boolean values. Uses Alpine.js for state management and animations. For detailed examples and usage guides, visit https://goilerplate.com/docs/components/toggle
Props: - ID: Unique identifier - Name: Form field name - LabelLeft: Text before toggle - LabelRight: Text after toggle - Class: Additional CSS classes - Attributes: Additional HTML attributes
Features: - Animated switching - Keyboard navigation - Label placement options - ARIA support
Types ¶
type AccordionItem ¶
type AccordionItem struct {
// ID is the unique identifier for managing accordion item state
ID string
// Trigger is the content shown in the header/trigger area
// Can be any templ.Component (typically text)
Trigger templ.Component
// Content is the expandable content section
// Can be any templ.Component
Content templ.Component
}
type AccordionProps ¶
type AccordionProps struct {
// Items contains the accordion sections
Items []AccordionItem
// Class adds custom CSS classes
Class string
// Attributes for additional HTML attributes and Alpine.js bindings
Attributes templ.Attributes
}
type AlertProps ¶
type AlertProps struct {
// Variant controls the alert styling (default or destructive)
Variant AlertVariant
// Class adds custom CSS classes
Class string
}
type AlertVariant ¶
type AlertVariant string
AlertVariant defines the available alert styles
const ( // DefaultAlert shows standard informational styling DefaultAlert AlertVariant = "default" // DestructiveAlert shows error/warning styling DestructiveAlert AlertVariant = "destructive" )
type AvatarProps ¶
type AvatarProps struct {
// ImageSrc is the URL for the avatar image
// If empty, initials will be shown instead
ImageSrc string
// Name is used to generate initials when no image is provided
Name string
// Size controls the avatar dimensions (small, medium, large)
Size AvatarSize
// Class adds custom CSS classes
Class string
// Attributes for additional HTML attributes
Attributes templ.Attributes
}
type AvatarSize ¶
type AvatarSize string
AvatarSize defines the available avatar dimensions
const ( // AvatarSizeSmall renders a small avatar (32x32px) AvatarSizeSmall AvatarSize = "small" // AvatarSizeMedium renders a medium avatar (48x48px) AvatarSizeMedium AvatarSize = "medium" // AvatarSizeLarge renders a large avatar (64x64px) AvatarSizeLarge AvatarSize = "large" )
type ButtonProps ¶
type ButtonProps struct {
// Class adds custom CSS classes
Class string
// Text contains the button label
Text string
// Variant controls the button styling
Variant ButtonVariant
// Size controls button dimensions
Size ButtonSize
// FullWidth makes button expand to container width
FullWidth bool
// Href turns the button into a link
Href string
// Target controls link opening behavior
Target string
// Disabled controls interactive state (bool or JS expression)
Disabled any
// Type sets the button type attribute
Type string
// Attributes for additional HTML attributes
Attributes templ.Attributes
// IconLeft displays an icon before text
IconLeft templ.Component
// IconRight displays an icon after text
IconRight templ.Component
}
type CardProps ¶
type CardProps struct {
// Class adds custom CSS classes
Class string
// Attributes for additional HTML attributes
Attributes templ.Attributes
}
type CheckboxProps ¶ added in v0.20.4
type CheckboxProps struct {
// ID uniquely identifies the checkbox input
ID string
// Name sets the form field name
Name string
// Value sets the checkbox value
Value string
// Label displays text next to checkbox
// Empty string hides the label
Label string
// Class adds custom CSS classes
Class string
// Attributes for additional HTML attributes and Alpine.js bindings
Attributes templ.Attributes
}
type DatepickerProps ¶
type DatepickerProps struct {
// ID uniquely identifies the datepicker input
ID string
// Name sets the form field name
Name string
// Placeholder shows helper text when empty
Placeholder string
// Format controls date string presentation
// Supported formats:
// - "M d, Y" (Jan 1, 2024)
// - "MM-DD-YYYY" (01-01-2024)
// - "DD-MM-YYYY" (01-01-2024)
// - "YYYY-MM-DD" (2024-01-01)
// - "D d M, Y" (Mon 1 Jan, 2024)
Format string
// Class adds custom CSS classes
Class string
Value string
// Attributes for additional HTML attributes and Alpine.js bindings
Attributes templ.Attributes
}
type DropdownMenuItem ¶ added in v0.20.3
type DropdownMenuItem struct {
// Label displays text for the menu item
Label string
// Value for non-link menu items
Value string
// Href makes item a navigation link
Href string
// Target controls link opening behavior
Target string
// IconLeft displays icon before label
IconLeft templ.Component
// IconRight displays icon after label
IconRight templ.Component
// SubItems creates nested submenu
SubItems []DropdownMenuItem
// Disabled controls interactive state
Disabled bool
// Attributes for additional HTML attributes
Attributes templ.Attributes
}
func (DropdownMenuItem) ModifierClasses ¶ added in v0.21.1
func (d DropdownMenuItem) ModifierClasses() string
ModifierClasses generates state-based CSS classes
type DropdownMenuProps ¶ added in v0.20.3
type DropdownMenuProps struct {
// Items defines the menu structure
Items []DropdownMenuItem
// Trigger overrides default button trigger
Trigger templ.Component
// Class adds custom CSS classes
Class string
// Position sets preferred menu placement (left, right, top, bottom)
Position string
}
type InputProps ¶
type InputProps struct {
// Type sets the input field behavior
Type InputType
// Placeholder shows helper text when empty
Placeholder string
// Value sets the current input content
Value string
// Name sets the form field name
Name string
// ID uniquely identifies the input
ID string
// Label displays text above input
Label string
// Description shows helper text below input
Description string
// Error displays validation message
Error string
// Class adds custom CSS classes
Class string
// FileAccept limits allowed file types
// Only used when Type is InputTypeFile
FileAccept string
// Attributes for additional HTML attributes and Alpine.js bindings
Attributes templ.Attributes
}
type InputType ¶
type InputType string
InputType defines the available input field types
const ( // Standard text inputs InputTypeText InputType = "text" InputTypePassword InputType = "password" InputTypeEmail InputType = "email" InputTypeNumber InputType = "number" InputTypeTel InputType = "tel" InputTypeURL InputType = "url" InputTypeSearch InputType = "search" // Date and time inputs InputTypeDate InputType = "date" InputTypeTime InputType = "time" // File upload input InputTypeFile InputType = "file" )
type ModalProps ¶
type RadioGroupItemProps ¶ added in v0.20.8
type RadioGroupItemProps struct {
// Value sets the radio button value
Value string
// Name matches parent RadioGroup name
Name string
// ID uniquely identifies the radio button
ID string
// Label displays text next to radio button
Label templ.Component
// Class adds custom CSS classes
Class string
// Attributes for additional HTML attributes and Alpine.js bindings
Attributes templ.Attributes
}
type RadioGroupProps ¶ added in v0.20.8
type RadioGroupProps struct {
// Name groups related radio buttons
Name string
// Class adds custom CSS classes
Class string
// Attributes for additional HTML attributes
Attributes templ.Attributes
}
type SelectOption ¶ added in v0.22.0
type SelectOption struct {
// Label displays text in dropdown
Label string
// Value sets the option's form value
Value string
// Attributes for disabled state or other HTML attributes
Attributes templ.Attributes
}
type SelectProps ¶ added in v0.22.0
type SelectProps struct {
// ID uniquely identifies the select input
ID string
// Name sets the form field name
Name string
// Placeholder shows text when no option selected
Placeholder string
// Options defines available choices
Options []SelectOption
// Class adds custom CSS classes
Class string
// Attributes for additional HTML attributes and Alpine.js bindings
Attributes templ.Attributes
}
type SheetProps ¶
type SidebarRightLItem ¶
type SliderProps ¶ added in v0.22.0
type SliderProps struct {
// ID is the unique identifier for the slider
ID string
// Name is the name attribute for the slider
Name string
// Min sets the minimum value (default: 0)
Min int
// Max sets the maximum value (default: 100)
Max int
// Step defines the increment between values (default: 1)
Step int
// Value sets the initial value
Value int
// Label displays a label above the slider
Label string
// ShowValue toggles the value display
ShowValue bool
// ValueFormat adds a suffix to the value (e.g. "%", "°C")
ValueFormat string
// Class adds custom CSS classes
Class string
// Disabled makes the slider non-interactive
Disabled bool
// Attributes for additional HTML attributes and Alpine.js bindings
Attributes templ.Attributes
}
type TextareaProps ¶ added in v0.22.0
type TextareaProps struct {
// ID uniquely identifies the textarea
ID string
// Name sets the form field name
Name string
// Value sets initial content
Value string
// Placeholder shows when empty
Placeholder string
// Label displays text above textarea
Label string
// Description shows helper text below
Description string
// Error displays validation message
Error string
// Rows sets visible text lines height
Rows int
// Class adds custom CSS classes
Class string
// AutoResize enables dynamic height adjustment
AutoResize bool
// Attributes for additional HTML attributes and Alpine.js bindings
Attributes templ.Attributes
}
type ToggleLabelPlacement ¶ added in v0.21.0
type ToggleLabelPlacement string
ToggleLabelPlacement defines label position options
type ToggleProps ¶ added in v0.21.0
type ToggleProps struct {
// ID uniquely identifies the toggle
ID string
// Name sets the form field name
Name string
// LabelLeft displays text before toggle
LabelLeft string
// LabelRight displays text after toggle
LabelRight string
// Class adds custom CSS classes
Class string
// Attributes for additional HTML attributes and Alpine.js bindings
Attributes templ.Attributes
}
type ToggleSize ¶ added in v0.21.0
type ToggleSize string
/ ToggleSize defines the available toggle dimensions
Source Files
¶
- accordion_templ.go
- alert_templ.go
- avatar_templ.go
- button_templ.go
- card_templ.go
- checkbox_templ.go
- datepicker_templ.go
- dropdown_menu_templ.go
- embed.go
- footer_templ.go
- input_templ.go
- modal_templ.go
- navbar_templ.go
- radio_group_templ.go
- select_templ.go
- sheet_templ.go
- sidebar_right_templ.go
- sidebar_templ.go
- slider_templ.go
- tabs_templ.go
- textarea_templ.go
- themeswitcher_templ.go
- toggle_templ.go