@renderlesskit/react
Version:
Collection of headless components/hooks that are accessible, composable, customizable from low level to build your own UI & Design System powered by Reakit
43 lines (42 loc) • 1.24 kB
TypeScript
import * as React from "react";
import { unstable_IdActions, unstable_IdInitialState, unstable_IdState } from "reakit";
export declare type DisclosureState = unstable_IdState & {
/**
* Whether it's expanded or not.
*/
visible: boolean;
};
export declare type DisclosureActions = unstable_IdActions & {
/**
* Changes the `expanded` state to `true`
*/
show: () => void;
/**
* Changes the `expanded` state to `false`
*/
hide: () => void;
/**
* Toggles the `expanded` state
*/
toggle: () => void;
/**
* Sets `expanded`.
*/
setVisible: React.Dispatch<React.SetStateAction<DisclosureState["visible"]>>;
};
export declare type DisclosureStateReturn = DisclosureState & DisclosureActions;
export declare type DisclosureInitialState = unstable_IdInitialState & Partial<Pick<DisclosureState, "visible">> & {
/**
* Default uncontrolled state.
*/
defaultVisible?: boolean;
/**
* Controllabele state.
*/
visible?: boolean;
/**
* controllable state callback.
*/
onVisibleChange?: (expanded: boolean) => void;
};
export declare const useDisclosureState: (props?: DisclosureInitialState) => DisclosureStateReturn;