### Install react-icomoon with npm Source: https://github.com/aykutkardas/react-icomoon/blob/main/README.md Installs the react-icomoon package using npm. This is the first step to integrate the library into your project. ```bash npm install react-icomoon ``` -------------------------------- ### Install react-icomoon with yarn Source: https://github.com/aykutkardas/react-icomoon/blob/main/README.md Installs the react-icomoon package using yarn. This command is an alternative to npm for package management. ```bash yarn add react-icomoon ``` -------------------------------- ### Install Dependencies for React Native Source: https://github.com/aykutkardas/react-icomoon/blob/main/README.md Installs react-icomoon along with react-native-svg, which is a required dependency for using SVG components in React Native. ```bash npm install react-icomoon react-native-svg ``` ```bash yarn add react-icomoon react-native-svg ``` -------------------------------- ### Get List of Available Icons Source: https://github.com/aykutkardas/react-icomoon/blob/main/README.md Shows how to use the `iconList` utility function from the react-icomoon library to retrieve a list of all available icon names from the provided icon set. ```jsx import IcoMoon, { iconList } from "react-icomoon"; iconList(iconSet); // sample output // [ // "document", // "camera", // "genius", // "chat", // "heart1", // "alarmclock", // "star-full", // "heart", // "play3", // "pause2", // "bin1", // ]; ``` -------------------------------- ### Use Icon Component in React Source: https://github.com/aykutkardas/react-icomoon/blob/main/README.md Demonstrates how to use the previously declared Icon component in a React application. It shows passing icon name, size, and color as props. ```jsx import Icon from "./Icon"; ; ``` -------------------------------- ### Render SVG Icons with IcoMoon Component (React) Source: https://context7.com/aykutkardas/react-icomoon/llms.txt Demonstrates basic usage of the IcoMoon component to render SVG icons in a React application. It shows how to import the icon set and customize icons using props like 'icon', 'size', and 'color'. ```jsx import IcoMoon from "react-icomoon"; import iconSet from "./selection.json"; // Basic usage with size and color function App() { return (
); } export default App; ``` -------------------------------- ### Custom Styling and Props with IcoMoon Source: https://context7.com/aykutkardas/react-icomoon/llms.txt Demonstrates how to customize IcoMoon components using various props like `removeInlineStyle`, `disableFill`, `className`, and inline `style` objects. This allows for fine-grained control over icon appearance. ```jsx import IcoMoon from "react-icomoon"; import iconSet from "./selection.json"; function CustomStyledIcons() { return (
{/* Remove default inline styles */} {/* Disable fill for multi-color icons */} {/* Complex styling with CSS-in-JS */} e.currentTarget.style.transform = 'scale(1.2)'} onMouseLeave={(e) => e.currentTarget.style.transform = 'scale(1)'} />
); } export default CustomStyledIcons; ``` -------------------------------- ### Declare Icon Component for React Native Source: https://github.com/aykutkardas/react-icomoon/blob/main/README.md Configures the Icon component for React Native usage by passing `native` prop and specifying `SvgComponent` and `PathComponent` from `react-native-svg`. This enables SVG rendering in a native environment. ```jsx // Icon.jsx import IcoMoon from "react-icomoon"; import { Svg, Path } from "react-native-svg"; import iconSet from "./selection.json"; const Icon = (props) => ( ); export default Icon; ``` -------------------------------- ### IcoMoon Icon Set JSON Structure Source: https://context7.com/aykutkardas/react-icomoon/llms.txt Illustrates the typical structure of an icon set JSON file generated by IcoMoon or svgps.app. It contains an 'icons' array, where each object represents an icon with its SVG paths, dimensions, and properties like name and code. ```json { "icons": [ { "icon": { "paths": [ "M1140.864 448.736c-8.448-2.624-17.408 1.984-20.096 10.4-2.656 8.416 1.984 17.408 10.4 20.096..." ], "attrs": [], "width": 1344 }, "properties": { "name": "chat", "id": 74, "order": 1008, "code": 57417 } }, { "icon": { "paths": [ "M512 0c-282.77 0-512 229.23-512 512s229.23 512 512 512..." ], "width": 1024 }, "properties": { "name": "heart", "id": 75 } } ] } ``` -------------------------------- ### Declare Icon Component in React Source: https://github.com/aykutkardas/react-icomoon/blob/main/README.md Defines a reusable Icon component in React that imports the IcoMoon component and a selection.json file. This component can then be used throughout the application. ```jsx // Icon.jsx import IcoMoon from "react-icomoon"; import iconSet from "./selection.json"; const Icon = (props) => ; export default Icon; ``` -------------------------------- ### Render SVG Icons in React Native with IcoMoon Component Source: https://context7.com/aykutkardas/react-icomoon/llms.txt Explains how to use the IcoMoon component for React Native applications. It requires the `native` prop and passing `Svg` and `Path` components from `react-native-svg` to enable rendering on iOS and Android platforms. ```jsx import IcoMoon from "react-icomoon"; import { Svg, Path } from "react-native-svg"; import iconSet from "./selection.json"; import { View, TouchableOpacity, Text } from "react-native"; // Create native icon component const Icon = (props) => ( ); // Usage in React Native app function HomeScreen() { return ( console.log('Back pressed')} style={{ flexDirection: 'row', alignItems: 'center' }} > Back ); } export default HomeScreen; ``` -------------------------------- ### Type-Safe SVG Icons with IcoMoon Component (TypeScript) Source: https://context7.com/aykutkardas/react-icomoon/llms.txt Illustrates a type-safe implementation of the IcoMoon component in TypeScript. It shows how to use the exported `IconProps` interface for compile-time prop validation and creating a typed icon wrapper for cleaner usage within TypeScript components. ```tsx import IcoMoon, { IconProps } from "react-icomoon"; import iconSet from "./selection.json"; // Create a typed icon wrapper const Icon = (props: IconProps) => ; // Usage in a TypeScript component interface HeaderProps { onMenuClick: () => void; } const Header: React.FC = ({ onMenuClick }) => { return (

My App

); }; export default Header; ``` -------------------------------- ### Declare Icon Component with TypeScript Source: https://github.com/aykutkardas/react-icomoon/blob/main/README.md Declares a reusable Icon component in TypeScript, including type definitions for props. This enhances type safety in React projects using TypeScript. ```tsx // Icon.tsx import IcoMoon, { IconProps } from "react-icomoon"; import iconSet from "./selection.json"; const Icon = (props: IconProps) => ; export default Icon; ``` -------------------------------- ### Extract Icon Names using iconList Source: https://context7.com/aykutkardas/react-icomoon/llms.txt Utility function to extract all available icon names from an icon set. Useful for validation, debugging, or creating dynamic icon selectors. It takes an icon set object as input and returns an array of strings representing icon names. ```javascript import { iconList } from "react-icomoon"; import iconSet from "./selection.json"; // Get all available icons const availableIcons = iconList(iconSet); console.log(availableIcons); // Output: ["document", "camera", "genius", "chat", "heart", "alarmclock", "star-full", "play3", "pause2", "bin1"] ``` ```javascript // Validate icon exists before rendering function IconWrapper({ iconName, ...props }) { const icons = iconList(iconSet); if (!icons || !icons.includes(iconName)) { console.warn(`Icon "${iconName}" not found in icon set`); return null; } return ; } ``` ```javascript // Build dynamic icon selector function IconPicker({ onSelect }) { const icons = iconList(iconSet); return (
{icons.map(icon => ( ))}
); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.