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.

56 lines (55 loc) 2.15 kB
import type { GenericHTMLProps } from '../utils/types.js'; export declare function useToggleGroup(parameters: UseToggleGroup.Parameters): UseToggleGroup.ReturnValue; export type ToggleGroupOrientation = 'horizontal' | 'vertical'; export declare namespace UseToggleGroup { interface Parameters { /** * The open state of the ToggleGroup represented by an array of * the values of all pressed `<ToggleGroup.Item/>`s * This is the controlled counterpart of `defaultValue`. */ value?: readonly any[]; /** * The open state of the ToggleGroup represented by an array of * the values of all pressed `<ToggleGroup.Item/>`s. * This is the uncontrolled counterpart of `value`. */ defaultValue?: readonly any[]; /** * Callback fired when the pressed states of the ToggleGroup changes. * * @param {any[]} groupValue An array of the `value`s of all the pressed items. * @param {Event} event The corresponding event that initiated the change. */ onValueChange: (groupValue: any[], event: Event) => void; /** * Whether the component should ignore user interaction. * @default false */ disabled: boolean; /** * When `false` only one item in the group can be pressed. If any item in * the group becomes pressed, the others will become unpressed. * When `true` multiple items can be pressed. * @default false */ toggleMultiple: boolean; } interface ReturnValue { getRootProps: (externalProps?: GenericHTMLProps) => GenericHTMLProps; /** * Whether the component should ignore user interaction. * @default false */ disabled: boolean; /** * */ setGroupValue: (newValue: string, nextPressed: boolean, event: Event) => void; /** * The value of the ToggleGroup represented by an array of values * of the items that are pressed. */ value: readonly any[]; } }