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/bright-dropdown-icons.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cloudflare/kumo": patch
---

Apply dropdown icon spacing and sizing to element icons while preserving their custom classes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
GearIcon,
BookOpenIcon,
ArrowSquareOutIcon,
ArrowsClockwiseIcon,
CopyIcon,
PencilSimpleIcon,
TrashIcon,
Expand Down Expand Up @@ -192,6 +193,12 @@ export function DropdownOnClickDemo() {
>
Rename
</DropdownMenu.Item>
<DropdownMenu.Item
icon={<ArrowsClockwiseIcon className="animate-spin" />}
onClick={() => setLastAction("Refreshed")}
>
Refresh
</DropdownMenu.Item>
<DropdownMenu.Separator />
<DropdownMenu.Item
icon={TrashIcon}
Expand Down
6 changes: 5 additions & 1 deletion packages/kumo/src/components/dropdown/dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ const DropdownMenuContent = React.forwardRef<

const renderIconNode = (IconComponent?: Icon | React.ReactNode) => {
if (!IconComponent) return null;
if (React.isValidElement(IconComponent)) return IconComponent;
if (React.isValidElement<{ className?: string }>(IconComponent)) {
return React.cloneElement(IconComponent, {
className: cn("mr-2 h-4 w-4", IconComponent.props.className),
});
}
const Comp = IconComponent as React.ComponentType<Record<string, unknown>>;
return <Comp className="mr-2 h-4 w-4" />;
};
Expand Down
Loading