shadcn-templ 2.0 beta. Switch to templUI v1
1.7k

Popover

Displays rich content in a portal, triggered by a button.

package examples import (

Installation

shadcn-templ add popover

Usage

import "github.com/axadrn/shadcn-templ/v2/components/popover"
@popover.Popover() {	@button.Button(button.Props{		Variant:    button.VariantOutline,		Attributes: popover.Trigger(ctx),	}) {		Open Popover	}	@popover.Content() {		@popover.Header() {			@popover.Title() {				Title			}			@popover.Description() {				Description text here.			}		}	}}

Composition

Use the following composition to build a Popover:

popover.Popover├── popover.Trigger└── popover.Content

Basic

A simple popover with a header, title, and description.

package examples import (

Align

Use the Align prop on popover.Content to control the horizontal alignment.

package examples import (

With Form

A popover with form fields inside.

package examples import (

API Reference

Popover

The popover.Root component renders no element, it carries the id that links trigger and content.

Prop Type Default
ID string -

PopoverTrigger

popover.Trigger(ctx) returns the attributes that turn any element into the popover trigger, popover.TriggerFor(id) targets a popover outside the current root.

PopoverContent

The popover.Content component is the floating panel.

Prop Type Default
Side SideTop | SideRight | SideBottom | SideLeft SideBottom
Align AlignStart | AlignCenter | AlignEnd AlignCenter
SideOffset int 4
AlignOffset int 0
Class string -

PopoverHeader

The popover.Header component wraps the title and description.

Prop Type Default
Class string -

PopoverTitle

The popover.Title component renders the accessible popover title.

Prop Type Default
Class string -

PopoverDescription

The popover.Description component renders the accessible popover description.

Prop Type Default
Class string -