@react-md/divider
Version:
This package is used to create horizontal or vertical dividers in your application.
38 lines (37 loc) • 1.55 kB
TypeScript
import type { CSSProperties, Ref, RefCallback } from "react";
/** @remarks \@since 5.0.0 */
export interface VerticalDividerHookOptions<E extends HTMLElement> {
/**
* An optional ref to merge with the returned ref.
*/
ref?: Ref<E>;
/**
* An optional style object to merge with the divider's height style.
*/
style?: CSSProperties;
/**
* The max height for the vertical divider. When this is `<= 0`, the hook will
* be disabled.
*
* When the value is between 0 and 1, it will be used as a multiplier with the
* parent element's height. When the value is greater than 1, it will be used
* in `Math.min(parentElementHeight, maxHeight)`.
*/
maxHeight: number;
}
/** @remarks \@since 5.0.0 */
export interface VerticalDividerHeight<E extends HTMLElement> {
ref: RefCallback<E>;
style: CSSProperties | undefined;
}
/**
* This is a small hook that is used to automatically create a vertical divider
* based on the computed height of its parent element.
*
* @param maxHeight - The max height for the vertical divider. When the value is
* between 0 and 1, it will be used as a percentage. Otherwise the smaller value
* of parent element height and this will be used.
* @remarks \@since 5.0.0 The hook accepts an object instead of using multiple
* params and uses a generic for the HTMLElement type.
*/
export declare function useVerticalDividerHeight<E extends HTMLElement>({ ref, style, maxHeight, }: VerticalDividerHookOptions<E>): VerticalDividerHeight<E>;