Radix Icons

repository·main·Indexed 25 days ago

https://github.com/radix-ui/icons

A 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.

Tokens
20.3K
Snippets
4
Records
345
Agent score
82%

What's inside radix-ui-icons

  1. Authenticate with Figma using a Personal Access Token

    main

    To access Figma files, you must provide a Personal Access Token.

    1. Create a Personal Access Token in your Figma Account Settings.
    2. Set the token using the FIGMA_ACCESS_TOKEN environment variable.

    You can create an .env file in your target directory to store the token for reuse.

    echo "FIGMA_ACCESS_TOKEN=<token>" >> packages/radix-icons/.env
  2. Fetch resources with retry support

    main

    The fetch function is a wrapper around the global fetch API that includes automatic retry logic. It is useful for making resilient network requests when generating icons.

    Retry Configuration: By default, it uses a defaultRetry configuration:

    • delay: 1000ms
    • retries: 2

    You can override these settings by passing a retry object within the fetchOptions.

    Error Handling: If all retries fail and the device is offline, it rejects with a CodedError using the NETWORK_OFFLINE code.

  3. Extract leaf node strings from an object with pushObjLeafNodesToArr

    main

    The pushObjLeafNodesToArr function 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.
  4. Use the generate-icon-lib CLI to sync icons from Figma

    main

    The generate-icon-lib CLI 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 --file or -f flag. The CLI expects a page named Icons to exist in the Figma document, containing frames that group icon sets.