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.

38 lines (37 loc) 1.26 kB
'use client'; import * as React from 'react'; import { useIsoLayoutEffect } from '@base-ui-components/utils/useIsoLayoutEffect'; import { useAlertDialogRootContext } from "../root/AlertDialogRootContext.js"; import { useRenderElement } from "../../utils/useRenderElement.js"; import { useBaseUiId } from "../../utils/useBaseUiId.js"; /** * A paragraph with additional information about the alert dialog. * Renders a `<p>` element. * * Documentation: [Base UI Alert Dialog](https://base-ui.com/react/components/alert-dialog) */ export const AlertDialogDescription = /*#__PURE__*/React.forwardRef(function AlertDialogDescription(componentProps, forwardedRef) { const { render, className, id: idProp, ...elementProps } = componentProps; const { setDescriptionElementId } = useAlertDialogRootContext(); const id = useBaseUiId(idProp); useIsoLayoutEffect(() => { setDescriptionElementId(id); return () => { setDescriptionElementId(undefined); }; }, [id, setDescriptionElementId]); return useRenderElement('p', componentProps, { ref: forwardedRef, props: [{ id }, elementProps] }); }); if (process.env.NODE_ENV !== "production") AlertDialogDescription.displayName = "AlertDialogDescription";