New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

th-loading

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

th-loading

A customizable React loading component with a spinning animation.

latest
npmnpm
Version
1.0.4
Version published
Maintainers
1
Created
Source

React Loading Component

A customizable React loading component with a spinning animation.

📦 Installation

npm install th-loading

Usage

✅ Basic Usage

import { Loading } from 'th-loading';

function App() {
  return <Loading />; // Uses default loading image
}

🖼️ Custom Image

import { Loading } from 'th-loading';

function App() {
  return (
    <Loading imageUrl="https://path.to/your/custom/loading.gif" />
  );
}

⚙️ Props

PropTypeRequiredDefaultDescription
imageUrlstringNo"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRFzebLh8zihBChP2pwfn2kwgJr2_IgwxSIqQ&s"URL of the loading image

🎨 Styling

The component comes with default styles but can be customized using CSS. Below are the default classes:

/* Centers the loader in its container */
.loader-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
}

/* Styles for the loading image */
.loader {
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

💡 Example: Conditional Loading State

import React, { useState, useEffect } from 'react';
import { Loading } from 'th-loading';

function MyComponent() {
  const [isLoading, setIsLoading] = useState(true);

  useEffect(() => {
    setTimeout(() => setIsLoading(false), 3000); // Simulate loading
  }, []);

  return (
    <div>
      {isLoading ? <Loading /> : <div>Your content here</div>}
    </div>
  );
}

🌐 Browser Support

Compatible with all modern browsers:

  • Chrome
  • Firefox
  • Safari
  • Edge

🤝 Contributing

Contributions are welcome! Please feel free to open an issue or submit a Pull Request.

📄 License

MIT © Refael Levi

🆘 Support

If you encounter any issues or have questions, please open an issue on GitHub.

FAQs

Package last updated on 01 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts