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.

41 lines (39 loc) 1.12 kB
'use client'; import * as React from 'react'; import { useToastPositionerContext } from "../positioner/ToastPositionerContext.js"; import { useRenderElement } from "../../utils/useRenderElement.js"; /** * Displays an element positioned against the toast anchor. * Renders a `<div>` element. * * Documentation: [Base UI Toast](https://base-ui.com/react/components/toast) */ export const ToastArrow = /*#__PURE__*/React.forwardRef(function ToastArrow(componentProps, forwardedRef) { const { className, render, ...elementProps } = componentProps; const { arrowRef, side, align, arrowUncentered, arrowStyles } = useToastPositionerContext(); const state = React.useMemo(() => ({ side, align, uncentered: arrowUncentered }), [side, align, arrowUncentered]); const element = useRenderElement('div', componentProps, { state, ref: [forwardedRef, arrowRef], props: [{ style: arrowStyles, 'aria-hidden': true }, elementProps] }); return element; }); if (process.env.NODE_ENV !== "production") ToastArrow.displayName = "ToastArrow";