import { UseScrollAreaReturn } from '@chakra-ui/react/scroll-area'; import { HTMLChakraProps, SlotRecipeProps, UnstyledProp } from '@chakra-ui/react/styled-system'; import { OmitInternalProps } from '../../type-utils/omit-props'; /** * Recipe props for the ScrollArea component. * Inferred from the slot recipe to enable responsive values. */ type ScrollAreaRecipeProps = { /** * Scrollbar visibility variant. * - `hover`: scrollbar appears on hover or during active scrolling (default) * - `always`: scrollbar is permanently visible * @default "hover" */ variant?: SlotRecipeProps<"scrollArea">["variant"]; /** * Scrollbar thickness. * @default "sm" */ size?: SlotRecipeProps<"scrollArea">["size"]; } & UnstyledProp; type ScrollAreaRootSlotProps = HTMLChakraProps<"div", ScrollAreaRecipeProps>; /** * Style props that would collide with ScrollArea's internal overflow control. * The root has `overflow: hidden` from the recipe, the viewport owns * `overflow: auto` / axis clipping, and `orientation` drives the strict * clipping — consumers setting these would silently break scroll behavior. */ type ConflictingProps = "overflow" | "overflowX" | "overflowY"; /** Props for the `ScrollArea` component. */ export type ScrollAreaProps = Omit, ConflictingProps> & { /** Content to render inside the scrollable area. */ children: React.ReactNode; /** * The HTML element type to render the root as. */ as?: React.ElementType; /** A ref to the root scroll area element. */ ref?: React.Ref; /** A ref to the scrollable viewport element inside the scroll area. */ viewportRef?: React.Ref; /** * Which scrollbar axes to render. * * When set to `"vertical"` or `"horizontal"`, the opposite axis is actively * suppressed: Zag's inline `min-width: fit-content` (or `min-height`) is * overridden on the content slot and the viewport clips the other axis. * This prevents silent overflow with no visible scrollbar indicator. * @default "both" */ orientation?: "vertical" | "horizontal" | "both"; /** * An externally created scroll area machine (from `useScrollArea`). * When provided, the component uses `RootProvider` instead of `Root`, * allowing external access to scroll state and programmatic control. */ value?: UseScrollAreaReturn; /** * Scrollbar visibility variant. * - `hover`: scrollbar appears on hover or during active scrolling (default) * - `always`: scrollbar is permanently visible * @default "hover" */ variant?: ScrollAreaRecipeProps["variant"]; /** * Scrollbar thickness. * @default "sm" */ size?: ScrollAreaRecipeProps["size"]; /** * Custom element IDs for ScrollArea's internal parts. * Use when you need DOM access via `getElementById` (e.g., * `ids={{ viewport: 'my-viewport' }}`). * * Only `root`, `viewport`, and `content` are honored by the underlying * state machine. Scrollbar and thumb elements are located by data * attributes and cannot be renamed via ids. */ ids?: Partial<{ root: string; viewport: string; content: string; }>; }; /** * Custom element IDs for ScrollArea's internal parts. * Pass to the `ids` prop to set known IDs for DOM access. */ export type ScrollAreaElementIds = Partial<{ root: string; viewport: string; content: string; }>; export {};