GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - mmarinovic/tailwindsql: TailwindSQL lets you write SQL queries using Tailwind-style class names.

BranchesTags
Open more actions menu

Latest commit

 

History

1 Commit
1 Commit

Folders and files

NameName
Last commit message
Last commit date
.cursor/commands
.cursor/commands
 
 
scripts
scripts
 
 
src
src
 
 
.gitignore
.gitignore
 
 
README.md
README.md
 
 
next.config.js
next.config.js
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
postcss.config.js
postcss.config.js
 
 
repository.url
repository.url
 
 
tailwind.config.js
tailwind.config.js
 
 
tsconfig.json
tsconfig.json
 
 

Repository files navigation

TailwindSQL šŸŽØ

Like TailwindCSS, but for SQL queries in React Server Components.

GitHub

What is this?

TailwindSQL lets you write SQL queries using Tailwind-style class names. Just use className to query your database directly in React Server Components!

// Fetch and render a user's name
<DB className="db-users-name-where-id-1" />
// Renders: "Ada Lovelace"

// Render products as a list
<DB className="db-products-title-limit-5" as="ul" />
// Renders: <ul><li>Mechanical Keyboard</li>...</ul>

// Order by price and show as table
<DB className="db-products-orderby-price-desc" as="table" />

Features

  • šŸŽØ Tailwind-style syntax - Write SQL queries using familiar class names
  • ⚔ React Server Components - Zero client-side JavaScript for queries
  • šŸ”’ SQLite - Built on better-sqlite3 for fast, local database access
  • šŸŽÆ Zero Runtime - Queries are parsed and executed at build/render time
  • šŸŽ­ Multiple Render Modes - Render as text, lists, tables, or JSON

Syntax

db-{table}-{column}-where-{field}-{value}-limit-{n}-orderby-{field}-{asc|desc}

Examples

Class Name SQL Query
db-users SELECT * FROM users
db-users-name SELECT name FROM users
db-users-where-id-1 SELECT * FROM users WHERE id = 1
db-posts-title-limit-10 SELECT title FROM posts LIMIT 10
db-products-orderby-price-desc SELECT * FROM products ORDER BY price DESC

Getting Started

Prerequisites

  • Node.js 18+
  • npm or yarn

Installation

# Clone the repository
git clone https://github.com/mmarinovic/tailwindsql.git
cd tailwindsql

# Install dependencies
npm install

# Seed the database with demo data
npm run seed

# Start the development server
npm run dev

Open http://localhost:3000 to see the demo and interactive playground!

How It Works

  1. Parser (src/lib/parser.ts) - Parses class names into query configurations
  2. Query Builder (src/lib/query-builder.ts) - Transforms configs into safe SQL queries
  3. DB Component (src/components/DB.tsx) - React Server Component that executes queries and renders results

Render Modes

The as prop controls how results are rendered:

Value Description
span Inline text (default)
div Block element
ul Unordered list
ol Ordered list
table HTML table
json JSON code block

Project Structure

tailwindsql/
ā”œā”€ā”€ src/
│   ā”œā”€ā”€ app/              # Next.js app directory
│   │   ā”œā”€ā”€ page.tsx      # Landing page
│   │   └── api/          # API routes
│   ā”œā”€ā”€ components/        # React components
│   │   ā”œā”€ā”€ DB.tsx        # Main DB component
│   │   ā”œā”€ā”€ Example.tsx   # Example components
│   │   └── Playground.tsx # Interactive playground
│   └── lib/              # Core logic
│       ā”œā”€ā”€ parser.ts     # Class name parser
│       ā”œā”€ā”€ query-builder.ts # SQL query builder
│       └── db.ts         # Database connection
└── README.md

Why?

This project was built to explore css-driven database queries.

License

MIT - Do whatever you want with it (except deploy to production šŸ˜…)


Built with šŸ’œ using Next.js, SQLite, and questionable decisions

About

TailwindSQL lets you write SQL queries using Tailwind-style class names.

tailwindsql.xyz/

Resources

Readme
Activity

Stars

1.3k stars

Watchers

0 watching

Forks

53 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800Ɨ600. No cookies required.