Svg icon pattern

From vultisig/vultisig-windows · View interactive version

Svg icon pattern is an AI agent skill from the GitHub repository vultisig/vultisig-windows. Standards for creating and using SVG icons. Use SvgProps from @lib/ui/props and spread them on the svg element. Size icons via fontSize in the style prop at the usage site.

How to use this skill

Skill file

SVG Icon Pattern

Instructions

When creating or updating icons in the lib/ui/icons directory, follow these standards to ensure consistency and flexibility.

1. Icon Component Definition

Export a named component that receives SvgProps from @lib/ui/props. Spread these props onto the svg element.

// ✅ Good: SvgProps pattern
import { SvgProps } from '@lib/ui/props'

export const MyIcon = (props: SvgProps) => (
  <svg
    xmlns="http://www.w3.org/2000/svg"
    width="1em"
    height="1em"
    viewBox="0 0 24 24"
    fill="currentColor"
    {...props}
  >
    <path d="..." />
  </svg>
)

// ❌ Bad: IconWrapper inside icon definition
export const MyIcon = (props: any) => (
  <IconWrapper {...props}>
    <svg>...</svg>
  </IconWrapper>
)

2. Sizing and Dimensions

// Example for non-square icon (viewBox="0 0 22 20")
// height = 20/22 = 0.909
<svg width="1em" height="0.909em" viewBox="0 0 22 20" ...>

3. Styling and Colors

4. Usage and Sizing

Size icons at the usage site using the fontSize property within the style prop. This leverages the 1em base size defined in the icon component.

// ✅ Good: Direct sizing via style
<MyIcon style={{ fontSize: 24 }} />

// ❌ Bad: Using size prop (requires IconWrapper)
<MyIcon size={24} />

Anti-Patterns to Avoid

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.