@base-ui/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.
49 lines • 1.66 kB
TypeScript
import type { ElementProps, FloatingContext, FloatingRootContext } from "../types.js";
import { REASONS } from "../../utils/reasons.js";
export interface UseClickProps {
/**
* Whether the Hook is enabled, including all internal Effects and event
* handlers.
* @default true
*/
enabled?: boolean | undefined;
/**
* The type of event to use to determine a “click” with mouse input.
* Keyboard clicks work as normal.
* @default 'click'
*/
event?: ('click' | 'mousedown' | 'mousedown-only') | undefined;
/**
* Whether to toggle the open state with repeated clicks.
* @default true
*/
toggle?: boolean | undefined;
/**
* Whether to ignore the logic for mouse input (for example, if `useHover()`
* is also being used).
* @default false
*/
ignoreMouse?: boolean | undefined;
/**
* If already open from another event such as the `useHover()` Hook,
* determines whether to keep the floating element open when clicking the
* reference element for the first time.
* @default true
*/
stickIfOpen?: boolean | undefined;
/**
* Touch-only delay (ms) before opening. Useful to allow mobile viewport/keyboard to settle.
* @default 0
*/
touchOpenDelay?: number | undefined;
/**
* The reason for the click.
* @default REASONS.triggerPress
*/
reason?: (typeof REASONS.triggerPress | typeof REASONS.inputPress) | undefined;
}
/**
* Opens or closes the floating element when clicking the reference element.
* @see https://floating-ui.com/docs/useClick
*/
export declare function useClick(context: FloatingRootContext | FloatingContext, props?: UseClickProps): ElementProps;