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

tailwindsql

> 编程语言
Open source

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

1.3K stars0 likes1 views
WebsiteGitHub

About

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

TailwindSQL

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

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!

javascript
// Fetch and render a user's name

// Renders: "Ada Lovelace"

// Render products as a list

// Renders: 

Mechanical Keyboard
...

// Order by price and show 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

bash
# 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

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 推出的简洁高效系统语言