diff --git a/packages/lucide-solid/src/Icon.tsx b/packages/lucide-solid/src/Icon.tsx
index 087fc8fd9..72f91f68d 100644
--- a/packages/lucide-solid/src/Icon.tsx
+++ b/packages/lucide-solid/src/Icon.tsx
@@ -49,25 +49,25 @@ const Icon = (props: LucideProps & IconProps) => {
absoluteStrokeWidth: localProps.absoluteStrokeWidth ?? globalProps.absoluteStrokeWidth,
nonScalingStroke: localProps.nonScalingStroke ?? globalProps.nonScalingStroke,
className: mergeClasses('lucide-icon', globalProps.class, localProps.class),
- hasA11yProp: Boolean(localProps.children) || hasA11yProp(rest),
+ hasA11yProp: hasA11yProp(rest),
attributes: rest,
}),
);
- return (
-
+ const paths = (
+
+ {([elementName, attrs]) => {
+ return (
+
+ );
+ }}
+
);
+
+ return ;
};
export default Icon;
diff --git a/packages/lucide-solid/tests/Icon.spec.tsx b/packages/lucide-solid/tests/Icon.spec.tsx
index cf69de5d4..d84125b84 100644
--- a/packages/lucide-solid/tests/Icon.spec.tsx
+++ b/packages/lucide-solid/tests/Icon.spec.tsx
@@ -122,19 +122,45 @@ describe('Icon Component Accessibility', () => {
expect(container.firstChild).not.toHaveAttribute('aria-hidden');
});
- it('should not have aria-hidden prop when there are children that could be a
element', async () => {
+ it('should render a labelled title child and not have aria-hidden prop', async () => {
const { container } = render(() => (
- Some title
+ Warning: Action cannot be undone
));
expect(container.firstChild).not.toHaveAttribute('aria-hidden');
+ expect(container.firstChild).toHaveAttribute('role', 'img');
+ expect(container.firstChild).toHaveAttribute('aria-labelledby', 'warn-title');
+ expect(container.querySelector('title#warn-title')).toHaveTextContent(
+ 'Warning: Action cannot be undone',
+ );
+ });
+
+ it('should update reactive children', async () => {
+ const [showTitle, setShowTitle] = createSignal(false);
+ const { container } = render(() => (
+
+ {showTitle() && Dynamic title}
+
+ ));
+
+ expect(container.querySelector('title')).toBeNull();
+
+ setShowTitle(true);
+
+ expect(container.querySelector('title#dynamic-title')).toHaveTextContent('Dynamic title');
});
it('should never override aria-hidden prop', async () => {
diff --git a/packages/lucide-solid/tests/lucide-solid.spec.tsx b/packages/lucide-solid/tests/lucide-solid.spec.tsx
index 1421dd034..2caf934d9 100644
--- a/packages/lucide-solid/tests/lucide-solid.spec.tsx
+++ b/packages/lucide-solid/tests/lucide-solid.spec.tsx
@@ -87,4 +87,19 @@ describe('Using lucide icon components', () => {
expect(container.firstChild).toHaveClass('lucide');
expect(container.firstChild).toHaveClass('lucide-droplet');
});
+
+ it('should render child elements inside icon components', () => {
+ const { container } = render(() => (
+
+ Water droplet
+
+ ));
+
+ expect(container.firstChild).not.toHaveAttribute('aria-hidden');
+ expect(container.firstChild).toHaveAttribute('aria-labelledby', 'droplet-title');
+ expect(container.querySelector('title#droplet-title')).toHaveTextContent('Water droplet');
+ });
});
diff --git a/packages/solid/src/Icon.tsx b/packages/solid/src/Icon.tsx
index dd4019c69..c15308054 100644
--- a/packages/solid/src/Icon.tsx
+++ b/packages/solid/src/Icon.tsx
@@ -51,25 +51,25 @@ const Icon = (props: LucideProps & IconProps) => {
absoluteStrokeWidth: props.absoluteStrokeWidth ?? globalProps.absoluteStrokeWidth,
nonScalingStroke: props.nonScalingStroke ?? globalProps.nonScalingStroke,
className: mergeClasses('lucide-icon', globalProps.class, props.class),
- hasA11yProp: Boolean(props.children) || hasA11yProp(rest()),
+ hasA11yProp: hasA11yProp(rest()),
attributes: rest(),
}),
);
- return (
-
+ const paths = (
+
+ {([elementName, attrs]) => {
+ return (
+
+ );
+ }}
+
);
+
+ return ;
};
export default Icon;
diff --git a/packages/solid/tests/Icon.spec.tsx b/packages/solid/tests/Icon.spec.tsx
index 500bcff23..9eaa4c36e 100644
--- a/packages/solid/tests/Icon.spec.tsx
+++ b/packages/solid/tests/Icon.spec.tsx
@@ -123,19 +123,46 @@ describe('Icon Component Accessibility', () => {
expect(container.firstChild).not.toHaveAttribute('aria-hidden');
});
- it('should not have aria-hidden prop when there are children that could be a element', async () => {
+ it('should render a labelled title child and not have aria-hidden prop', async () => {
const { container } = render(() => (
- Some title
+ Warning: Action cannot be undone
));
expect(container.firstChild).not.toHaveAttribute('aria-hidden');
+ expect(container.firstChild).toHaveAttribute('role', 'img');
+ expect(container.firstChild).toHaveAttribute('aria-labelledby', 'warn-title');
+ expect(container.querySelector('title#warn-title')).toHaveTextContent(
+ 'Warning: Action cannot be undone',
+ );
+ });
+
+ it('should update reactive children', async () => {
+ const [showTitle, setShowTitle] = createSignal(false);
+ const { container } = render(() => (
+
+ {showTitle() && Dynamic title}
+
+ ));
+
+ expect(container.querySelector('title')).toBeNull();
+
+ setShowTitle(true);
+ flush();
+
+ expect(container.querySelector('title#dynamic-title')).toHaveTextContent('Dynamic title');
});
it('should never override aria-hidden prop', async () => {
diff --git a/packages/solid/tests/lucide-solid.spec.tsx b/packages/solid/tests/lucide-solid.spec.tsx
index 1421dd034..2caf934d9 100644
--- a/packages/solid/tests/lucide-solid.spec.tsx
+++ b/packages/solid/tests/lucide-solid.spec.tsx
@@ -87,4 +87,19 @@ describe('Using lucide icon components', () => {
expect(container.firstChild).toHaveClass('lucide');
expect(container.firstChild).toHaveClass('lucide-droplet');
});
+
+ it('should render child elements inside icon components', () => {
+ const { container } = render(() => (
+
+ Water droplet
+
+ ));
+
+ expect(container.firstChild).not.toHaveAttribute('aria-hidden');
+ expect(container.firstChild).toHaveAttribute('aria-labelledby', 'droplet-title');
+ expect(container.querySelector('title#droplet-title')).toHaveTextContent('Water droplet');
+ });
});