-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SVG Icons: Unable to Supply <defs> Element #4489
Comments
@joncursi The pre-built icons don't currently support children, as the path for the icon itself is the import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionStars = (props) => (
<SvgIcon {...props}>
<path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zm4.24 16L12 15.45 7.77 18l1.12-4.81-3.73-3.23 4.92-.42L12 5l1.92 4.53 4.92.42-3.73 3.23L16.23 18z"/>
</SvgIcon>
);
ActionStars = pure(ActionStars);
ActionStars.displayName = 'ActionStars';
ActionStars.muiName = 'SvgIcon';
export default ActionStars; |
@joncursi If the prebuilt SvgIcons supported defs as children, how would you apply them to the built-in SVG paths? |
@mbrookes I was looking to apply a linear gradient over the SVG path rather than a solid color. CSS can't do this alone, it requires DOM elements be defined like this: http://www.w3schools.com/svg/svg_grad_linear.asp The fill name can then either be passed in as an additional prop, or specified to be used in CSS. |
@joncursi The problem is that some icons have multiple paths (or other elements |
Requiring that SvgIcons embed the raw source of an SVG instead of some way to link or load from an external source is rather limiting. Creating these in TypeScript, you can't embed an icon-specific |
We have 3 paths going forward:
Option 1 or 3 sounds like the best ones to me. |
@dustingraves People can already do that with Material-UI. I don't follow. |
I didn't read the original problem fully... I will remove my comment to keep the issue clean |
Actually, I think that we have an even better solution to the problem. We can make the |
Although the SVG font icons support a
children
prop, I am unable to pass in adefs
element to define a custom linear gradient. I.e.:The icon renders without the
defs
element.The text was updated successfully, but these errors were encountered: