An interactive playground for learning and experimenting with CSS Grid layouts using Tailwind CSS. Visual building, code generation, and advanced grid controls.
- Interactive Grid System: Drag and drop blocks to position them within the grid.
- Multi-Selection: Select multiple blocks via Shift+Click or by dragging a selection area. Group drag and delete operations supported.
- Customizable Layout: Adjust columns (up to 12), rows, and gutter sizes visually.
- Resizing: Intuitive resize handles on blocks to modify column and row spans.
- Code Generation:
- Tailwind CSS: Instant utility class generation.
- CSS/HTML: Standard CSS Grid and HTML export option.
- Persistent State: Your grid layout and settings are automatically saved to local storage.
- Responsive Design: Mobile-friendly interface with touch support.
- Dark Mode: Sleek, modern dark UI.
- Framework: Next.js 15+ (App Router)
- Styling: Tailwind CSS 4
- Drag & Drop: @dnd-kit/core
- Icons: Lucide React
- Components: Radix UI primitives & custom components.
- State Management: React Hooks + Local Storage persistence.
- Node.js 18+ or Bun 1.0+
- Clone the repository:
git clone <repository-url>
- Navigate to the project directory:
cd grid-app - Install dependencies:
npm install # or bun install
Start the development server:
npm run dev
# or
bun devOpen http://localhost:3000 to view the app.
- Add Blocks: Click the "+" button in the toolbar to add new blocks (auto-placed in available space).
- Selection:
- Single: Click a block.
- Multi: Shift+Click multiple blocks or drag a selection box across the grid background.
- Move: Drag selected blocks to reposition them. Moved blocks snap to the grid.
- Resize: Drag the corner handles on a selected block to change its span.
- Edit: Use the "Edit" button (for single blocks) to manually input col/row values.
- Code Export: Click the "Code" button to view generated code. Toggle between Tailwind and CSS modes.
- Settings: Adjust grid columns, rows, and gap size via the "Grid" settings panel.
app/: Next.js App Router structure.components/:grid-playground.tsx: Core logic (state, dnd sensors, layout).grid-block.tsx: Block component with resize handles and drag listeners.grid-selection-area.tsx: Logic for drag-to-select functionality.grid-settings.tsx: Grid configuration UI.code-panel.tsx: Code export viewer (Tailwind/CSS).toolbar.tsx: Actions for adding/deleting blocks.ui/: Shared UI components.
hooks/: Custom hooks (e.g.,usePersistentState).
MIT License
