popover

package
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 2, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package popover provides rich content popover components.

Available variants:

  • New() creates a popover (template: "lvt:popover:default:v1")

Open/close is handled client-side via CSS classes and onclick/onmouseenter/onmouseleave handlers. Server actions handle data operations only.

Example usage:

// In your controller/state
InfoPopover: popover.New("info",
    popover.WithTitle("Details"),
    popover.WithPosition(popover.PositionBottom),
)

// In your template
{{template "lvt:popover:default:v1" .InfoPopover}}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Templates

func Templates() *base.TemplateSet

Templates returns the popover component's template set for registration with the LiveTemplate framework.

Example usage in main.go:

import "github.com/livetemplate/lvt/components/popover"

tmpl, err := livetemplate.New("app",
    livetemplate.WithComponentTemplates(popover.Templates()),
)

Available templates:

  • "lvt:popover:default:v1" - Rich content popover

Types

type Option

type Option func(*Popover)

Option is a functional option for configuring popovers.

func WithArrow

func WithArrow(show bool) Option

WithArrow enables or disables the arrow.

func WithCloseOnClickAway

func WithCloseOnClickAway(close bool) Option

WithCloseOnClickAway enables closing on click outside.

func WithContent

func WithContent(content string) Option

WithContent sets the popover content.

func WithOpen

func WithOpen(_ bool) Option

WithOpen is a no-op. Open/close is now handled client-side via CSS classes. Deprecated: This option has no effect.

func WithPosition

func WithPosition(position Position) Option

WithPosition sets the popover position.

func WithShowClose

func WithShowClose(show bool) Option

WithShowClose shows a close button.

func WithStyled

func WithStyled(styled bool) Option

WithStyled enables Tailwind CSS styling.

func WithTitle

func WithTitle(title string) Option

WithTitle sets the popover title.

func WithTrigger

func WithTrigger(trigger Trigger) Option

WithTrigger sets the popover trigger.

func WithWidth

func WithWidth(width string) Option

WithWidth sets the popover width.

type Popover

type Popover struct {
	base.Base

	// Title is the popover header
	Title string

	// Content is the popover body text
	Content string

	// Position is where the popover appears
	Position Position

	// Trigger is what action shows the popover
	Trigger Trigger

	// Arrow shows a pointing arrow
	Arrow bool

	// CloseOnClickAway closes popover when clicking outside
	CloseOnClickAway bool

	// ShowClose shows a close button in header
	ShowClose bool

	// Width sets the popover width
	Width string
}

Popover is a rich content overlay component. Use template "lvt:popover:default:v1" to render.

func New

func New(id string, opts ...Option) *Popover

New creates a popover.

Example:

p := popover.New("info",
    popover.WithTitle("Information"),
    popover.WithContent("Some details here"),
    popover.WithPosition(popover.PositionBottom),
)

func (*Popover) ArrowClasses

func (p *Popover) ArrowClasses() string

ArrowClasses returns CSS classes for the arrow.

func (*Popover) HasContent

func (p *Popover) HasContent() bool

HasContent returns true if popover has content.

func (*Popover) HasHeader

func (p *Popover) HasHeader() bool

HasHeader returns true if popover should show header.

func (*Popover) HasTitle

func (p *Popover) HasTitle() bool

HasTitle returns true if popover has a title.

func (*Popover) IsBottom

func (p *Popover) IsBottom() bool

IsBottom returns true if position starts with "bottom".

func (*Popover) IsClickTrigger

func (p *Popover) IsClickTrigger() bool

IsClickTrigger returns true if trigger is click.

func (*Popover) IsFocusTrigger

func (p *Popover) IsFocusTrigger() bool

IsFocusTrigger returns true if trigger is focus.

func (*Popover) IsHoverTrigger

func (p *Popover) IsHoverTrigger() bool

IsHoverTrigger returns true if trigger is hover.

func (*Popover) IsLeft

func (p *Popover) IsLeft() bool

IsLeft returns true if position starts with "left".

func (*Popover) IsRight

func (p *Popover) IsRight() bool

IsRight returns true if position starts with "right".

func (*Popover) IsTop

func (p *Popover) IsTop() bool

IsTop returns true if position starts with "top".

func (*Popover) PositionClasses

func (p *Popover) PositionClasses() string

PositionClasses returns CSS classes for position.

func (*Popover) Styles

func (p *Popover) Styles() styles.PopoverStyles

Styles returns the resolved PopoverStyles for this component.

type Position

type Position string

Position defines where the popover appears relative to trigger.

const (
	PositionTop         Position = "top"
	PositionTopStart    Position = "top-start"
	PositionTopEnd      Position = "top-end"
	PositionBottom      Position = "bottom"
	PositionBottomStart Position = "bottom-start"
	PositionBottomEnd   Position = "bottom-end"
	PositionLeft        Position = "left"
	PositionLeftStart   Position = "left-start"
	PositionLeftEnd     Position = "left-end"
	PositionRight       Position = "right"
	PositionRightStart  Position = "right-start"
	PositionRightEnd    Position = "right-end"
)

type Trigger

type Trigger string

Trigger defines what action shows the popover.

const (
	TriggerClick Trigger = "click"
	TriggerHover Trigger = "hover"
	TriggerFocus Trigger = "focus"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL