UNPKG

@base-ui-components/react

Version:

Base UI is a library of headless ('unstyled') React components and low-level hooks. You gain complete control over your app's CSS and accessibility features.

69 lines 2.19 kB
import * as React from 'react'; import type { BaseUIComponentProps, NativeButtonProps } from "../../utils/types.js"; import { PopoverHandle } from "../store/PopoverHandle.js"; /** * A button that opens the popover. * Renders a `<button>` element. * * Documentation: [Base UI Popover](https://base-ui.com/react/components/popover) */ export declare const PopoverTrigger: PopoverTrigger; export interface PopoverTrigger { <Payload>(componentProps: PopoverTriggerProps<Payload> & React.RefAttributes<HTMLElement>): React.JSX.Element; } export interface PopoverTriggerState { /** * Whether the popover is currently disabled. */ disabled: boolean; /** * Whether the popover is currently open. */ open: boolean; } export type PopoverTriggerProps<Payload = unknown> = NativeButtonProps & BaseUIComponentProps<'button', PopoverTriggerState> & { /** * Whether the component renders a native `<button>` element when replacing it * via the `render` prop. * Set to `false` if the rendered element is not a button (e.g. `<div>`). * @default true */ nativeButton?: boolean; /** * A handle to associate the trigger with a popover. */ handle?: PopoverHandle<Payload>; /** * A payload to pass to the popover when it is opened. */ payload?: Payload; /** * ID of the trigger. In addition to being forwarded to the rendered element, * it is also used to specify the active trigger for the popover in controlled mode (with the PopoverRoot `triggerId` prop). */ id?: string; /** * Whether the popover should also open when the trigger is hovered. * @default false */ openOnHover?: boolean; /** * How long to wait before the popover may be opened on hover. Specified in milliseconds. * * Requires the `openOnHover` prop. * @default 300 */ delay?: number; /** * How long to wait before closing the popover that was opened on hover. * Specified in milliseconds. * * Requires the `openOnHover` prop. * @default 0 */ closeDelay?: number; }; export declare namespace PopoverTrigger { type State = PopoverTriggerState; type Props<Payload = unknown> = PopoverTriggerProps<Payload>; }