Replies: 3 comments 3 replies
-
Icon Library Management
Here is one article, but we still need more clarity. |
Beta Was this translation helpful? Give feedback.
-
@shivamvijaywargi , please read this article. https://benadam.me/thoughts/react-svg-sprites/ I think we can go with 3rd logic, "Rendering Icons using SVG Sprites". It solves 3 problems,
|
Beta Was this translation helpful? Give feedback.
-
How to use?
import Icon from "@/components/icon/Icon";
<Icon id="icon-id"/> where Additionally, we can alter icon size, fill color, and stroke color, using tailwind classes <Icon id="MapPin" className="h-12 w-12 hover:stroke-primary"></Icon> How to add a new Icon
// /public/sprite.svg
<symbol id="icon-id" viewBox="0 0 24 24">
// Your icon paths
</symbol> Note: Remove following attributes from your paths, if present fillColor="anyValue" stroke="currentColor", for better control over style overrding.
// types/icon/index.ts
export type idType = "icon-id" | ..... This step is to enhance code suggestions, while using Icons. More Examples // plain icons with default fill, stroke, and size.
<Icon id="XCircle"></Icon>
<Icon id="XCircle"></Icon>
<Icon id="XCircle"></Icon>
<Icon id="XCircle"></Icon>
<Icon id="XCircle"></Icon>
<Icon id="XCircle"></Icon>
// change default stroke color
<Icon id="Pen" className="stroke-primary"></Icon>
<Icon id="Pen" className="stroke-primary"></Icon>
<Icon id="Pen" className="stroke-primary"></Icon>
<Icon id="Pen" className="stroke-primary"></Icon>
<Icon id="Pen" className="stroke-primary"></Icon>
<Icon id="Pen" className="stroke-primary"></Icon>
// fill color with no stroke
<Icon id="ThumbsUp" className="fill-primary stroke-none"></Icon>
<Icon id="ThumbsUp" className="fill-primary stroke-none"></Icon>
<Icon id="ThumbsUp" className="fill-primary stroke-none"></Icon>
<Icon id="ThumbsUp" className="fill-primary stroke-none"></Icon>
<Icon id="ThumbsUp" className="fill-primary stroke-none"></Icon>
<Icon id="ThumbsUp" className="fill-primary stroke-none"></Icon>
// stroke color success
<Icon id="CheckSquare" className="stroke-success-600 "></Icon>
<Icon id="CheckSquare" className="stroke-success-600 "></Icon>
<Icon id="CheckSquare" className="stroke-success-600 "></Icon>
<Icon id="CheckSquare" className="stroke-success-600 "></Icon>
<Icon id="CheckSquare" className="stroke-success-600 "></Icon>
<Icon id="CheckSquare" className="stroke-success-600 "></Icon>
// stroke color warning
<Icon id="Prohibit" className="stroke-warning-600"></Icon>
<Icon id="Prohibit" className="stroke-warning-600"></Icon>
<Icon id="Prohibit" className="stroke-warning-600"></Icon>
<Icon id="Prohibit" className="stroke-warning-600"></Icon>
<Icon id="Prohibit" className="stroke-warning-600"></Icon>
<Icon id="Prohibit" className="stroke-warning-600"></Icon>
// size variation + hover effect
<Icon id="MapPin" className="hover:stroke-primary"></Icon>
<Icon id="MapPin" className="h-12 w-12 hover:stroke-primary"></Icon>
<Icon id="MapPin" className="h-14 w-14 hover:stroke-primary"></Icon>
<Icon id="MapPin" className="h-16 w-16 hover:stroke-primary"></Icon>
<Icon id="MapPin" className="h-20 w-20 hover:stroke-primary"></Icon>
<Icon id="MapPin" className="h-24 w-24 hover:stroke-primary"></Icon> |
Beta Was this translation helpful? Give feedback.
-
Here we can discuss and decide coding best practices for better code quality.
Beta Was this translation helpful? Give feedback.
All reactions