Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
T

thiings-grid

> 编程语言
Open source

A high-performance, infinite scrolling grid component for React that provides smooth touch/mouse interactions with momentum-based scrolling.

386 stars0 likes1 views
WebsiteGitHub

About

A high-performance, infinite scrolling grid component for React that provides smooth touch/mouse interactions with momentum-based scrolling.

ThiingsGrid

A high-performance, infinite scrolling grid component for React that provides smooth touch/mouse interactions with momentum-based scrolling. Perfect for displaying large datasets in a grid format with custom cell renderers.

Explore Thiings.co →

This is the component that powers the interactive grid on thiings.co - A growing collection of 1200+ free 3D icons, generated with AI.

Try the Live Playground →

Experience ThiingsGrid in action with interactive examples and copy-paste ready code.

✨ Features

  • High Performance: Only renders visible cells with optimized viewport calculations
  • Touch & Mouse Support: Smooth interactions on both desktop and mobile
  • Momentum Scrolling: Natural physics-based scrolling with inertia
  • ♾️ Infinite Grid: Supports unlimited grid sizes with efficient rendering
  • Custom Renderers: Flexible cell rendering with your own components
  • TypeScript Support: Full type safety with comprehensive TypeScript definitions

Quick Start

Installation

This component is currently part of this repository. To use it in your project:

  1. Copy the lib/ThiingsGrid.tsx file to your project
  2. Install the required dependencies:
bash
npm install react react-dom

Basic Usage

typescript
import ThiingsGrid, { type ItemConfig } from './path/to/ThiingsGrid';

const MyCell = ({ gridIndex, position }: ItemConfig) => (
  

);

const App = () => (
  

);

API Reference

ThiingsGridProps

Prop Type Required Default Description
gridSize number ✅ - Size of each grid cell in pixels
renderItem (config: ItemConfig) => ReactNode ✅ - Function to render each grid cell
className string ❌ - CSS class name for the container
initialPosition Position ❌ { x: 0, y: 0 } Initial scroll position

ItemConfig

The renderItem function receives an ItemConfig object with:

Property Type Description
gridIndex number Unique index for the grid cell
position Position Grid coordinates { x: number, y: number }
isMoving boolean Whether the grid is currently being moved/scrolled

Position

typescript
type Position = {
  x: number;
  y: number;
};

Examples

Simple Numbers

typescript
import ThiingsGrid, { type ItemConfig } from "./ThiingsGrid";

const SimpleNumberCell = ({ gridIndex }: ItemConfig) => (
  

);

export const SimpleNumbers = () => (
  
);

Colorful Grid

typescript
const ColorfulCell = ({ gridIndex }: ItemConfig) => {
  const colors = [
    "bg-red-300",
    "bg-green-300", 
    "bg-blue-300",
    "bg-yellow-300",
    "bg-pink-300",
    "bg-cyan-300",
  ];
  const colorClass = colors[gridIndex % colors.length];

  return (
    

  );
};

export const ColorfulGrid = () => (
  
);

Interactive Cards

typescript
const CardCell = ({ gridIndex, position, isMoving }: ItemConfig) => (
  

    

  
);

export const CardLayout = () => (
  
);

Best Practices

Cell Positioning

Always use absolute positioning within your cell components for optimal performance:

typescript
// ✅ Good
const MyCell = ({ gridIndex }: ItemConfig) => (
  

);

// ❌ Avoid - can cause layout issues
const MyCell = ({ gridIndex }: ItemConfig) => (
  

);

Performance Optimization

For better performance with complex cells:

typescript
const OptimizedCell = React.memo(({ gridIndex, isMoving }: ItemConfig) => {
  // Expensive calculations here
  const computedValue = useMemo(() => {
    return expensiveCalculation(gridIndex);
  }, [gridIndex]);

  return (
    

  );
});

Container Setup

Ensure the ThiingsGrid has a defined container size:

typescript
// ✅ Good - explicit container size

// ✅ Good - CSS classes with defined dimensions

Advanced Usage

Custom Grid Index Calculation

The gridIndex is calculated based on the grid position using a custom algorithm that provides unique indices for each cell position.

Accessing Grid Position

You can access the current grid position programmatically:

typescript
const MyComponent = () => {
  const gridRef = useRef(null);

  const getCurrentPosition = () => {
    if (gridRef.current) {
      const position = gridRef.current.publicGetCurrentPosition();
      console.log('Current position:', position);
    }
  };

  return (
    
  );
};

Responsive Grid Sizes

typescript
const useResponsiveGridSize = () => {
  const [gridSize, setGridSize] = useState(80);

  useEffect(() => {
    const handleResize = () => {
      const width = window.innerWidth;
      if (width  window.removeEventListener('resize', handleResize);
  }, []);

  return gridSize;
};

const ResponsiveGrid = () => {
  const gridSize = useResponsiveGridSize();
  
  return (
    
  );
};

Interaction

Touch/Mouse Events

The component handles:

  • Mouse: Click and drag to pan
  • Touch: Touch and drag to pan
  • Wheel: Scroll wheel for precise movements
  • Momentum: Automatic momentum scrolling with physics

Development

Running the Demo

bash
# Install dependencies
npm install

# Start development server
npm run dev

# Build for production
npm run build

Project Structure

src/
├── examples/           # Example implementations
│   ├── SimpleNumbers.tsx
│   ├── ColorfulGrid.tsx
│   ├── EmojiFun.tsx
│   └── CardLayout.tsx
├── App.tsx            # Main demo application
├── Playground.tsx     # Example viewer
├── SourceCode.tsx     # Source code display
└── Sidebar.tsx        # Example navigation

lib/
└── ThiingsGrid.tsx    # Main component

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

MIT License - see the LICENSE file for details.

Acknowledgments

  • Built with React and TypeScript
  • Styled with Tailwind CSS
  • Bundled with Vite

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScript

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言