Radix Icons
repository·main·Indexed 25 days ago
https://github.com/radix-ui/iconsA collection of high-quality, 15×15 pixel icons designed by WorkOS for modern web interfaces. The repository includes a set of React SVG components and the `generate-icon-lib` CLI tool, which automates pulling icon designs from Figma files to generate React components and an icon manifest using a Figma Personal Access Token.
What's inside radix-ui-icons
- Radix Icons is a set of crisp 15×15 icons designed by the WorkOS team. They are intended for use in user interfaces requiring high-quality, small-scale iconography.
Authenticate with Figma using a Personal Access Token
mainTo access Figma files, you must provide a Personal Access Token.
- Create a Personal Access Token in your Figma Account Settings.
- Set the token using the
FIGMA_ACCESS_TOKENenvironment variable.
You can create an
.envfile in your target directory to store the token for reuse.echo "FIGMA_ACCESS_TOKEN=<token>" >> packages/radix-icons/.envImport Radix Icons
mainRadix Icons are exported as individual React components from the@radix-ui/react-iconspackage. You can import any icon by its specific name (e.g.,ArrowRightIcon,CheckIcon,GearIcon) to use within your React application.Configure the FIGMA_ACCESS_TOKEN environment variable
mainThe
FIGMA_ACCESS_TOKENenvironment variable is used to provide authentication for Figma API interactions, likely required during icon generation or development processes within the repository.FIGMA_ACCESS_TOKEN="figd_..."Generate icon library from a Figma file
mainUse the
generate-icon-libCLI to generate an icon library from a specific Figma document. You must provide thefigma-file-key, which can be extracted from a Figma URL (e.g.,https://www.figma.com/file/<figma-file-key>).generate-icon-lib --file=<figma-file-key>Fetch resources with retry support
mainThe
fetchfunction is a wrapper around the globalfetchAPI that includes automatic retry logic. It is useful for making resilient network requests when generating icons.Retry Configuration: By default, it uses a
defaultRetryconfiguration:delay: 1000msretries: 2
You can override these settings by passing a
retryobject within thefetchOptions.Error Handling: If all retries fail and the device is offline, it rejects with a
CodedErrorusing theNETWORK_OFFLINEcode.Handle errors with handleError
mainThehandleErrorfunction is used to process errors, unmount the current view, and log formatted error messages to the console. If the error is an instance ofCodedError, it displays the specific error code and message. Ifexitis set totrue(default), the process will terminate with exit code1.Extract leaf node strings from an object with pushObjLeafNodesToArr
mainThe
pushObjLeafNodesToArrfunction traverses an object and collects all string values found at leaf nodes into a provided array. This is useful for flattening nested configuration or data structures.Parameters:
obj: The source object to traverse.arr: The array where the discovered string values will be pushed.accessor(optional): An array of keys used to navigate to a specific sub-object before starting the traversal.
Reference the generate-icon-lib CLI flags
mainThe following flags are available for the
generate-icon-libCLI:Flag Short Type Description --file-fstringThe Figma File Key from which to source icons. --helpN/A N/A Show this message. Options --file, -f File Key from Figma --help Show this messageReference: Radix Icons List
mainThe following icons are available for import from the package entry point:Use the generate-icon-lib CLI to sync icons from Figma
mainThe
generate-icon-libCLI automates the process of pulling icon designs from a Figma file, downloading them as SVGs, and generating React components and an icon manifest.To run the CLI, you must provide the Figma file key using the
--fileor-fflag. The CLI expects a page namedIconsto exist in the Figma document, containing frames that group icon sets.Use the PersonIcon component
mainThePersonIconcomponent renders a person silhouette icon. It is a React component that accepts standard SVG props and an optionalcolorprop. By default, the icon usescurrentColorfor its fill color.