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.19 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 heading that labels the dialog. * Renders an `<h2>` element. * * Documentation: [Base UI Alert Dialog](https://base-ui.com/react/components/alert-dialog) */ export const AlertDialogTitle = /*#__PURE__*/React.forwardRef(function AlertDialogTitle(componentProps, forwardedRef) { const { render, className, id: idProp, ...elementProps } = componentProps; const { setTitleElementId } = useAlertDialogRootContext(); const id = useBaseUiId(idProp); useIsoLayoutEffect(() => { setTitleElementId(id); return () => { setTitleElementId(undefined); }; }, [id, setTitleElementId]); return useRenderElement('h2', componentProps, { ref: forwardedRef, props: [{ id }, elementProps] }); }); if (process.env.NODE_ENV !== "production") AlertDialogTitle.displayName = "AlertDialogTitle";