@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.
80 lines (79 loc) • 2.63 kB
TypeScript
import { type TransitionStatus } from '../../utils/index.js';
import type { SelectRootContext } from './SelectRootContext.js';
import type { SelectIndexContext } from './SelectIndexContext.js';
export declare function useSelectRoot<T>(params: useSelectRoot.Parameters<T>): useSelectRoot.ReturnValue;
export declare namespace useSelectRoot {
interface Parameters<Value> {
/**
* Identifies the field when a form is submitted.
*/
name?: string;
/**
* The id of the Select.
*/
id?: string;
/**
* Whether the user must choose a value before submitting a form.
* @default false
*/
required?: boolean;
/**
* Whether the user should be unable to choose a different option from the select menu.
* @default false
*/
readOnly?: boolean;
/**
* Whether the component should ignore user interaction.
* @default false
*/
disabled?: boolean;
/**
* The value of the select.
*/
value?: Value | null;
/**
* Callback fired when the value of the select changes. Use when controlled.
*/
onValueChange?: (value: Value, event?: Event) => void;
/**
* The uncontrolled value of the select when it’s initially rendered.
*
* To render a controlled select, use the `value` prop instead.
* @default null
*/
defaultValue?: Value | null;
/**
* Whether the select menu is initially open.
*
* To render a controlled select menu, use the `open` prop instead.
* @default false
*/
defaultOpen?: boolean;
/**
* Event handler called when the select menu is opened or closed.
*/
onOpenChange?: (open: boolean, event: Event | undefined) => void;
/**
* Whether the select menu is currently open.
*/
open?: boolean;
/**
* Determines if the selected item inside the popup should align to the trigger element.
* @default true
*/
alignItemToTrigger?: boolean;
/**
* The transition status of the Select.
*/
transitionStatus?: TransitionStatus;
/**
* Whether the select should prevent outside clicks and lock page scroll when open.
* @default true
*/
modal?: boolean;
}
interface ReturnValue {
rootContext: SelectRootContext;
indexContext: SelectIndexContext;
}
}