### Responsive GridLoader Example Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/api-reference/GridLoader.md This example demonstrates how to use the GridLoader component and dynamically adjust its size based on the window width. It includes setup for state management and event listeners for window resizing. ```typescript import { GridLoader } from 'react-spinners'; import { useState, useEffect } from 'react'; function ResponsiveGridLoader() { const [size, setSize] = useState(15); useEffect(() => { const handleResize = () => { if (window.innerWidth < 640) { setSize(10); } else if (window.innerWidth < 1024) { setSize(15); } else { setSize(20); } }; window.addEventListener('resize', handleResize); handleResize(); // Call on mount return () => window.removeEventListener('resize', handleResize); }, []); return ( ); } ``` -------------------------------- ### Install Dependencies Source: https://github.com/davidhu2000/react-spinners/blob/main/CONTRIBUTING.md Install the necessary project dependencies using either npm or yarn. This is required before running any development commands. ```bash npm install ``` -------------------------------- ### Install react-spinners with Yarn Source: https://github.com/davidhu2000/react-spinners/blob/main/README.md Use this command to add react-spinners to your project if you are using Yarn. ```bash yarn add react-spinners ``` -------------------------------- ### Basic ClipLoader Usage Example Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/api-reference/ClipLoader.md Demonstrates how to use the ClipLoader component with basic props and a toggle button. ```typescript import { ClipLoader } from 'react-spinners'; import { CSSProperties, useState } from 'react'; function LoadingComponent() { const [loading, setLoading] = useState(true); const override: CSSProperties = { display: "block", margin: "0 auto", }; return ( <> ); } ``` -------------------------------- ### Install react-spinners with npm Source: https://github.com/davidhu2000/react-spinners/blob/main/README.md Use this command to add react-spinners to your project if you are using npm. ```bash npm install --save react-spinners ``` -------------------------------- ### Advanced BarLoader Configuration Example Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/API_INDEX.md Shows advanced configuration of the BarLoader component, including CSS overrides for positioning and styling, and custom speed multiplier. ```typescript import { BarLoader } from 'react-spinners'; import { CSSProperties } from 'react'; function ProgressBar() { const override: CSSProperties = { display: "block", position: "fixed", top: 0, left: 0, right: 0, zIndex: 9999, }; return ( ); } ``` -------------------------------- ### Basic Usage Example Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/api-reference/ScaleLoader.md A typical implementation of ScaleLoader within a React component, demonstrating how to set custom colors and dimensions for the loading bars. ```typescript import { ScaleLoader } from 'react-spinners'; function FileProcessing() { return (
); } ``` -------------------------------- ### Clone the Repository Source: https://github.com/davidhu2000/react-spinners/blob/main/CONTRIBUTING.md Fork the repository and clone it locally to start contributing. Replace 'your-username' with your GitHub username. ```bash git clone git@github.com:your-username/react-spinners.git ``` -------------------------------- ### Responsive CircleLoader Example Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/api-reference/CircleLoader.md Shows how to make the CircleLoader responsive by adjusting its size based on window width. It uses the `useState` and `useEffect` hooks to manage the size and listen for window resize events. ```typescript import { CircleLoader } from 'react-spinners'; import { useEffect, useState } from 'react'; function ResponsiveCircleLoader() { const [size, setSize] = useState(50); useEffect(() => { const handleResize = () => { if (window.innerWidth < 640) { setSize(35); } else if (window.innerWidth < 1024) { setSize(50); } else { setSize(70); } }; window.addEventListener('resize', handleResize); handleResize(); return () => window.removeEventListener('resize', handleResize); }, []); return ( ); } ``` -------------------------------- ### Responsive RingLoader Example Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/api-reference/RingLoader.md Demonstrates how to dynamically adjust the size of the RingLoader based on window width. This snippet uses React hooks to manage state and listen for resize events. ```typescript import { RingLoader } from 'react-spinners'; import { useEffect, useState } from 'react'; function ResponsiveRingLoader() { const [size, setSize] = useState(60); useEffect(() => { const handleResize = () => { if (window.innerWidth < 640) { setSize(40); } else if (window.innerWidth < 1024) { setSize(60); } else { setSize(80); } }; window.addEventListener('resize', handleResize); handleResize(); return () => window.removeEventListener('resize', handleResize); }, []); return ( ); } ``` -------------------------------- ### Basic PuffLoader Usage Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/api-reference/PuffLoader.md A basic example demonstrating how to use the PuffLoader component with custom color and size. Ensure the component is wrapped in a container for proper centering. ```typescript import { PuffLoader } from 'react-spinners'; function DataLoading() { return (
); } ``` -------------------------------- ### Basic FadeLoader Usage Example Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/api-reference/FadeLoader.md Demonstrates how to use the FadeLoader component with custom color, size, and margin props. Ensure the component is wrapped in a container that allows for centering if needed. ```typescript import { FadeLoader } from 'react-spinners'; function AsyncDataLoader() { return (
); } ``` -------------------------------- ### Basic CircleLoader Usage Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/api-reference/CircleLoader.md A basic example demonstrating how to render the CircleLoader component with custom color and size. Ensure the component is wrapped in a container with appropriate styling for centering if needed. ```typescript import { CircleLoader } from 'react-spinners'; function LoadingScreen() { return (
); } ``` -------------------------------- ### Basic RingLoader Usage Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/api-reference/RingLoader.md A basic example demonstrating how to use the RingLoader component with custom color and size. Ensure the component is wrapped in a container for proper centering. ```typescript import { RingLoader } from 'react-spinners'; function LoadingDisplay() { return (
); } ``` -------------------------------- ### ClipLoader with named colors Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/configuration.md Examples of using supported named colors for the 'color' prop. Note that 'lightgray' is not supported. ```typescript // Not supported; use hex or rgb ``` -------------------------------- ### ClipLoader with hex color formats Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/configuration.md Examples of using 6-digit and 3-digit hex color codes for the 'color' prop. ```typescript // 6-digit hex // 3-digit hex (expands to #FF0000) ``` -------------------------------- ### Controlled PuffLoader with Speed and Size Adjustment Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/api-reference/PuffLoader.md An advanced example showing how to control the loading state, speed, and size of the PuffLoader using React state and input elements. This allows for dynamic adjustments to the spinner's behavior. ```typescript import { PuffLoader } from 'react-spinners'; import { useState } from 'react'; function ControlledPuffLoader() { const [loading, setLoading] = useState(true); const [speed, setSpeed] = useState(1); const [size, setSize] = useState(60); return (
); } ``` -------------------------------- ### Dynamic ScaleLoader with Custom Bar Count and Speed Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/api-reference/ScaleLoader.md An advanced example showcasing a dynamic ScaleLoader where the number of bars and animation speed can be adjusted in real-time using state and input range elements. ```typescript import { ScaleLoader } from 'react-spinners'; import { useState } from 'react'; function DynamicScaleLoader() { const [barCount, setBarCount] = useState(5); const [speed, setSpeed] = useState(1); return (
); } ``` -------------------------------- ### Advanced RingLoader with Animation Control Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/api-reference/RingLoader.md An advanced example showing how to control the loading state and animation speed of the RingLoader using React state and event handlers. ```typescript import { RingLoader } from 'react-spinners'; import { useState } from 'react'; function ControlledRingLoader() { const [loading, setLoading] = useState(true); const [speed, setSpeed] = useState(1); return (
); } ``` -------------------------------- ### FadeLoader with Dynamic Size Based on Screen Width Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/api-reference/FadeLoader.md This example shows how to dynamically adjust the FadeLoader's size (height, width, margin) based on the screen width, making it responsive. It uses the useState and useEffect hooks to track window size changes. ```typescript import { FadeLoader } from 'react-spinners'; import { useState } from 'react'; function ResponsiveFadeLoader() { const [isMobile, setIsMobile] = useState(window.innerWidth < 768); const handleResize = () => { setIsMobile(window.innerWidth < 768); }; React.useEffect(() => { window.addEventListener('resize', handleResize); return () => window.removeEventListener('resize', handleResize); }, []); return ( ); } ``` -------------------------------- ### Custom FadeLoader with Styling Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/api-reference/FadeLoader.md Demonstrates how to use the FadeLoader component with custom CSS overrides for advanced styling, including background color, padding, and box shadow. Ensure the 'react-spinners' and 'react' libraries are installed. ```typescript import { FadeLoader } from 'react-spinners'; import { CSSProperties } from 'react'; function CustomFadeLoader() { const override: CSSProperties = { display: "block", margin: "0 auto", backgroundColor: "white", borderRadius: "8px", padding: "30px", boxShadow: "0 2px 8px rgba(0,0,0,0.1)", }; return ( ); } ``` -------------------------------- ### CircleLoader with Speed and State Control Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/api-reference/CircleLoader.md An advanced example showing how to control the CircleLoader's speed and loading state dynamically using React hooks. This allows for interactive adjustments to the spinner's animation. ```typescript import { CircleLoader } from 'react-spinners'; import { useState } from 'react'; function AdjustableCircleLoader() { const [speed, setSpeed] = useState(1); const [size, setSize] = useState(50); const [loading, setLoading] = useState(true); return (
); } ``` -------------------------------- ### Customized RingLoader Styling Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/api-reference/RingLoader.md An example of how to apply custom CSS styles to the RingLoader using the 'cssOverride' prop. This allows for significant visual modifications beyond the default appearance. ```typescript import { RingLoader } from 'react-spinners'; import { CSSProperties } from 'react'; function StyledRingLoader() { const override: CSSProperties = { display: "block", margin: "0 auto", backgroundColor: "rgba(255, 255, 255, 0.8)", borderRadius: "50%", padding: "40px", }; return ( ); } ``` -------------------------------- ### Configurable GridLoader with State Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/api-reference/GridLoader.md Shows an advanced example of GridLoader where its size, margin, and color can be dynamically changed using React state and input elements. This allows for interactive customization of the spinner's appearance. ```typescript import { GridLoader } from 'react-spinners'; import { useState } from 'react'; function ConfigurableGridLoader() { const [size, setSize] = useState(15); const [margin, setMargin] = useState(2); const [color, setColor] = useState("#3498db"); return (
); } ``` -------------------------------- ### Build Demo Site Source: https://github.com/davidhu2000/react-spinners/blob/main/CONTRIBUTING.md Build the demo site after making changes to loaders or the demo interface. This command ensures the demo accurately reflects your modifications. ```bash npm run build:demo ``` -------------------------------- ### Project File Structure Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/MANIFEST.md This tree shows the organization of the generated documentation files for the react-spinners library. ```bash output/ ├── README.md [Orientation guide - start here] ├── MANIFEST.md [This file] ├── API_INDEX.md [Master index and quick reference] ├── types.md [Type definitions and interfaces] ├── configuration.md [Props and configuration options] └── api-reference/ ├── Helpers.md [Helper utility functions] ├── BarLoader.md [Horizontal progress bar] ├── BeatLoader.md [Three pulsing dots] ├── BounceLoader.md [Two bouncing circles] ├── CircleLoader.md [Five concentric rings] ├── ClipLoader.md [Rotating circle with scaling] ├── FadeLoader.md [Eight fading bars in circle] ├── GridLoader.md [3×3 grid of animated dots] ├── PuffLoader.md [Two puffing circles] ├── RingLoader.md [Two 3D rotating rings] ├── ScaleLoader.md [Multiple scaling bars] └── OtherLoaders.md [13 additional loader components] ``` -------------------------------- ### Use Flexbox for Spinner Container Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/configuration.md Arrange the spinner within a flexbox container to center it both horizontally and vertically. This example makes the container fill the viewport height. ```typescript const override = { display: "flex", justifyContent: "center", alignItems: "center", height: "100vh", }; ``` -------------------------------- ### Component Usage with Props Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/README.md Demonstrates how to use a loader component with common props like loading, color, and size. Ensure you have the necessary types imported. ```typescript import { ClipLoader, LoaderSizeProps } from 'react-spinners'; const props: LoaderSizeProps = { loading: true, color: "#FF0000", size: 50, }; ``` -------------------------------- ### Add Background Container with CSS Override Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/configuration.md Style a background container for the spinner using CSS overrides. This example adds a white background, padding, and rounded corners. ```typescript const override = { backgroundColor: "white", padding: "20px", borderRadius: "8px", boxShadow: "0 2px 8px rgba(0,0,0,0.1)", }; ``` -------------------------------- ### Responsive BarLoader with Dynamic Width Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/api-reference/BarLoader.md Illustrates how to make the BarLoader responsive by dynamically adjusting its width based on window size. This ensures the loader fits well across different screen dimensions. ```typescript import { BarLoader } from 'react-spinners'; import { useEffect, useState } from 'react'; function ResponsiveBar() { const [barWidth, setBarWidth] = useState("100%"); useEffect(() => { const handleResize = () => { const isMobile = window.innerWidth < 768; setBarWidth(isMobile ? "100%" : "80%"); }; window.addEventListener('resize', handleResize); return () => window.removeEventListener('resize', handleResize); }, []); return ( ); } ``` -------------------------------- ### Basic Usage of ClipLoader Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/README.md Demonstrates how to import and use the ClipLoader component with basic props like color, loading state, and size. ```typescript import { ClipLoader } from 'react-spinners'; function Loading() { return ; } ``` -------------------------------- ### Basic GridLoader Usage Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/api-reference/GridLoader.md Demonstrates how to use the GridLoader component with custom color, size, and margin. Ensure the component is wrapped in a container that allows for centering if needed. ```typescript import { GridLoader } from 'react-spinners'; function DataLoadingScreen() { return (
); } ``` -------------------------------- ### Basic BeatLoader Usage Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/api-reference/BeatLoader.md Demonstrates a simple implementation of the BeatLoader component with custom color, loading state, size, and margin. ```typescript import { BeatLoader } from 'react-spinners'; function LoadingMessage() { return (

Processing your request

); } ``` -------------------------------- ### Development Build Commands Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/API_INDEX.md Commands for building and developing the react-spinners project. Includes commands for development server, CJS build, ESM build, and Storybook. ```bash # Development npm run dev # Build CJS npm run build # Build ESM npm run build:esm # Storybook documentation npm run storybook ``` -------------------------------- ### Stage and Commit Changes Source: https://github.com/davidhu2000/react-spinners/blob/main/CONTRIBUTING.md Stage all changes and commit them with a descriptive message. This prepares your changes for pushing to the remote repository. ```bash git add -A; git commit -m 'Awesome new feature'; ``` -------------------------------- ### Basic BounceLoader Usage Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/api-reference/BounceLoader.md Demonstrates how to use the BounceLoader component with basic props like color, loading state, and size. This is suitable for general loading indicators. ```typescript import { BounceLoader } from 'react-spinners'; function LoadingSpinner() { return (
); } ``` -------------------------------- ### Making ScaleLoader Responsive Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/api-reference/ScaleLoader.md Shows how to make the ScaleLoader responsive to different screen sizes by dynamically adjusting its configuration (height, width, bar count) based on window width. This ensures the loader looks good on both small and large displays. ```typescript import { ScaleLoader } from 'react-spinners'; import { useEffect, useState } from 'react'; function ResponsiveScaleLoader() { const [config, setConfig] = useState({ height: 35, width: 4, barCount: 5, }); useEffect(() => { const handleResize = () => { if (window.innerWidth < 640) { setConfig({ height: 20, width: 3, barCount: 3 }); } else if (window.innerWidth < 1024) { setConfig({ height: 30, width: 4, barCount: 5 }); } else { setConfig({ height: 40, width: 5, barCount: 7 }); } }; window.addEventListener('resize', handleResize); handleResize(); return () => window.removeEventListener('resize', handleResize); }, []); return ( ); } ``` -------------------------------- ### Run Tests and Lints Source: https://github.com/davidhu2000/react-spinners/blob/main/CONTRIBUTING.md Ensure code quality by running the necessary tests and linters. Fix any errors reported by these commands before proceeding. ```bash npm run lint; npm run test:jest; ``` -------------------------------- ### Using calculateRgba for Backgrounds Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/api-reference/Helpers.md Demonstrates using calculateRgba to generate a background color with a specified opacity, useful for creating semi-transparent elements. ```typescript const backgroundColor = calculateRgba(color, 0.2); // 20% opacity const wrapper = { backgroundColor: backgroundColor, // Semi-transparent background color: color, // Full opacity foreground }; ``` -------------------------------- ### ClipLoader with RGB and RGBA color formats Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/configuration.md Demonstrates using standard RGB, RGBA with decimal opacity, and modern CSS syntax for the 'color' prop. ```typescript // Standard RGB format // RGBA with decimal opacity // Modern CSS syntax with forward slash // Numeric opacity in RGBA ``` -------------------------------- ### BarLoader with custom height and width Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/configuration.md Shows how to set custom 'height' and 'width' for the BarLoader component. ```typescript ``` -------------------------------- ### Watch for Changes Source: https://github.com/davidhu2000/react-spinners/blob/main/CONTRIBUTING.md Use webpack to continuously watch for changes and update the bundle file. This is useful during development to see your changes reflected quickly. ```bash npm run watch ``` -------------------------------- ### Responsive PuffLoader based on Window Size Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/api-reference/PuffLoader.md Shows how to make the PuffLoader responsive by dynamically adjusting its size based on the browser window's width. It uses `useState` and `useEffect` to manage size changes on window resize events. ```typescript import { PuffLoader } from 'react-spinners'; import { useEffect, useState } from 'react'; function ResponsivePuffLoader() { const [size, setSize] = useState(60); useEffect(() => { const handleResize = () => { if (window.innerWidth < 640) { setSize(40); } else if (window.innerWidth < 1024) { setSize(60); } else { setSize(80); } }; window.addEventListener('resize', handleResize); handleResize(); return () => window.removeEventListener('resize', handleResize); }, []); return ( ); } ``` -------------------------------- ### Basic Usage with Functional Component Source: https://github.com/davidhu2000/react-spinners/blob/main/README.md Demonstrates how to use ClipLoader in a React functional component, managing loading state and color via useState. ```tsx import { useState, CSSProperties } from "react"; import { ClipLoader } from "react-spinners"; const override: CSSProperties = { display: "block", margin: "0 auto", borderColor: "red", }; function App() { let [loading, setLoading] = useState(true); let [color, setColor] = useState("#ffffff"); return (
setColor(input.target.value)} placeholder="Color of the loader" />
); } export default App; ``` -------------------------------- ### Basic BarLoader Usage Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/api-reference/BarLoader.md Demonstrates a basic implementation of the BarLoader component with custom color, height, and width. This is useful for standard loading indicators within your application. ```typescript import { BarLoader } from 'react-spinners'; import { CSSProperties } from 'react'; function FileUploadProgress() { return (

Uploading file...

); } ``` -------------------------------- ### Advanced ClipLoader with Color and Size Customization Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/api-reference/ClipLoader.md Shows how to dynamically customize the color and size of the ClipLoader using input elements. ```typescript import { ClipLoader } from 'react-spinners'; import { useState } from 'react'; function CustomClipLoader() { const [color, setColor] = useState("#FF5733"); const [size, setSize] = useState(60); return (
setColor(e.target.value)} /> setSize(Number(e.target.value))} />
); } ``` -------------------------------- ### Using createAnimation in Loaders Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/api-reference/Helpers.md Shows how to use the createAnimation helper to define CSS keyframe animations for loaders, specifying the animation name, keyframes, and a fallback name. ```typescript const fadeAnimation = createAnimation( "FadeLoader", "50% {opacity: 0.3} 100% {opacity: 1}", "fade" ); const style = { animation: `${fadeAnimation} 1.2s infinite`, }; ``` -------------------------------- ### Universal Props for All Loaders Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/API_INDEX.md Demonstrates the common props that can be applied to any loader component. These include loading state, color, speed multiplier, and CSS overrides. ```typescript ``` -------------------------------- ### BeatLoader with custom size and margin Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/configuration.md Illustrates customizing the 'size' and 'margin' props for the BeatLoader component. ```typescript ``` -------------------------------- ### Full Width BarLoader with State Management Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/api-reference/BarLoader.md Shows how to use BarLoader to create a full-width progress bar at the top of the page, controlled by component state. This is ideal for indicating global loading states or page transitions. ```typescript import { BarLoader } from 'react-spinners'; import { CSSProperties, useState } from 'react'; function TopProgressBar() { const [loading, setLoading] = useState(false); const override: CSSProperties = { position: "fixed", top: 0, left: 0, right: 0, zIndex: 9999, }; return ( <>

Page content here...

); } ``` -------------------------------- ### Custom PuffLoader with CSS Overrides Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/api-reference/PuffLoader.md Demonstrates how to customize the PuffLoader's appearance using the `cssOverride` prop. This includes setting display, margin, background color, border radius, and padding. ```typescript import { PuffLoader } from 'react-spinners'; import { CSSProperties } from 'react'; function StyledPuffLoader() { const override: CSSProperties = { display: "block", margin: "0 auto", backgroundColor: "rgba(0, 0, 0, 0.05)", borderRadius: "50%", padding: "30px", }; return ( ); } ``` -------------------------------- ### FadeLoader with full dimensional control Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/configuration.md Demonstrates setting 'height', 'width', 'radius', and 'margin' for the FadeLoader component. ```typescript ``` -------------------------------- ### Customizing BounceLoader Styles Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/api-reference/BounceLoader.md Illustrates how to apply custom CSS styles to the BounceLoader using the `cssOverride` prop. This allows for detailed visual adjustments beyond basic props. ```typescript import { BounceLoader } from 'react-spinners'; import { CSSProperties } from 'react'; function CustomBounceLoader() { const override: CSSProperties = { display: "block", margin: "0 auto", backgroundColor: "rgba(0, 0, 0, 0.05)", borderRadius: "10px", padding: "20px", }; return ( ); } ``` -------------------------------- ### BeatLoader with CSS Overrides Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/api-reference/BeatLoader.md Illustrates how to apply custom CSS styles to the BeatLoader component using the `cssOverride` prop for layout and alignment. ```typescript import { BeatLoader } from 'react-spinners'; import { CSSProperties } from 'react'; function CustomBeatLoader() { const override: CSSProperties = { display: "flex", justifyContent: "center", alignItems: "center", padding: "20px", }; return ( ); } ``` -------------------------------- ### Memoizing Loader Styles with useMemo Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/configuration.md Optimize component rendering by memoizing style overrides for ClipLoader using the `useMemo` hook. This prevents unnecessary re-creation of the style object on every render. ```typescript import { useMemo } from 'react'; import { ClipLoader } from 'react-spinners'; function OptimizedLoader({ loading, color }) { const override = useMemo(() => ({ display: "block", margin: "0 auto", }), []); return ; } ``` -------------------------------- ### ClipLoader with size in pixels and rem Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/configuration.md Demonstrates using the 'size' prop with both numeric (pixels) and string (rem) values for ClipLoader. ```typescript // 50px diameter // 2rem diameter ``` -------------------------------- ### Create a New Branch Source: https://github.com/davidhu2000/react-spinners/blob/main/CONTRIBUTING.md Create a new branch for your feature or bug fix. This helps keep your changes organized. ```bash git checkout -b awesome-feature ``` -------------------------------- ### Importing a Component Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/INDEX.txt Standard import pattern for any component from the react-spinners library. ```javascript import { ComponentName } from 'react-spinners'; ``` -------------------------------- ### BounceLoader with State Transitions Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/api-reference/BounceLoader.md Shows how to control the loading state and size of the BounceLoader dynamically using React state. This allows for interactive loading indicators. ```typescript import { BounceLoader } from 'react-spinners'; import { useState } from 'react'; function LoadingWithState() { const [isLoading, setIsLoading] = useState(true); const [size, setSize] = useState(60); const handleToggle = () => { setIsLoading(!isLoading); setSize(isLoading ? 40 : 60); }; return ( <> ); } ``` -------------------------------- ### CircleLoader Ring Sizing Formula Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/api-reference/CircleLoader.md Illustrates the formula used to calculate the size of each of the five concentric rings based on the 'size' prop and the ring's index. This ensures a consistent decrease in size for inner rings. ```typescript const { value, unit } = parseLengthAndUnit(size); // Ring i dimensions: const ringSize = `${value * (1 - i / 10)}${unit}`; ``` -------------------------------- ### Client-Side Hydration with ClipLoader Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/configuration.md This snippet demonstrates how to safely use ClipLoader in components that are hydrated on the client. Ensure to use the 'use client' directive in Next.js for correct hydration. ```typescript import { ClipLoader } from 'react-spinners'; export default function ClientComponent() { return ; } ``` -------------------------------- ### Conditional Rendering with Loading Prop Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/README.md Shows how to conditionally render a loader based on a loading state. The loader returns null when loading is false. ```typescript // Hidden when isLoading is false ``` -------------------------------- ### ClipLoader and FadeLoader with numeric size/dimension values Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/configuration.md Illustrates how numeric values for 'size', 'height', and 'width' props are interpreted as pixels. ```typescript // Interpreted as 50px // 15px and 5px ``` -------------------------------- ### Import BeatLoader Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/api-reference/BeatLoader.md Import the BeatLoader component from the react-spinners library. ```typescript import { BeatLoader } from 'react-spinners'; ``` -------------------------------- ### createAnimation Source: https://github.com/davidhu2000/react-spinners/blob/main/_autodocs/api-reference/Helpers.md Creates and injects CSS keyframe animations into the document head. It is server-safe and can be used in SSR/Node.js environments. ```APIDOC ## createAnimation ### Description Creates and injects CSS keyframe animations into the document head. It is server-safe and can be used in SSR/Node.js environments. ### Function Signature ```typescript function createAnimation(loaderName: string, frames: string, suffix: string): string ``` ### Parameters #### Parameters - **loaderName** (string) - Required - Name of the loader (e.g., "ClipLoader", "BarLoader") - **frames** (string) - Required - CSS keyframe rules as a string (e.g., "0% {...} 50% {...} 100% {...}") - **suffix** (string) - Required - Suffix to append to animation name for uniqueness (e.g., "clip", "bounce") ### Returns `string` — The generated animation name in format `react-spinners-{loaderName}-{suffix}` ### Behavior - In browser environment: Creates a `