Skip to content

Commit 8463c38

Browse files
fix(toast): use Button for close control (#600)
1 parent 4dd1398 commit 8463c38

2 files changed

Lines changed: 28 additions & 7 deletions

File tree

.changeset/bright-toasts-close.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cloudflare/kumo": patch
3+
---
4+
5+
Use the Button component for Toast close controls and match the hover tint to the toast variant.

packages/kumo/src/components/toast/toast.tsx

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ export const KUMO_TOAST_VARIANTS = {
3939
},
4040
close: {
4141
classes:
42-
"absolute top-2 right-2 flex h-5 w-5 items-center justify-center rounded bg-transparent text-kumo-subtle hover:bg-kumo-fill-hover hover:text-kumo-default",
43-
description: "Close button with X icon",
42+
"absolute top-2 right-2 size-5 rounded text-kumo-subtle hover:bg-current/15",
43+
description: "Button-based close control with variant-aware hover tint",
4444
},
4545
variant: {
4646
default: {
@@ -383,18 +383,34 @@ function ToastList() {
383383
</>
384384
)}
385385
<Toast.Close
386-
data-kumo-component="Toast"
387386
data-kumo-part="close"
388-
className="absolute top-2 right-2 flex h-4 w-4 items-center justify-center rounded border-none bg-transparent text-current hover:bg-kumo-contrast/10 hover:text-current"
389387
aria-label="Close"
390-
>
391-
<XIcon className="h-3 w-3" />
392-
</Toast.Close>
388+
render={
389+
<Button
390+
variant="ghost"
391+
size="sm"
392+
shape="square"
393+
aria-label="Close"
394+
className={cn(
395+
"absolute top-2 right-2 size-5 rounded text-kumo-subtle hover:bg-current/15",
396+
toast.variant && TOAST_CLOSE_CLASSES[toast.variant],
397+
)}
398+
icon={<XIcon className="h-3 w-3" />}
399+
/>
400+
}
401+
/>
393402
</Toast.Content>
394403
</Toast.Root>
395404
));
396405
}
397406

407+
const TOAST_CLOSE_CLASSES: Record<string, string> = {
408+
success: "text-kumo-success",
409+
error: "text-kumo-danger",
410+
warning: "text-kumo-warning",
411+
info: "text-kumo-info",
412+
};
413+
398414
const TOAST_BACKGROUND_CLASSES: Record<string, string> = {
399415
success: "bg-kumo-success-tint/20",
400416
error: "bg-kumo-danger-tint/30",

0 commit comments

Comments
 (0)