Package Exports
- filoaders
- filoaders/styles.css
Readme
Filoaders
A beautiful, production-ready React component library for canvas-based loader animations.
Built with TypeScript, SOLID principles, and designed for maximum developer experience. 69 unique loaders with advanced customization features.
โจ Features
- ๐จ 69 Beautiful Loaders - Diverse collection of canvas-based animations
- ๐ฆ TypeScript First - Full type safety and IntelliSense support
- โก Highly Performant - Optimized canvas rendering at 60fps
- ๐ญ Fully Customizable - Control colors, size, speed, and more
- ๐ฏ Per-Dot Styling - Customize individual dots by position/index/time
- ๐ Gradient Support - Linear and radial gradients for backgrounds and dots
- ๐ Theme Detection - Auto-detect system/next-themes preferences
- ๐ญ SVG Mask Support - Apply custom SVG masks to loaders
- ๐ง SOLID Principles - Clean, maintainable architecture
- ๐ณ Tree-shakeable - Import only what you need
- ๐ Zero Runtime Dependencies - Only React as peer dependency
- ๐ฎ Interactive Playground - Configure and generate code visually
๐ฆ Installation
npm install filoaders
# or
yarn add filoaders
# or
pnpm add filoaders๐ Quick Start
import { PulseWaveLoader } from 'filoaders';
import 'filoaders/styles.css';
function App() {
return <PulseWaveLoader size={180} dotColor="#3b82f6" />;
}๐จ Advanced Features
Per-Dot Styling
Customize individual dots based on position, index, and animation state:
import { PulseWaveLoader, rainbowDots } from 'filoaders';
// Use preset
<PulseWaveLoader dotStyle={rainbowDots} />
// Custom styling
<PulseWaveLoader
dotStyle={({ index, time }) => ({
color: `hsl(${index * 10}, 70%, 60%)`,
opacity: 0.5 + Math.sin(time + index) * 0.5,
size: 1 + Math.sin(time) * 0.3,
})}
/>Gradient Backgrounds
Apply beautiful gradients to backgrounds:
import { SpiralGalaxyLoader, gradientPresets } from 'filoaders';
// Use preset
<SpiralGalaxyLoader backgroundGradient={gradientPresets.sunset} />
// Custom gradient
<SpiralGalaxyLoader
backgroundGradient={{
type: 'radial',
stops: [
{ offset: 0, color: '#1e3a8a' },
{ offset: 1, color: '#000000' },
],
}}
/>Theme Detection
Automatic theme detection with next-themes support:
<PulseWaveLoader
theme={{
mode: 'auto', // 'light' | 'dark' | 'auto'
lightColors: {
dotColor: '#000000',
backgroundColor: '#ffffff',
},
darkColors: {
dotColor: '#ffffff',
backgroundColor: '#000000',
},
}}
/>SVG Masks
Apply custom SVG masks for creative effects:
import { BreathingGridLoader, maskPresets } from 'filoaders';
// Use preset
<BreathingGridLoader mask={maskPresets.heart} />
// Custom SVG
<BreathingGridLoader
mask={{
svg: `<svg viewBox="0 0 100 100">
<circle cx="50" cy="50" r="45" fill="white"/>
</svg>`,
scale: 0.9,
}}
/>Combined Features
Mix and match for stunning effects:
import {
RadiatingScanLoader,
rainbowDots,
gradientPresets,
maskPresets,
} from 'filoaders';
<RadiatingScanLoader
size={220}
dotStyle={rainbowDots}
backgroundGradient={gradientPresets.sunset}
mask={maskPresets.star}
theme={{ mode: 'auto' }}
/>๐ View Advanced Features Guide for complete documentation.
๐ญ Available Loaders (69 Total)
All loaders share a common props interface for consistency. Here's a selection organized by category:
Wave & Pulse (12 loaders)
PulseWaveLoader- Concentric dot rings with radial pulsePulseShockwaveLoader- Pulse wave with rotation effectInterwovenPulsesLoader- Independent ring pulsesCircularWavesLoader- Circular wave propagationPendulumWaveLoader- Pendulum-inspired wave motionRippleEffectLoader- Water ripple simulationInterconnectingWavesLoader- Interwoven wave patternsSequentialPulseLoader- Sequential pulse animationRadialPulseLoader- Radial pulse effectPulsatingCirclesLoader- Pulsating circular ringsPulseShockwaveLoader- Shockwave pulse effectPulsingGridLoader- Pulsing grid pattern
Spiral & Rotation (8 loaders)
SpiralGalaxyLoader- Rotating spiral armsSpiralRadiatingLoader- Spiral with radiating pulseFibonacciSpiralLoader- Golden ratio spiralSilverSpiralLoader- Silver ratio spiralSunflowerSpiralLoader- Sunflower seed patternRotatingOrbitsLoader- Rotating orbital pathsConcentricRotationsLoader- Concentric rotating ringsOrbitalPulseLoader- Orbital pulse animation
Grid & Pattern (5 loaders)
BreathingGridLoader- Grid with radial expansionPulsingGridLoader- Pulsing grid patternInterferenceGridLoader- Wave interference patternHalftoneGradientLoader- Halftone dot patternVoronoiOrganicLoader- Voronoi diagram animation
3D & Geometric (12 loaders)
SphereScanLoader- 3D sphere scan effectCrystallineRefractionLoader- Crystal refractionCrystallineCubeRefractionLoader- 3D cube refractionHelixScannerLoader- DNA helix scannerCylindricalAnalysisLoader- Cylindrical projectionVoxelMatrixMorphLoader- Voxel matrix morphingTriAxialGimbalLoader- 3D gimbal rotationScatterPlot3DLoader- 3D scatter plotPyramidDotLoader- Pyramid dot formationDNADoubleHelixLoader- DNA double helixTorusKnotFlowLoader- Torus knot topologyTesseract4DLoader- 4D hypercube projection
Mathematical & Physics (11 loaders)
MobiusRibbonLoader- Mรถbius strip topologyPolarLissajousLoader- Lissajous curvesSphericalHarmonicsLoader- Spherical harmonicsLorenzAttractorLoader- Lorenz attractor chaosQuasicrystalPenroseLoader- Penrose tilingKleinBottleLoader- Klein bottle topologyQuantumOrbitalLoader- Quantum orbital patternsHopfFibrationLoader- Hopf fibrationAiryDiskLoader- Airy disk diffractionNewtonsCraddleLoader- Newton's cradle physicsDoublePendulumChaosLoader- Chaotic double pendulum
Organic & Natural (6 loaders)
FlowingEnergyLoader- Flowing energy bandsReactionDiffusionLoader- Reaction-diffusion systemBinaryTreeGrowthLoader- Binary tree growthVoronoiOrganicLoader- Organic Voronoi cellsFerrofluidSpikesLoader- Ferrofluid spike simulationFluidOrbLoader- Fluid dynamics orb
Scan & Radar (5 loaders)
RadiatingScanLoader- Rotating scan linesSonarSweepLoader- Sonar sweep effectPhasedArrayEmitterLoader- Phased array emissionSphereScanLoader- Spherical scan
Rings & Circles (6 loaders)
ConcentricRingsLoader- Concentric ring animationSequentialRingsLoader- Sequential ring appearanceStretchedRingsLoader- Radially stretched ringsExpandingLinesLoader- Expanding line segmentsPulsatingCirclesLoader- Pulsating circles
Specialized (4 loaders)
BouncingProgressBarLoader- Bouncing progress barBouncingBarGraphLoader- Animated bar graphECGHeartbeatLoader- ECG heartbeat monitorPlaceholderSkeletonLoader- Skeleton placeholderTripleBouncingDotsLoader- Three bouncing dotsOscillatingDotsLoader- Oscillating dot patternMandelbrotZoomLoader- Mandelbrot set zoomBlackHoleAccretionLoader- Black hole accretion disk
View the complete list with live demos in the Interactive Playground
๐ Common Props (BaseLoaderProps)
All loaders accept these props:
Basic Props
| Prop | Type | Default | Description |
|---|---|---|---|
size |
number |
180 |
Canvas size in pixels |
animationSpeed |
number |
1 |
Animation speed multiplier (0.1-3) |
dotColor |
string |
'#ffffff' |
Primary color for dots/elements |
backgroundColor |
string |
'transparent' |
Canvas background color |
className |
string |
'' |
Additional CSS classes |
opacity |
number |
1 |
Global opacity (0-1) |
paused |
boolean |
false |
Pause the animation |
onAnimationFrame |
(time: number) => void |
undefined |
Callback on each frame |
Advanced Props
| Prop | Type | Default | Description |
|---|---|---|---|
dotStyle |
DotStyleFunction |
undefined |
Function to customize individual dots |
dotGradientConfig |
GradientConfig |
undefined |
Gradient configuration for dots |
backgroundGradient |
GradientConfig |
undefined |
Gradient configuration for background |
theme |
ThemeConfig |
undefined |
Theme detection and color switching |
mask |
SVGMaskConfig |
undefined |
SVG mask to apply to the loader |
See ADVANCED_FEATURES.md for detailed documentation on advanced props.
๐ก Usage Examples
Basic Usage
import { PulseWaveLoader } from 'filoaders';
import 'filoaders/styles.css';
function LoadingScreen() {
return (
<div style={{ display: 'flex', justifyContent: 'center', padding: '50px' }}>
<PulseWaveLoader />
</div>
);
}Custom Colors
<PulseWaveLoader
size={200}
dotColor="#3b82f6"
backgroundColor="#000000"
/>Custom Speed
<SpiralGalaxyLoader
animationSpeed={2} // 2x speed
size={180}
/>Controlled Animation
function ControlledLoader() {
const [paused, setPaused] = useState(false);
return (
<div>
<button onClick={() => setPaused(!paused)}>
{paused ? 'Resume' : 'Pause'}
</button>
<PulseWaveLoader paused={paused} />
</div>
);
}Animation Callback
<PulseWaveLoader
onAnimationFrame={(time) => {
console.log(`Animation time: ${time}s`);
}}
/>Multiple Loaders
import {
PulseWaveLoader,
SpiralGalaxyLoader,
BreathingGridLoader,
} from 'filoaders';
function LoaderShowcase() {
return (
<div style={{ display: 'flex', gap: '20px' }}>
<PulseWaveLoader dotColor="#3b82f6" />
<SpiralGalaxyLoader dotColor="#10b981" />
<BreathingGridLoader dotColor="#ef4444" />
</div>
);
}๐๏ธ Architecture
Filoaders is built with SOLID principles:
- Single Responsibility: Each loader handles one animation type
- Open/Closed: Extensible through props, closed for modification
- Liskov Substitution: All loaders are interchangeable via BaseLoaderProps
- Interface Segregation: Common interface with optional specific props
- Dependency Inversion: Components depend on abstractions (hooks/utils)
Project Structure
src/
โโโ types/ # TypeScript interfaces
โโโ utils/ # Shared utilities
โ โโโ canvas.ts # Canvas helpers
โ โโโ colors.ts # Color management
โ โโโ animation.ts # Animation utilities
โโโ components/
โ โโโ BaseLoader/ # Base animation hook
โ โโโ [LoaderName]/ # Individual loaders
โโโ index.ts # Main exports๐ ๏ธ Development
Setup
# Clone the repo
git clone https://github.com/your-org/filoaders.git
cd filoaders
# Install dependencies
yarn installDevelopment Commands
# Run demo app with Vite
yarn dev
# Launch Storybook
yarn storybook
# Build library for production
yarn build
# Build Storybook for deployment
yarn build-storybookDemo App
The demo app (/demo) showcases all loaders with live controls:
- Adjust size, speed, opacity
- Change colors in real-time
- Pause/resume animations
- Test different configurations
Storybook
Interactive component documentation with:
- Individual loader stories
- Prop controls
- Color variants
- Usage examples
๐ TypeScript Support
Full TypeScript support with exported types:
import type {
BaseLoaderProps,
PulseWaveLoaderProps,
AnimationState,
RingConfig,
} from 'filoaders';
const loaderProps: PulseWaveLoaderProps = {
size: 180,
dotColor: '#ffffff',
animationSpeed: 1,
};๐จ Customization
Custom Themes
const theme = {
primary: '#3b82f6',
secondary: '#8b5cf6',
success: '#10b981',
error: '#ef4444',
};
<PulseWaveLoader dotColor={theme.primary} />Responsive Sizing
function ResponsiveLoader() {
const size = useWindowSize();
const loaderSize = size.width < 768 ? 120 : 180;
return <PulseWaveLoader size={loaderSize} />;
}๐ Performance
- Canvas-based rendering for smooth 60fps animations
- RequestAnimationFrame for optimal performance
- Automatic cleanup on unmount
- No layout thrashing - pure canvas operations
๐ค Contributing
Contributions are welcome! Please read our contributing guidelines.
๐ License
MIT ยฉ [Your Name]
๐ Links
Built with โค๏ธ using TypeScript, React, and Canvas API