Popover
Displays rich content in a portal, triggered by a button.
Code
import { Button, Input, Label, Popover, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger,} from "@falcon/ui-kit";
export function Example() { return ( <Popover> <PopoverTrigger render={<Button variant="outline" />}> Open popover </PopoverTrigger> <PopoverContent className="tw:w-80"> <div className="tw:grid tw:gap-4"> <PopoverHeader> <PopoverTitle>Application plan</PopoverTitle> <PopoverDescription> Set the details for this field. </PopoverDescription> </PopoverHeader> <div className="tw:grid tw:gap-2"> <div className="tw:grid tw:grid-cols-3 tw:items-center tw:gap-4"> <Label htmlFor="product">Product</Label> <Input id="product" defaultValue="Urea" className="tw:col-span-2 tw:h-8" /> </div> <div className="tw:grid tw:grid-cols-3 tw:items-center tw:gap-4"> <Label htmlFor="rate">Rate</Label> <Input id="rate" defaultValue="180" className="tw:col-span-2 tw:h-8" /> </div> <div className="tw:grid tw:grid-cols-3 tw:items-center tw:gap-4"> <Label htmlFor="unit">Unit</Label> <Input id="unit" defaultValue="lb/acre" className="tw:col-span-2 tw:h-8" /> </div> <div className="tw:grid tw:grid-cols-3 tw:items-center tw:gap-4"> <Label htmlFor="acres">Acres</Label> <Input id="acres" defaultValue="120" className="tw:col-span-2 tw:h-8" /> </div> </div> </div> </PopoverContent> </Popover> );}Composition
Section titled “Composition”Use the following composition to build a Popover:
Popover├── PopoverTrigger└── PopoverContentA simple popover with a header, title, and description.
Code
import { Button, Popover, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger,} from "@falcon/ui-kit";
export function Example() { return ( <> <Popover> <PopoverTrigger render={<Button variant="outline" className="tw:w-fit" />} > Open Popover </PopoverTrigger> <PopoverContent align="start"> <PopoverHeader> <PopoverTitle>Application plan</PopoverTitle> <PopoverDescription> Set the details for this field. </PopoverDescription> </PopoverHeader> </PopoverContent> </Popover> </> );}Use the align prop on PopoverContent to control the horizontal alignment.
Code
import { Button, Popover, PopoverContent, PopoverTrigger,} from "@falcon/ui-kit";
export function Example() { return ( <> <div className="tw:flex tw:gap-6"> <Popover> <PopoverTrigger render={<Button variant="outline" size="sm" />}> Start </PopoverTrigger> <PopoverContent align="start" aria-label="Start-aligned popover" className="tw:w-40" > Aligned to start </PopoverContent> </Popover> <Popover> <PopoverTrigger render={<Button variant="outline" size="sm" />}> Center </PopoverTrigger> <PopoverContent align="center" aria-label="Center-aligned popover" className="tw:w-40" > Aligned to center </PopoverContent> </Popover> <Popover> <PopoverTrigger render={<Button variant="outline" size="sm" />}> End </PopoverTrigger> <PopoverContent align="end" aria-label="End-aligned popover" className="tw:w-40" > Aligned to end </PopoverContent> </Popover> </div> </> );}With Form
Section titled “With Form”A popover with form fields inside.
Code
import { Button, Field, FieldGroup, FieldLabel, Input, Popover, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger,} from "@falcon/ui-kit";
export function Example() { return ( <> <Popover> <PopoverTrigger render={<Button variant="outline" />}> Open Popover </PopoverTrigger> <PopoverContent className="tw:w-64" align="start"> <PopoverHeader> <PopoverTitle>Application rate</PopoverTitle> <PopoverDescription> Set the planned rate for this field. </PopoverDescription> </PopoverHeader> <FieldGroup className="tw:gap-4"> <Field orientation="horizontal"> <FieldLabel htmlFor="rate" className="tw:w-1/2"> Rate </FieldLabel> <Input id="rate" defaultValue="180" /> </Field> <Field orientation="horizontal"> <FieldLabel htmlFor="unit" className="tw:w-1/2"> Unit </FieldLabel> <Input id="unit" defaultValue="lb/acre" /> </Field> </FieldGroup> </PopoverContent> </Popover> </> );}Popover
Section titled “Popover”Groups a popover’s parts without rendering an HTML element.
children
Section titled “children”children?: React.ReactNodeThe popover’s parts.
defaultOpen
Section titled “defaultOpen”defaultOpen?: booleanWhether the popover is initially open. Defaults to false.
defaultTriggerId
Section titled “defaultTriggerId”defaultTriggerId?: string | nullID of the trigger associated with an initially open popover.
modal?: boolean | "trap-focus"Whether opening the popover limits interaction outside it. Defaults to
false.
onOpenChange
Section titled “onOpenChange”onOpenChange?: ((open: boolean, eventDetails: PopoverPrimitive.Root.ChangeEventDetails) => void)Event handler called when the popover is opened or closed.
onOpenChangeComplete
Section titled “onOpenChangeComplete”onOpenChangeComplete?: ((open: boolean) => void)Event handler called after popover animations complete.
open?: booleanWhether the popover is currently open.
triggerId
Section titled “triggerId”triggerId?: string | nullID of the trigger associated with a controlled popover.
PopoverContent
Section titled “PopoverContent”Includes a portal and positioned popover. Renders a <div> element by
default and accepts standard <div> props. Use it with PopoverTitle and
PopoverDescription to give it an accessible name and description.
align?: Align = "center"The alignment of the popover relative to its trigger. Defaults to
"center".
alignOffset
Section titled “alignOffset”alignOffset?: number | OffsetFunction = 0The offset from the aligned position, in pixels. Defaults to 0.
className
Section titled “className”className?: stringCSS class applied to the popover.
finalFocus
Section titled “finalFocus”finalFocus?: boolean | React.RefObject<HTMLElement | null> | ((closeType: InteractionType) => void | boolean | HTMLElement | null)Determines the element to focus when the popover is closed.
initialFocus
Section titled “initialFocus”initialFocus?: boolean | React.RefObject<HTMLElement | null> | ((openType: InteractionType) => void | boolean | HTMLElement | null)Determines the element to focus when the popover is opened.
render
Section titled “render”render?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, PopoverPopupState>Allows replacing the popover element or composing it with another component.
side?: Side = "bottom"The side of the trigger where the popover is placed. Defaults to
"bottom".
sideOffset
Section titled “sideOffset”sideOffset?: number | OffsetFunction = 4The offset from the trigger, in pixels. Defaults to 4.
style?: React.CSSProperties | ((state: PopoverPopupState) => React.CSSProperties | undefined)Style applied to the popover, or a function based on its state.
PopoverDescription
Section titled “PopoverDescription”Provides the popover’s accessible description. Renders a <p> element by
default and accepts standard <p> props.
className
Section titled “className”className?: stringCSS class applied to the popover description.
render
Section titled “render”render?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, PopoverDescriptionState>Allows replacing the description element or composing it with another component.
style?: React.CSSProperties | ((state: PopoverDescriptionState) => React.CSSProperties | undefined)Style applied to the popover description, or a function based on its state.
PopoverHeader
Section titled “PopoverHeader”Groups PopoverTitle and PopoverDescription. Renders a <div> element and
accepts standard <div> props.
PopoverTitle
Section titled “PopoverTitle”Provides the popover’s accessible name. Renders an <h2> element by default
and accepts standard heading props.
className
Section titled “className”className?: stringCSS class applied to the popover title.
render
Section titled “render”render?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, PopoverTitleState>Allows replacing the title element or composing it with another component.
style?: React.CSSProperties | ((state: PopoverTitleState) => React.CSSProperties | undefined)Style applied to the popover title, or a function based on its state.
PopoverTrigger
Section titled “PopoverTrigger”Opens the associated popover. Renders a <button> element by default and
accepts standard <button> props.
className
Section titled “className”className?: string | ((state: PopoverTriggerState) => string | undefined)CSS class applied to the trigger, or a function based on its state.
closeDelay
Section titled “closeDelay”closeDelay?: numberHow long to wait before closing a hover-opened popover, in milliseconds.
Defaults to 0.
delay?: numberHow long to wait before opening the popover on hover, in milliseconds.
Defaults to 300.
id?: stringID used to identify the active trigger in controlled mode.
nativeButton
Section titled “nativeButton”nativeButton?: booleanWhether render produces a native <button> element. Defaults to true.
openOnHover
Section titled “openOnHover”openOnHover?: booleanWhether hovering the trigger also opens the popover. Defaults to false.
render
Section titled “render”render?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, PopoverTriggerState>Allows replacing the trigger element or composing it with another component.
style?: React.CSSProperties | ((state: PopoverTriggerState) => React.CSSProperties | undefined)Style applied to the trigger, or a function based on its state.