@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.
25 lines • 1 kB
TypeScript
import * as React from 'react';
export declare function useLabel(params?: UseLabelParameters): UseLabelReturnValue;
export interface UseLabelParameters {
id?: string | undefined;
/**
* Control id used when no labelable context control id exists.
*/
fallbackControlId?: string | null | undefined;
/**
* Whether the rendered element is a native `<label>`.
* @default false
*/
native?: boolean | undefined;
/**
* Additional callback to sync the current label id with local component state/store.
*/
setLabelId?: ((nextLabelId: string | undefined) => void) | undefined;
/**
* Custom focus handler for non-native labels.
* If omitted, focus behavior targets the resolved control id.
*/
focusControl?: ((event: React.MouseEvent, controlId: string | null | undefined) => void) | undefined;
}
export type UseLabelReturnValue = React.HTMLAttributes<any> & React.LabelHTMLAttributes<any>;
export declare function focusElementWithVisible(element: HTMLElement): void;