@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.
43 lines • 1.38 kB
TypeScript
import type { ElementProps, FloatingContext, FloatingRootContext } from "../types.js";
export interface UseClickProps {
/**
* Whether the Hook is enabled, including all internal Effects and event
* handlers.
* @default true
*/
enabled?: boolean;
/**
* 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';
/**
* Whether to toggle the open state with repeated clicks.
* @default true
*/
toggle?: boolean;
/**
* Whether to ignore the logic for mouse input (for example, if `useHover()`
* is also being used).
* @default false
*/
ignoreMouse?: boolean;
/**
* 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;
/**
* Touch-only delay (ms) before opening. Useful to allow mobile viewport/keyboard to settle.
* @default 0
*/
touchOpenDelay?: number;
}
/**
* 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;