diff --git a/.changeset/hot-owls-sniff.md b/.changeset/hot-owls-sniff.md new file mode 100644 index 0000000000..2c713d7975 --- /dev/null +++ b/.changeset/hot-owls-sniff.md @@ -0,0 +1,5 @@ +--- +"@nextui-org/alert": patch +--- + +propagate className (#4533) diff --git a/packages/components/alert/src/use-alert.ts b/packages/components/alert/src/use-alert.ts index 5c24fd1e03..44ce645a37 100644 --- a/packages/components/alert/src/use-alert.ts +++ b/packages/components/alert/src/use-alert.ts @@ -7,7 +7,7 @@ import {ReactNode, useCallback, useMemo} from "react"; import {mergeProps} from "@react-aria/utils"; import {alert} from "@nextui-org/theme"; import {useControlledState} from "@react-stately/utils"; -import {dataAttr, isEmpty, objectToDeps} from "@nextui-org/shared-utils"; +import {clsx, dataAttr, isEmpty, objectToDeps} from "@nextui-org/shared-utils"; interface Props extends HTMLNextUIProps<"div"> { /** @@ -103,6 +103,7 @@ export function useAlert(originalProps: UseAlertProps) { closeButtonProps = { size: "sm", }, + className, classNames, ...otherProps } = props; @@ -123,6 +124,8 @@ export function useAlert(originalProps: UseAlertProps) { onClose?.(); }, [setIsVisible, onClose]); + const baseStyles = clsx(classNames?.base, className); + const slots = useMemo( () => alert({hasContent: !isEmpty(description) || !isEmpty(children), ...variantProps}), [description, objectToDeps(variantProps)], @@ -140,9 +143,9 @@ export function useAlert(originalProps: UseAlertProps) { }), filterDOMProps(props), ), - className: slots.base({class: classNames?.base}), + className: slots.base({class: baseStyles}), }; - }, [slots, classNames?.base]); + }, [slots, baseStyles]); const getMainWrapperProps = useCallback(() => { return {