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.

53 lines 2.07 kB
import * as React from 'react'; import type { FieldRoot } from "../field/root/FieldRoot.js"; import type { BaseUIComponentProps } from "../utils/types.js"; import type { BaseUIChangeEventDetails } from "../utils/createBaseUIEventDetails.js"; import { REASONS } from "../utils/reasons.js"; /** * Provides a shared state to a series of checkboxes. * * Documentation: [Base UI Checkbox Group](https://base-ui.com/react/components/checkbox-group) */ export declare const CheckboxGroup: React.ForwardRefExoticComponent<CheckboxGroupProps & React.RefAttributes<HTMLDivElement>>; export interface CheckboxGroupState extends FieldRoot.State { /** * Whether the component should ignore user interaction. */ disabled: boolean; } export interface CheckboxGroupProps extends BaseUIComponentProps<'div', CheckboxGroup.State> { /** * Names of the checkboxes in the group that should be ticked. * * To render an uncontrolled checkbox group, use the `defaultValue` prop instead. */ value?: string[]; /** * Names of the checkboxes in the group that should be initially ticked. * * To render a controlled checkbox group, use the `value` prop instead. */ defaultValue?: string[]; /** * Event handler called when a checkbox in the group is ticked or unticked. * Provides the new value as an argument. */ onValueChange?: (value: string[], eventDetails: CheckboxGroupChangeEventDetails) => void; /** * Names of all checkboxes in the group. Use this when creating a parent checkbox. */ allValues?: string[]; /** * Whether the component should ignore user interaction. * @default false */ disabled?: boolean; } export type CheckboxGroupChangeEventReason = typeof REASONS.none; export type CheckboxGroupChangeEventDetails = BaseUIChangeEventDetails<CheckboxGroup.ChangeEventReason>; export declare namespace CheckboxGroup { type State = CheckboxGroupState; type Props = CheckboxGroupProps; type ChangeEventReason = CheckboxGroupChangeEventReason; type ChangeEventDetails = CheckboxGroupChangeEventDetails; }