Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/hot-owls-sniff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nextui-org/alert": patch
---

propagate className (#4533)
9 changes: 6 additions & 3 deletions packages/components/alert/src/use-alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"> {
/**
Expand Down Expand Up @@ -103,6 +103,7 @@ export function useAlert(originalProps: UseAlertProps) {
closeButtonProps = {
size: "sm",
},
className,
classNames,
...otherProps
} = props;
Expand All @@ -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)],
Expand All @@ -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<PropGetter>(() => {
return {
Expand Down