Configuration Options
IconSync provides various configuration options to customize how icons are fetched from Figma and how components are generated.
Complete Configuration Reference
Here's a complete reference of all available configuration options:
import { iconConfig } from "@iconsync/core";
export default iconConfig({
// Figma API configuration
figma: {
token: process.env.FIGMA_TOKEN!, // Your Figma API token
url: "https://www.figma.com/design/YOUR_FILE_ID/YOUR_FILE_NAME?node-id=YOUR_NODE_ID",
// Alternatively, you can specify fileId and nodeId directly:
// fileId: "YOUR_FILE_ID",
// nodeId: "YOUR_NODE_ID",
},
// Icon fetching configuration
fetch: {
concurrentDownloads: 5, // Number of concurrent downloads
// nodeTypes: ["COMPONENT", "COMPONENT_SET"], // Types of nodes to fetch
// generateFileName: (node, parentNode) => node.name + "--" + parentNode.name, // Custom filename generator
// sanitizeName: true, // Sanitize filenames
// limit: 10, // Limit the number of icons to fetch
},
// Component generation configuration
generator: {
icon: true, // Generate icon components
typescript: true, // Generate TypeScript files
titleProp: true, // Add title prop to components
dimensions: false, // Include width/height dimensions
expandProps: "end", // Position of expanded props
replaceAttrValues: {
"#000000": "currentColor", // Replace specific colors
"#fff": "currentColor",
},
outDir: "src/components/icons", // Output directory
ext: "tsx", // File extension
prettier: true, // Format with Prettier
memo: false, // Use React.memo
ref: false, // Forward refs
filenameCase: "camel", // Filename case style: "pascal", "camel", "kebab", "snake"
},
});Color Replacement
The replaceAttrValues option in the generator configuration allows you to replace specific colors in your SVG icons with dynamic values like currentColor. This is useful for creating icons that inherit their color from CSS:
generator: {
// ... other options
replaceAttrValues: {
"#000000": "currentColor",
"#fff": "currentColor",
"#3E7BFA": "currentColor",
},
}Filename Customization
You can customize how filenames are generated using the filenameCase option:
generator: {
// ... other options
filenameCase: "camel", // Options: "pascal", "camel", "kebab", "snake"
}For example:
camel: myIconNamepascal: MyIconNamekebab: my-icon-namesnake: my_icon_name