1.0.0 • Published 6 months ago

react-clouds v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

React Clouds

A customizable React component for creating beautiful, layered clouds. Perfect for creating atmospheric backgrounds and decorative elements in your React applications.

Installation

npm install react-clouds
# or
yarn add react-clouds

Features

  • Fully customizable cloud appearance (size, color, position)
  • Support for single or multiple cloud layers
  • Responsive design - automatically adjusts to container width
  • TypeScript support
  • Lightweight with minimal dependencies
  • Smooth shadow-based rendering

Basic Usage

import { Clouds } from 'react-clouds';

const SimpleExample = () => (
  <div style={{ position: 'relative', height: '200px', background: '#ffa6b9' }}>
    <Clouds size={100} color="#ffffff" />
  </div>
);

Advanced Usage - Cloud Layers

import { CloudLayers } from 'react-clouds';

const LayeredExample = () => (
  <CloudLayers
    height="24rem"
    backgroundColor="#ffa6b9"
    shadowOpacity={0.1}
    layers={[
      {
        size: 120,
        color: '#ffdbde',
        bottomOffset: 160,
        randomization: {
          xMin: 0.5,
          xMax: 0.7,
          yMin: 0.1,
          yMax: 0.3,
          initialX: 0.4,
        },
      },
      {
        size: 100,
        color: '#ffffff',
        bottomOffset: 0,
        randomization: {
          xMin: 0.4,
          xMax: 0.6,
          yMin: 0.03,
          yMax: 0.2,
          initialX: 0.5,
        },
      },
    ]}
  />
);

API Reference

Clouds Component Props

PropTypeDefaultDescription
sizenumber100Size of each cloud in pixels
colorstring'#ffffff'Color of the clouds
bottomOffsetnumber0Distance from the bottom of the container
xMinMultipliernumber0.45Minimum multiplier for horizontal spacing
xMaxMultipliernumber0.6Maximum multiplier for horizontal spacing
yMinMultipliernumber0.05Minimum multiplier for vertical variation
yMaxMultipliernumber0.25Maximum multiplier for vertical variation
initialXOffsetnumber0.45Initial horizontal offset
classNamestring''Additional CSS classes
styleobject{}Additional inline styles

CloudLayers Component Props

PropTypeDefaultDescription
backgroundColorstring'#ffa6b9'Background color of the container
heightstring | number'24rem'Height of the container
shadowOpacitynumber0.1Opacity of cloud shadows
layersLayer[]...Array of layer configurations
classNamestring''Additional CSS classes
styleobject{}Additional inline styles

Layer Configuration

Each layer in the layers array accepts the following properties:

interface Layer {
  size: number;
  color: string;
  bottomOffset: number;
  randomization?: {
    xMin?: number;
    xMax?: number;
    yMin?: number;
    yMax?: number;
    initialX?: number;
  };
}

License

MIT © Sahil Tandon

1.0.0

6 months ago