Tailwind classes in OCaml

Compare changes

Choose any two refs to compare.

+7
.agent/CLAUDE.md
···
+
My goal is to build a high quality professions OCaml library to generate
+
Tailwind CSS components. Build a core `tailwind` library that serialises the
+
CSS into strings. Then build a `tailwind-html` library that uses the Htmlit
+
OCaml HTML generation library https://github.com/dbuenzli/htmlit for common
+
components.
+
+
You can find full Tailwind docs in tailwind-llms.txt in this directory.
+1422
.agent/tailwind-llms.txt
···
+
# Tailwind CSS v4 LLM Development Guidelines
+
+
You are an expert web developer specializing in Tailwind CSS v4. Follow these guidelines when writing code or providing recommendations.
+
+
## Core Principles
+
+
Tailwind CSS v4 is a complete rewrite with a new high-performance Oxide engine, CSS-first configuration, and modern web platform features. It requires modern browsers (Safari 16.4+, Chrome 111+, Firefox 128+) and is NOT compatible with older browsers.
+
+
## Installation & Setup
+
+
### Basic Setup
+
```css
+
/* styles.css */
+
@import "tailwindcss";
+
```
+
+
### With Vite
+
```js
+
// vite.config.js
+
import { defineConfig } from 'vite'
+
import tailwindcss from '@tailwindcss/vite'
+
+
export default defineConfig({
+
plugins: [tailwindcss()]
+
})
+
```
+
+
### Package Installation
+
```bash
+
npm install tailwindcss@next @tailwindcss/vite@next
+
```
+
+
## Configuration (CSS-First)
+
+
**IMPORTANT**: v4 uses CSS-first configuration, NOT JavaScript config files. Use the `@theme` directive in your CSS file:
+
+
```css
+
@import "tailwindcss";
+
+
@theme {
+
/* Colors (use OKLCH for wider gamut) */
+
--color-brand-50: oklch(0.98 0.01 142.12);
+
--color-brand-500: oklch(0.64 0.15 142.12);
+
--color-brand-900: oklch(0.25 0.08 142.12);
+
+
/* Typography */
+
--font-display: "Satoshi", "Inter", sans-serif;
+
--font-body: "Inter", system-ui, sans-serif;
+
+
/* Spacing */
+
--spacing-18: 4.5rem;
+
--spacing-72: 18rem;
+
+
/* Breakpoints */
+
--breakpoint-3xl: 1920px;
+
--breakpoint-4xl: 2560px;
+
+
/* Shadows */
+
--shadow-brutal: 8px 8px 0px 0px #000;
+
+
/* Animation */
+
--animate-wiggle: wiggle 1s ease-in-out infinite;
+
}
+
+
/* Define keyframes for animations */
+
@keyframes wiggle {
+
0%, 100% { transform: rotate(-3deg); }
+
50% { transform: rotate(3deg); }
+
}
+
```
+
+
### Legacy Config Support (if needed)
+
```css
+
@import "tailwindcss";
+
@config "./tailwind.config.js";
+
```
+
+
## Breaking Changes from v3
+
+
### Import Changes
+
- โŒ `@tailwind base; @tailwind components; @tailwind utilities;`
+
- โœ… `@import "tailwindcss";`
+
+
### Removed Utilities
+
- `text-opacity-*` โ†’ Use `text-{color}/{opacity}` instead
+
- `bg-opacity-*` โ†’ Use `bg-{color}/{opacity}` instead
+
- `border-opacity-*` โ†’ Use `border-{color}/{opacity}` instead
+
- `flex-grow-*` โ†’ Use `grow-*`
+
- `flex-shrink-*` โ†’ Use `shrink-*`
+
- `decoration-slice` โ†’ Use `box-decoration-slice`
+
+
### Renamed Utilities
+
- `shadow-sm` โ†’ `shadow-xs`
+
- `rounded-sm` โ†’ `rounded-xs`
+
- `blur-sm` โ†’ `blur-xs`
+
- `bg-gradient-*` โ†’ `bg-linear-*`
+
+
### Default Behavior Changes
+
- **Border**: No longer defaults to gray-200, uses `currentColor`
+
- **Ring**: Changed from 3px blue to 1px `currentColor`
+
- **Outline**: Now 1px by default for consistency
+
+
## Custom Utilities
+
+
Use the `@utility` directive instead of `@layer utilities`:
+
+
```css
+
@utility btn {
+
padding: 0.5rem 1rem;
+
border-radius: 0.375rem;
+
font-weight: 500;
+
transition: all 0.2s;
+
}
+
+
@utility btn-primary {
+
background: var(--color-blue-600);
+
color: white;
+
+
&:hover {
+
background: var(--color-blue-700);
+
}
+
}
+
+
/* Functional utilities with parameters */
+
@utility margin-auto {
+
margin: auto;
+
}
+
+
@utility flex-center {
+
display: flex;
+
justify-content: center;
+
align-items: center;
+
}
+
```
+
+
## Custom Variants
+
+
```css
+
@custom-variant theme-dark {
+
&:where([data-theme="dark"] *) {
+
@slot;
+
}
+
}
+
+
@custom-variant any-hover {
+
@media (any-hover: hover) {
+
&:hover {
+
@slot;
+
}
+
}
+
}
+
```
+
+
## New Features in v4
+
+
### Container Queries (Built-in)
+
```html
+
<div class="@container">
+
<div class="grid grid-cols-1 @sm:grid-cols-2 @lg:grid-cols-3">
+
<div class="@min-w-64:text-lg @max-w-96:bg-blue-100">
+
Responsive to container size
+
</div>
+
</div>
+
</div>
+
```
+
+
### 3D Transforms
+
```html
+
<div class="perspective-1000">
+
<div class="rotate-x-45 rotate-y-12 scale-z-110 translate-z-24 transform-3d">
+
3D transformed element
+
</div>
+
</div>
+
```
+
+
### Enhanced Gradients
+
```html
+
<!-- Linear gradients with angles -->
+
<div class="bg-linear-45 from-blue-500 to-purple-500"></div>
+
+
<!-- Radial gradients -->
+
<div class="bg-radial from-red-500 via-yellow-500 to-orange-500"></div>
+
+
<!-- Conic gradients -->
+
<div class="bg-conic from-pink-500 via-blue-500 to-green-500"></div>
+
```
+
+
### Text Shadows
+
```html
+
<h1 class="text-shadow-lg text-shadow-blue-500/50">
+
Text with colored shadow
+
</h1>
+
```
+
+
### Mask Utilities
+
```html
+
<div class="mask-radial mask-cover">
+
<img src="image.jpg" alt="Masked image" />
+
</div>
+
```
+
+
### New Variants
+
+
#### @starting-style (for animations)
+
```html
+
<div class="opacity-100 @starting-style:opacity-0 transition-opacity">
+
Animates in on mount
+
</div>
+
```
+
+
#### not-* variant
+
```html
+
<div class="bg-blue-500 not-hover:bg-gray-500">
+
Blue except when hovering
+
</div>
+
```
+
+
#### nth-* variants
+
```html
+
<div class="nth-2:bg-red-500 nth-odd:bg-blue-500">
+
Nth child styling
+
</div>
+
```
+
+
#### inert variant
+
```html
+
<div class="inert:opacity-50 inert:pointer-events-none">
+
Styled when inert
+
</div>
+
```
+
+
#### in-* variant (like group-* but without group class)
+
```html
+
<article>
+
<h2 class="in-article:text-lg">Styled when inside article</h2>
+
</article>
+
```
+
+
### Modern Color System
+
v4 uses OKLCH color space for wider gamut support:
+
+
```css
+
@theme {
+
--color-brand-primary: oklch(0.7 0.15 180);
+
--color-brand-accent: oklch(0.8 0.2 45);
+
}
+
```
+
+
## Multi-Theme Strategy
+
+
```css
+
@import "tailwindcss";
+
+
@theme {
+
--color-primary: oklch(0.5 0.2 240);
+
--color-background: oklch(0.98 0.01 240);
+
}
+
+
@layer base {
+
[data-theme='dark'] {
+
--color-primary: oklch(0.7 0.2 240);
+
--color-background: oklch(0.15 0.02 240);
+
}
+
+
[data-theme='high-contrast'] {
+
--color-primary: oklch(0.0 0 0);
+
--color-background: oklch(1.0 0 0);
+
}
+
}
+
```
+
+
## Best Practices
+
+
### 1. Use CSS Variables for Dynamic Values
+
```html
+
<div class="bg-[var(--dynamic-color)] text-[var(--dynamic-size)]">
+
Dynamic styling
+
</div>
+
```
+
+
### 2. Leverage the New Color System
+
```html
+
<!-- Better contrast and vibrancy with OKLCH -->
+
<div class="bg-blue-500 text-white">
+
Vivid colors on modern displays
+
</div>
+
```
+
+
### 3. Container Queries for True Responsive Design
+
```html
+
<div class="@container">
+
<div class="p-4 @lg:p-8 @xl:p-12">
+
Responds to container, not viewport
+
</div>
+
</div>
+
```
+
+
### 4. Modern CSS Features
+
```html
+
<!-- Native cascade layers -->
+
<div class="layer-[utilities]:z-10">
+
Proper layer management
+
</div>
+
+
<!-- Color mixing -->
+
<div class="bg-blue-500/50">
+
Uses color-mix() under the hood
+
</div>
+
```
+
+
## Performance Optimizations
+
+
v4's Oxide engine provides:
+
- 5x faster full builds
+
- 100x faster incremental builds
+
- Automatic content detection
+
- Built-in import handling
+
- Native vendor prefixing
+
+
## File Organization
+
+
```
+
src/
+
โ”œโ”€โ”€ styles/
+
โ”‚ โ”œโ”€โ”€ main.css # @import "tailwindcss" + @theme
+
โ”‚ โ”œโ”€โ”€ components.css # @utility definitions
+
โ”‚ โ””โ”€โ”€ utilities.css # Additional @utility definitions
+
โ””โ”€โ”€ components/
+
โ””โ”€โ”€ *.vue/jsx/html # Your components
+
```
+
+
## Common Patterns
+
+
### Theme-aware Components
+
```css
+
@utility card {
+
background: var(--color-background);
+
border: 1px solid var(--color-border);
+
border-radius: 0.5rem;
+
padding: 1.5rem;
+
box-shadow: var(--shadow-sm);
+
}
+
```
+
+
### Responsive Typography
+
```html
+
<h1 class="text-2xl @sm:text-3xl @lg:text-4xl @xl:text-5xl">
+
Container-responsive heading
+
</h1>
+
```
+
+
### Animation with @starting-style
+
```html
+
<div class="translate-y-0 @starting-style:translate-y-full transition-transform duration-500">
+
Slides up on mount
+
</div>
+
```
+
+
## Debugging Tips
+
+
1. **Use browser dev tools** to inspect CSS variables
+
2. **Check cascade layers** in dev tools
+
3. **Verify modern browser support** for OKLCH colors
+
4. **Use @reference** for CSS modules/component styles
+
5. **Restart dev server** after major theme changes
+
+
## Migration from v3
+
+
1. Replace `@tailwind` directives with `@import "tailwindcss"`
+
2. Move config from JS to CSS using `@theme`
+
3. Update deprecated utility classes
+
4. Replace `@layer utilities` with `@utility`
+
5. Test in modern browsers only
+
6. Use the official upgrade tool: `npx @tailwindcss/upgrade@next`
+
+
## Complete Utility Class Reference
+
+
### Layout
+
+
#### Display
+
```
+
block, inline-block, inline, flex, inline-flex, table, inline-table, table-caption, table-cell, table-column, table-column-group, table-footer-group, table-header-group, table-row-group, table-row, flow-root, grid, inline-grid, contents, list-item, hidden
+
```
+
+
#### Position
+
```
+
static, fixed, absolute, relative, sticky
+
```
+
+
#### Top/Right/Bottom/Left
+
```
+
inset-0, inset-x-0, inset-y-0, start-0, end-0, top-0, right-0, bottom-0, left-0
+
inset-px, inset-x-px, inset-y-px, start-px, end-px, top-px, right-px, bottom-px, left-px
+
inset-0.5, inset-1, inset-1.5, inset-2, inset-2.5, inset-3, inset-3.5, inset-4, inset-5, inset-6, inset-7, inset-8, inset-9, inset-10, inset-11, inset-12, inset-14, inset-16, inset-20, inset-24, inset-28, inset-32, inset-36, inset-40, inset-44, inset-48, inset-52, inset-56, inset-60, inset-64, inset-72, inset-80, inset-96
+
inset-auto, inset-1/2, inset-1/3, inset-2/3, inset-1/4, inset-2/4, inset-3/4, inset-full
+
```
+
+
#### Visibility & Z-Index
+
```
+
visible, invisible, collapse
+
z-0, z-10, z-20, z-30, z-40, z-50, z-auto
+
```
+
+
#### Overflow
+
```
+
overflow-auto, overflow-hidden, overflow-clip, overflow-visible, overflow-scroll
+
overflow-x-auto, overflow-x-hidden, overflow-x-clip, overflow-x-visible, overflow-x-scroll
+
overflow-y-auto, overflow-y-hidden, overflow-y-clip, overflow-y-visible, overflow-y-scroll
+
```
+
+
### Flexbox & Grid
+
+
#### Flex Direction
+
```
+
flex-row, flex-row-reverse, flex-col, flex-col-reverse
+
```
+
+
#### Flex Wrap
+
```
+
flex-wrap, flex-wrap-reverse, flex-nowrap
+
```
+
+
#### Flex
+
```
+
flex-1, flex-auto, flex-initial, flex-none
+
```
+
+
#### Grow & Shrink
+
```
+
grow, grow-0, shrink, shrink-0
+
```
+
+
#### Order
+
```
+
order-1, order-2, order-3, order-4, order-5, order-6, order-7, order-8, order-9, order-10, order-11, order-12, order-first, order-last, order-none
+
```
+
+
#### Grid Template Columns
+
```
+
grid-cols-1, grid-cols-2, grid-cols-3, grid-cols-4, grid-cols-5, grid-cols-6, grid-cols-7, grid-cols-8, grid-cols-9, grid-cols-10, grid-cols-11, grid-cols-12, grid-cols-none, grid-cols-subgrid
+
```
+
+
#### Grid Column Start/End
+
```
+
col-auto, col-span-1, col-span-2, col-span-3, col-span-4, col-span-5, col-span-6, col-span-7, col-span-8, col-span-9, col-span-10, col-span-11, col-span-12, col-span-full
+
col-start-1, col-start-2, col-start-3, col-start-4, col-start-5, col-start-6, col-start-7, col-start-8, col-start-9, col-start-10, col-start-11, col-start-12, col-start-13, col-start-auto
+
col-end-1, col-end-2, col-end-3, col-end-4, col-end-5, col-end-6, col-end-7, col-end-8, col-end-9, col-end-10, col-end-11, col-end-12, col-end-13, col-end-auto
+
```
+
+
#### Grid Template Rows
+
```
+
grid-rows-1, grid-rows-2, grid-rows-3, grid-rows-4, grid-rows-5, grid-rows-6, grid-rows-7, grid-rows-8, grid-rows-9, grid-rows-10, grid-rows-11, grid-rows-12, grid-rows-none, grid-rows-subgrid
+
```
+
+
#### Grid Row Start/End
+
```
+
row-auto, row-span-1, row-span-2, row-span-3, row-span-4, row-span-5, row-span-6, row-span-7, row-span-8, row-span-9, row-span-10, row-span-11, row-span-12, row-span-full
+
row-start-1, row-start-2, row-start-3, row-start-4, row-start-5, row-start-6, row-start-7, row-start-8, row-start-9, row-start-10, row-start-11, row-start-12, row-start-13, row-start-auto
+
row-end-1, row-end-2, row-end-3, row-end-4, row-end-5, row-end-6, row-end-7, row-end-8, row-end-9, row-end-10, row-end-11, row-end-12, row-end-13, row-end-auto
+
```
+
+
#### Gap
+
```
+
gap-0, gap-x-0, gap-y-0, gap-px, gap-x-px, gap-y-px
+
gap-0.5, gap-1, gap-1.5, gap-2, gap-2.5, gap-3, gap-3.5, gap-4, gap-5, gap-6, gap-7, gap-8, gap-9, gap-10, gap-11, gap-12, gap-14, gap-16, gap-20, gap-24, gap-28, gap-32, gap-36, gap-40, gap-44, gap-48, gap-52, gap-56, gap-60, gap-64, gap-72, gap-80, gap-96
+
```
+
+
#### Justify & Align
+
```
+
justify-normal, justify-start, justify-end, justify-center, justify-between, justify-around, justify-evenly, justify-stretch
+
justify-items-start, justify-items-end, justify-items-center, justify-items-stretch
+
justify-self-auto, justify-self-start, justify-self-end, justify-self-center, justify-self-stretch
+
align-items-start, align-items-end, align-items-center, align-items-baseline, align-items-stretch
+
align-content-normal, align-content-center, align-content-start, align-content-end, align-content-between, align-content-around, align-content-evenly, align-content-baseline, align-content-stretch
+
align-self-auto, align-self-start, align-self-end, align-self-center, align-self-stretch, align-self-baseline
+
place-content-center, place-content-start, place-content-end, place-content-between, place-content-around, place-content-evenly, place-content-baseline, place-content-stretch
+
place-items-start, place-items-end, place-items-center, place-items-baseline, place-items-stretch
+
place-self-auto, place-self-start, place-self-end, place-self-center, place-self-stretch
+
```
+
+
### Spacing
+
+
#### Padding
+
```
+
p-0, p-px, p-0.5, p-1, p-1.5, p-2, p-2.5, p-3, p-3.5, p-4, p-5, p-6, p-7, p-8, p-9, p-10, p-11, p-12, p-14, p-16, p-20, p-24, p-28, p-32, p-36, p-40, p-44, p-48, p-52, p-56, p-60, p-64, p-72, p-80, p-96
+
px-0, py-0, pl-0, pr-0, pt-0, pb-0, ps-0, pe-0
+
```
+
+
#### Margin
+
```
+
m-0, m-px, m-0.5, m-1, m-1.5, m-2, m-2.5, m-3, m-3.5, m-4, m-5, m-6, m-7, m-8, m-9, m-10, m-11, m-12, m-14, m-16, m-20, m-24, m-28, m-32, m-36, m-40, m-44, m-48, m-52, m-56, m-60, m-64, m-72, m-80, m-96, m-auto
+
mx-0, my-0, ml-0, mr-0, mt-0, mb-0, ms-0, me-0
+
-m-0, -m-px, -m-0.5, -m-1, -m-1.5, -m-2, -m-2.5, -m-3, -m-3.5, -m-4, -m-5, -m-6, -m-7, -m-8, -m-9, -m-10, -m-11, -m-12, -m-14, -m-16, -m-20, -m-24, -m-28, -m-32, -m-36, -m-40, -m-44, -m-48, -m-52, -m-56, -m-60, -m-64, -m-72, -m-80, -m-96
+
```
+
+
#### Space Between
+
```
+
space-x-0, space-x-px, space-x-0.5, space-x-1, space-x-1.5, space-x-2, space-x-2.5, space-x-3, space-x-3.5, space-x-4, space-x-5, space-x-6, space-x-7, space-x-8, space-x-9, space-x-10, space-x-11, space-x-12, space-x-14, space-x-16, space-x-20, space-x-24, space-x-28, space-x-32, space-x-36, space-x-40, space-x-44, space-x-48, space-x-52, space-x-56, space-x-60, space-x-64, space-x-72, space-x-80, space-x-96, space-x-reverse
+
space-y-0, space-y-px, space-y-0.5, space-y-1, space-y-1.5, space-y-2, space-y-2.5, space-y-3, space-y-3.5, space-y-4, space-y-5, space-y-6, space-y-7, space-y-8, space-y-9, space-y-10, space-y-11, space-y-12, space-y-14, space-y-16, space-y-20, space-y-24, space-y-28, space-y-32, space-y-36, space-y-40, space-y-44, space-y-48, space-y-52, space-y-56, space-y-60, space-y-64, space-y-72, space-y-80, space-y-96, space-y-reverse
+
```
+
+
### Sizing
+
+
#### Width
+
```
+
w-0, w-px, w-0.5, w-1, w-1.5, w-2, w-2.5, w-3, w-3.5, w-4, w-5, w-6, w-7, w-8, w-9, w-10, w-11, w-12, w-14, w-16, w-20, w-24, w-28, w-32, w-36, w-40, w-44, w-48, w-52, w-56, w-60, w-64, w-72, w-80, w-96, w-auto, w-1/2, w-1/3, w-2/3, w-1/4, w-2/4, w-3/4, w-1/5, w-2/5, w-3/5, w-4/5, w-1/6, w-2/6, w-3/6, w-4/6, w-5/6, w-1/12, w-2/12, w-3/12, w-4/12, w-5/12, w-6/12, w-7/12, w-8/12, w-9/12, w-10/12, w-11/12, w-full, w-screen, w-svw, w-lvw, w-dvw, w-min, w-max, w-fit
+
```
+
+
#### Height
+
```
+
h-0, h-px, h-0.5, h-1, h-1.5, h-2, h-2.5, h-3, h-3.5, h-4, h-5, h-6, h-7, h-8, h-9, h-10, h-11, h-12, h-14, h-16, h-20, h-24, h-28, h-32, h-36, h-40, h-44, h-48, h-52, h-56, h-60, h-64, h-72, h-80, h-96, h-auto, h-1/2, h-1/3, h-2/3, h-1/4, h-2/4, h-3/4, h-1/5, h-2/5, h-3/5, h-4/5, h-1/6, h-2/6, h-3/6, h-4/6, h-5/6, h-full, h-screen, h-svh, h-lvh, h-dvh, h-min, h-max, h-fit
+
```
+
+
#### Size (Width + Height)
+
```
+
size-0, size-px, size-0.5, size-1, size-1.5, size-2, size-2.5, size-3, size-3.5, size-4, size-5, size-6, size-7, size-8, size-9, size-10, size-11, size-12, size-14, size-16, size-20, size-24, size-28, size-32, size-36, size-40, size-44, size-48, size-52, size-56, size-60, size-64, size-72, size-80, size-96, size-auto, size-1/2, size-1/3, size-2/3, size-1/4, size-2/4, size-3/4, size-1/5, size-2/5, size-3/5, size-4/5, size-1/6, size-2/6, size-3/6, size-4/6, size-5/6, size-1/12, size-2/12, size-3/12, size-4/12, size-5/12, size-6/12, size-7/12, size-8/12, size-9/12, size-10/12, size-11/12, size-full, size-min, size-max, size-fit
+
```
+
+
#### Min/Max Width
+
```
+
min-w-0, min-w-full, min-w-min, min-w-max, min-w-fit
+
max-w-0, max-w-xs, max-w-sm, max-w-md, max-w-lg, max-w-xl, max-w-2xl, max-w-3xl, max-w-4xl, max-w-5xl, max-w-6xl, max-w-7xl, max-w-full, max-w-min, max-w-max, max-w-fit, max-w-prose, max-w-screen-sm, max-w-screen-md, max-w-screen-lg, max-w-screen-xl, max-w-screen-2xl
+
```
+
+
#### Min/Max Height
+
```
+
min-h-0, min-h-full, min-h-screen, min-h-svh, min-h-lvh, min-h-dvh, min-h-min, min-h-max, min-h-fit
+
max-h-0, max-h-px, max-h-0.5, max-h-1, max-h-1.5, max-h-2, max-h-2.5, max-h-3, max-h-3.5, max-h-4, max-h-5, max-h-6, max-h-7, max-h-8, max-h-9, max-h-10, max-h-11, max-h-12, max-h-14, max-h-16, max-h-20, max-h-24, max-h-28, max-h-32, max-h-36, max-h-40, max-h-44, max-h-48, max-h-52, max-h-56, max-h-60, max-h-64, max-h-72, max-h-80, max-h-96, max-h-full, max-h-screen, max-h-svh, max-h-lvh, max-h-dvh, max-h-min, max-h-max, max-h-fit
+
```
+
+
### Typography
+
+
#### Font Family
+
```
+
font-sans, font-serif, font-mono
+
```
+
+
#### Font Size
+
```
+
text-xs, text-sm, text-base, text-lg, text-xl, text-2xl, text-3xl, text-4xl, text-5xl, text-6xl, text-7xl, text-8xl, text-9xl
+
```
+
+
#### Font Weight
+
```
+
font-thin, font-extralight, font-light, font-normal, font-medium, font-semibold, font-bold, font-extrabold, font-black
+
```
+
+
#### Font Style
+
```
+
italic, not-italic
+
```
+
+
#### Font Variant Numeric
+
```
+
normal-nums, ordinal, slashed-zero, lining-nums, oldstyle-nums, proportional-nums, tabular-nums, diagonal-fractions, stacked-fractions
+
```
+
+
#### Font Stretch (NEW in v4)
+
```
+
font-stretch-ultra-condensed, font-stretch-extra-condensed, font-stretch-condensed, font-stretch-semi-condensed, font-stretch-normal, font-stretch-semi-expanded, font-stretch-expanded, font-stretch-extra-expanded, font-stretch-ultra-expanded
+
```
+
+
#### Letter Spacing
+
```
+
tracking-tighter, tracking-tight, tracking-normal, tracking-wide, tracking-wider, tracking-widest
+
```
+
+
#### Line Clamp
+
```
+
line-clamp-1, line-clamp-2, line-clamp-3, line-clamp-4, line-clamp-5, line-clamp-6, line-clamp-none
+
```
+
+
#### Line Height
+
```
+
leading-3, leading-4, leading-5, leading-6, leading-7, leading-8, leading-9, leading-10, leading-none, leading-tight, leading-snug, leading-normal, leading-relaxed, leading-loose
+
```
+
+
#### List Style
+
```
+
list-none, list-disc, list-decimal, list-inside, list-outside
+
```
+
+
#### Text Align
+
```
+
text-left, text-center, text-right, text-justify, text-start, text-end
+
```
+
+
#### Text Color
+
```
+
text-inherit, text-current, text-transparent, text-black, text-white
+
text-slate-50, text-slate-100, text-slate-200, text-slate-300, text-slate-400, text-slate-500, text-slate-600, text-slate-700, text-slate-800, text-slate-900, text-slate-950
+
text-gray-50, text-gray-100, text-gray-200, text-gray-300, text-gray-400, text-gray-500, text-gray-600, text-gray-700, text-gray-800, text-gray-900, text-gray-950
+
text-zinc-50, text-zinc-100, text-zinc-200, text-zinc-300, text-zinc-400, text-zinc-500, text-zinc-600, text-zinc-700, text-zinc-800, text-zinc-900, text-zinc-950
+
text-neutral-50, text-neutral-100, text-neutral-200, text-neutral-300, text-neutral-400, text-neutral-500, text-neutral-600, text-neutral-700, text-neutral-800, text-neutral-900, text-neutral-950
+
text-stone-50, text-stone-100, text-stone-200, text-stone-300, text-stone-400, text-stone-500, text-stone-600, text-stone-700, text-stone-800, text-stone-900, text-stone-950
+
text-red-50, text-red-100, text-red-200, text-red-300, text-red-400, text-red-500, text-red-600, text-red-700, text-red-800, text-red-900, text-red-950
+
text-orange-50, text-orange-100, text-orange-200, text-orange-300, text-orange-400, text-orange-500, text-orange-600, text-orange-700, text-orange-800, text-orange-900, text-orange-950
+
text-amber-50, text-amber-100, text-amber-200, text-amber-300, text-amber-400, text-amber-500, text-amber-600, text-amber-700, text-amber-800, text-amber-900, text-amber-950
+
text-yellow-50, text-yellow-100, text-yellow-200, text-yellow-300, text-yellow-400, text-yellow-500, text-yellow-600, text-yellow-700, text-yellow-800, text-yellow-900, text-yellow-950
+
text-lime-50, text-lime-100, text-lime-200, text-lime-300, text-lime-400, text-lime-500, text-lime-600, text-lime-700, text-lime-800, text-lime-900, text-lime-950
+
text-green-50, text-green-100, text-green-200, text-green-300, text-green-400, text-green-500, text-green-600, text-green-700, text-green-800, text-green-900, text-green-950
+
text-emerald-50, text-emerald-100, text-emerald-200, text-emerald-300, text-emerald-400, text-emerald-500, text-emerald-600, text-emerald-700, text-emerald-800, text-emerald-900, text-emerald-950
+
text-teal-50, text-teal-100, text-teal-200, text-teal-300, text-teal-400, text-teal-500, text-teal-600, text-teal-700, text-teal-800, text-teal-900, text-teal-950
+
text-cyan-50, text-cyan-100, text-cyan-200, text-cyan-300, text-cyan-400, text-cyan-500, text-cyan-600, text-cyan-700, text-cyan-800, text-cyan-900, text-cyan-950
+
text-sky-50, text-sky-100, text-sky-200, text-sky-300, text-sky-400, text-sky-500, text-sky-600, text-sky-700, text-sky-800, text-sky-900, text-sky-950
+
text-blue-50, text-blue-100, text-blue-200, text-blue-300, text-blue-400, text-blue-500, text-blue-600, text-blue-700, text-blue-800, text-blue-900, text-blue-950
+
text-indigo-50, text-indigo-100, text-indigo-200, text-indigo-300, text-indigo-400, text-indigo-500, text-indigo-600, text-indigo-700, text-indigo-800, text-indigo-900, text-indigo-950
+
text-violet-50, text-violet-100, text-violet-200, text-violet-300, text-violet-400, text-violet-500, text-violet-600, text-violet-700, text-violet-800, text-violet-900, text-violet-950
+
text-purple-50, text-purple-100, text-purple-200, text-purple-300, text-purple-400, text-purple-500, text-purple-600, text-purple-700, text-purple-800, text-purple-900, text-purple-950
+
text-fuchsia-50, text-fuchsia-100, text-fuchsia-200, text-fuchsia-300, text-fuchsia-400, text-fuchsia-500, text-fuchsia-600, text-fuchsia-700, text-fuchsia-800, text-fuchsia-900, text-fuchsia-950
+
text-pink-50, text-pink-100, text-pink-200, text-pink-300, text-pink-400, text-pink-500, text-pink-600, text-pink-700, text-pink-800, text-pink-900, text-pink-950
+
text-rose-50, text-rose-100, text-rose-200, text-rose-300, text-rose-400, text-rose-500, text-rose-600, text-rose-700, text-rose-800, text-rose-900, text-rose-950
+
```
+
+
#### Text Decoration
+
```
+
underline, overline, line-through, no-underline
+
decoration-solid, decoration-double, decoration-dotted, decoration-dashed, decoration-wavy
+
decoration-auto, decoration-from-font, decoration-0, decoration-1, decoration-2, decoration-4, decoration-8
+
underline-offset-auto, underline-offset-0, underline-offset-1, underline-offset-2, underline-offset-4, underline-offset-8
+
```
+
+
#### Text Transform
+
```
+
uppercase, lowercase, capitalize, normal-case
+
```
+
+
#### Text Overflow
+
```
+
truncate, text-ellipsis, text-clip
+
```
+
+
#### Text Shadow (NEW in v4)
+
```
+
text-shadow-sm, text-shadow, text-shadow-lg, text-shadow-xl, text-shadow-none
+
```
+
+
#### Overflow Wrap (NEW in v4)
+
```
+
overflow-wrap-normal, overflow-wrap-break-word, overflow-wrap-anywhere
+
```
+
+
#### Vertical Align
+
```
+
align-baseline, align-top, align-middle, align-bottom, align-text-top, align-text-bottom, align-sub, align-super
+
```
+
+
#### Whitespace
+
```
+
whitespace-normal, whitespace-nowrap, whitespace-pre, whitespace-pre-line, whitespace-pre-wrap, whitespace-break-spaces
+
```
+
+
#### Word Break
+
```
+
break-normal, break-words, break-all, break-keep
+
```
+
+
#### Hyphens
+
```
+
hyphens-none, hyphens-manual, hyphens-auto
+
```
+
+
#### Content
+
```
+
content-none
+
```
+
+
### Backgrounds
+
+
#### Background Attachment
+
```
+
bg-fixed, bg-local, bg-scroll
+
```
+
+
#### Background Clip
+
```
+
bg-clip-border, bg-clip-padding, bg-clip-content, bg-clip-text
+
```
+
+
#### Background Color
+
All color utilities work with `bg-` prefix (same as text colors above)
+
+
#### Background Origin
+
```
+
bg-origin-border, bg-origin-padding, bg-origin-content
+
```
+
+
#### Background Position
+
```
+
bg-bottom, bg-center, bg-left, bg-left-bottom, bg-left-top, bg-right, bg-right-bottom, bg-right-top, bg-top
+
```
+
+
#### Background Repeat
+
```
+
bg-repeat, bg-no-repeat, bg-repeat-x, bg-repeat-y, bg-repeat-round, bg-repeat-space
+
```
+
+
#### Background Size
+
```
+
bg-auto, bg-cover, bg-contain
+
```
+
+
#### Background Image
+
```
+
bg-none
+
bg-linear-to-t, bg-linear-to-tr, bg-linear-to-r, bg-linear-to-br, bg-linear-to-b, bg-linear-to-bl, bg-linear-to-l, bg-linear-to-tl
+
```
+
+
#### Enhanced Gradients (NEW in v4)
+
```
+
bg-linear-0, bg-linear-45, bg-linear-90, bg-linear-135, bg-linear-180, bg-linear-225, bg-linear-270, bg-linear-315
+
bg-radial, bg-radial-at-t, bg-radial-at-tr, bg-radial-at-r, bg-radial-at-br, bg-radial-at-b, bg-radial-at-bl, bg-radial-at-l, bg-radial-at-tl, bg-radial-at-c
+
bg-conic, bg-conic-at-t, bg-conic-at-tr, bg-conic-at-r, bg-conic-at-br, bg-conic-at-b, bg-conic-at-bl, bg-conic-at-l, bg-conic-at-tl, bg-conic-at-c
+
```
+
+
#### Gradient Color Stops
+
```
+
from-inherit, from-current, from-transparent, from-black, from-white, from-{color}
+
via-inherit, via-current, via-transparent, via-black, via-white, via-{color}
+
to-inherit, to-current, to-transparent, to-black, to-white, to-{color}
+
```
+
+
### Borders
+
+
#### Border Radius
+
```
+
rounded-none, rounded-xs, rounded-sm, rounded, rounded-md, rounded-lg, rounded-xl, rounded-2xl, rounded-3xl, rounded-full
+
rounded-s-none, rounded-s-xs, rounded-s-sm, rounded-s, rounded-s-md, rounded-s-lg, rounded-s-xl, rounded-s-2xl, rounded-s-3xl
+
rounded-e-none, rounded-e-xs, rounded-e-sm, rounded-e, rounded-e-md, rounded-e-lg, rounded-e-xl, rounded-e-2xl, rounded-e-3xl
+
rounded-t-none, rounded-t-xs, rounded-t-sm, rounded-t, rounded-t-md, rounded-t-lg, rounded-t-xl, rounded-t-2xl, rounded-t-3xl
+
rounded-r-none, rounded-r-xs, rounded-r-sm, rounded-r, rounded-r-md, rounded-r-lg, rounded-r-xl, rounded-r-2xl, rounded-r-3xl
+
rounded-b-none, rounded-b-xs, rounded-b-sm, rounded-b, rounded-b-md, rounded-b-lg, rounded-b-xl, rounded-b-2xl, rounded-b-3xl
+
rounded-l-none, rounded-l-xs, rounded-l-sm, rounded-l, rounded-l-md, rounded-l-lg, rounded-l-xl, rounded-l-2xl, rounded-l-3xl
+
rounded-ss-none, rounded-ss-xs, rounded-ss-sm, rounded-ss, rounded-ss-md, rounded-ss-lg, rounded-ss-xl, rounded-ss-2xl, rounded-ss-3xl
+
rounded-se-none, rounded-se-xs, rounded-se-sm, rounded-se, rounded-se-md, rounded-se-lg, rounded-se-xl, rounded-se-2xl, rounded-se-3xl
+
rounded-ee-none, rounded-ee-xs, rounded-ee-sm, rounded-ee, rounded-ee-md, rounded-ee-lg, rounded-ee-xl, rounded-ee-2xl, rounded-ee-3xl
+
rounded-es-none, rounded-es-xs, rounded-es-sm, rounded-es, rounded-es-md, rounded-es-lg, rounded-es-xl, rounded-es-2xl, rounded-es-3xl
+
rounded-tl-none, rounded-tl-xs, rounded-tl-sm, rounded-tl, rounded-tl-md, rounded-tl-lg, rounded-tl-xl, rounded-tl-2xl, rounded-tl-3xl
+
rounded-tr-none, rounded-tr-xs, rounded-tr-sm, rounded-tr, rounded-tr-md, rounded-tr-lg, rounded-tr-xl, rounded-tr-2xl, rounded-tr-3xl
+
rounded-br-none, rounded-br-xs, rounded-br-sm, rounded-br, rounded-br-md, rounded-br-lg, rounded-br-xl, rounded-br-2xl, rounded-br-3xl
+
rounded-bl-none, rounded-bl-xs, rounded-bl-sm, rounded-bl, rounded-bl-md, rounded-bl-lg, rounded-bl-xl, rounded-bl-2xl, rounded-bl-3xl
+
```
+
+
#### Border Width
+
```
+
border-0, border-2, border-4, border-8, border, border-x, border-y, border-s, border-e, border-t, border-r, border-b, border-l
+
```
+
+
#### Border Color
+
All color utilities work with `border-` prefix (same as text/bg colors)
+
+
#### Border Style
+
```
+
border-solid, border-dashed, border-dotted, border-double, border-hidden, border-none
+
```
+
+
#### Divide Width
+
```
+
divide-x-0, divide-x-2, divide-x-4, divide-x-8, divide-x, divide-y-0, divide-y-2, divide-y-4, divide-y-8, divide-y, divide-x-reverse, divide-y-reverse
+
```
+
+
#### Divide Color
+
All color utilities work with `divide-` prefix
+
+
#### Divide Style
+
```
+
divide-solid, divide-dashed, divide-dotted, divide-double, divide-none
+
```
+
+
#### Outline Width
+
```
+
outline-0, outline-1, outline-2, outline-4, outline-8
+
```
+
+
#### Outline Color
+
All color utilities work with `outline-` prefix
+
+
#### Outline Style
+
```
+
outline-none, outline, outline-dashed, outline-dotted, outline-double
+
```
+
+
#### Outline Offset
+
```
+
outline-offset-0, outline-offset-1, outline-offset-2, outline-offset-4, outline-offset-8
+
```
+
+
#### Ring Width
+
```
+
ring-0, ring-1, ring-2, ring, ring-4, ring-8, ring-inset
+
```
+
+
#### Ring Color
+
All color utilities work with `ring-` prefix
+
+
#### Ring Offset Width
+
```
+
ring-offset-0, ring-offset-1, ring-offset-2, ring-offset-4, ring-offset-8
+
```
+
+
#### Ring Offset Color
+
All color utilities work with `ring-offset-` prefix
+
+
### Effects
+
+
#### Box Shadow
+
```
+
shadow-xs, shadow-sm, shadow, shadow-md, shadow-lg, shadow-xl, shadow-2xl, shadow-inner, shadow-none
+
```
+
+
#### Box Shadow Color
+
All color utilities work with `shadow-` prefix
+
+
#### Drop Shadow (NEW colored support in v4)
+
```
+
drop-shadow-sm, drop-shadow, drop-shadow-md, drop-shadow-lg, drop-shadow-xl, drop-shadow-2xl, drop-shadow-none
+
```
+
+
#### Opacity
+
```
+
opacity-0, opacity-5, opacity-10, opacity-15, opacity-20, opacity-25, opacity-30, opacity-35, opacity-40, opacity-45, opacity-50, opacity-55, opacity-60, opacity-65, opacity-70, opacity-75, opacity-80, opacity-85, opacity-90, opacity-95, opacity-100
+
```
+
+
#### Mix Blend Mode
+
```
+
mix-blend-normal, mix-blend-multiply, mix-blend-screen, mix-blend-overlay, mix-blend-darken, mix-blend-lighten, mix-blend-color-dodge, mix-blend-color-burn, mix-blend-hard-light, mix-blend-soft-light, mix-blend-difference, mix-blend-exclusion, mix-blend-hue, mix-blend-saturation, mix-blend-color, mix-blend-luminosity, mix-blend-plus-darker, mix-blend-plus-lighter
+
```
+
+
#### Background Blend Mode
+
```
+
bg-blend-normal, bg-blend-multiply, bg-blend-screen, bg-blend-overlay, bg-blend-darken, bg-blend-lighten, bg-blend-color-dodge, bg-blend-color-burn, bg-blend-hard-light, bg-blend-soft-light, bg-blend-difference, bg-blend-exclusion, bg-blend-hue, bg-blend-saturation, bg-blend-color, bg-blend-luminosity
+
```
+
+
### Filters
+
+
#### Blur
+
```
+
blur-none, blur-xs, blur-sm, blur, blur-md, blur-lg, blur-xl, blur-2xl, blur-3xl
+
```
+
+
#### Brightness
+
```
+
brightness-0, brightness-50, brightness-75, brightness-90, brightness-95, brightness-100, brightness-105, brightness-110, brightness-125, brightness-150, brightness-200
+
```
+
+
#### Contrast
+
```
+
contrast-0, contrast-50, contrast-75, contrast-100, contrast-125, contrast-150, contrast-200
+
```
+
+
#### Grayscale
+
```
+
grayscale-0, grayscale
+
```
+
+
#### Hue Rotate
+
```
+
hue-rotate-0, hue-rotate-15, hue-rotate-30, hue-rotate-60, hue-rotate-90, hue-rotate-180, -hue-rotate-180, -hue-rotate-90, -hue-rotate-60, -hue-rotate-30, -hue-rotate-15
+
```
+
+
#### Invert
+
```
+
invert-0, invert
+
```
+
+
#### Saturate
+
```
+
saturate-0, saturate-50, saturate-100, saturate-150, saturate-200
+
```
+
+
#### Sepia
+
```
+
sepia-0, sepia
+
```
+
+
#### Backdrop Blur
+
```
+
backdrop-blur-none, backdrop-blur-xs, backdrop-blur-sm, backdrop-blur, backdrop-blur-md, backdrop-blur-lg, backdrop-blur-xl, backdrop-blur-2xl, backdrop-blur-3xl
+
```
+
+
#### Backdrop Brightness
+
```
+
backdrop-brightness-0, backdrop-brightness-50, backdrop-brightness-75, backdrop-brightness-90, backdrop-brightness-95, backdrop-brightness-100, backdrop-brightness-105, backdrop-brightness-110, backdrop-brightness-125, backdrop-brightness-150, backdrop-brightness-200
+
```
+
+
#### Backdrop Contrast
+
```
+
backdrop-contrast-0, backdrop-contrast-50, backdrop-contrast-75, backdrop-contrast-100, backdrop-contrast-125, backdrop-contrast-150, backdrop-contrast-200
+
```
+
+
#### Backdrop Grayscale
+
```
+
backdrop-grayscale-0, backdrop-grayscale
+
```
+
+
#### Backdrop Hue Rotate
+
```
+
backdrop-hue-rotate-0, backdrop-hue-rotate-15, backdrop-hue-rotate-30, backdrop-hue-rotate-60, backdrop-hue-rotate-90, backdrop-hue-rotate-180, -backdrop-hue-rotate-180, -backdrop-hue-rotate-90, -backdrop-hue-rotate-60, -backdrop-hue-rotate-30, -backdrop-hue-rotate-15
+
```
+
+
#### Backdrop Invert
+
```
+
backdrop-invert-0, backdrop-invert
+
```
+
+
#### Backdrop Saturate
+
```
+
backdrop-saturate-0, backdrop-saturate-50, backdrop-saturate-100, backdrop-saturate-150, backdrop-saturate-200
+
```
+
+
#### Backdrop Sepia
+
```
+
backdrop-sepia-0, backdrop-sepia
+
```
+
+
### Masks (NEW in v4)
+
+
#### Mask Image
+
```
+
mask-none
+
```
+
+
#### Mask Size
+
```
+
mask-auto, mask-cover, mask-contain
+
```
+
+
#### Mask Repeat
+
```
+
mask-repeat, mask-no-repeat, mask-repeat-x, mask-repeat-y, mask-repeat-round, mask-repeat-space
+
```
+
+
#### Mask Position
+
```
+
mask-bottom, mask-center, mask-left, mask-left-bottom, mask-left-top, mask-right, mask-right-bottom, mask-right-top, mask-top
+
```
+
+
#### Mask Origin
+
```
+
mask-origin-border, mask-origin-padding, mask-origin-content
+
```
+
+
#### Mask Clip
+
```
+
mask-clip-border, mask-clip-padding, mask-clip-content
+
```
+
+
#### Mask Composite
+
```
+
mask-composite-add, mask-composite-subtract, mask-composite-intersect, mask-composite-exclude
+
```
+
+
#### Mask Mode
+
```
+
mask-mode-match-source, mask-mode-luminance, mask-mode-alpha
+
```
+
+
#### Mask Type
+
```
+
mask-type-luminance, mask-type-alpha
+
```
+
+
### Tables
+
+
#### Border Collapse
+
```
+
border-collapse, border-separate
+
```
+
+
#### Border Spacing
+
```
+
border-spacing-0, border-spacing-px, border-spacing-0.5, border-spacing-1, border-spacing-1.5, border-spacing-2, border-spacing-2.5, border-spacing-3, border-spacing-3.5, border-spacing-4, border-spacing-5, border-spacing-6, border-spacing-7, border-spacing-8, border-spacing-9, border-spacing-10, border-spacing-11, border-spacing-12, border-spacing-14, border-spacing-16, border-spacing-20, border-spacing-24, border-spacing-28, border-spacing-32, border-spacing-36, border-spacing-40, border-spacing-44, border-spacing-48, border-spacing-52, border-spacing-56, border-spacing-60, border-spacing-64, border-spacing-72, border-spacing-80, border-spacing-96
+
border-spacing-x-0, border-spacing-y-0 (and all other spacing values)
+
```
+
+
#### Table Layout
+
```
+
table-auto, table-fixed
+
```
+
+
#### Caption Side
+
```
+
caption-top, caption-bottom
+
```
+
+
### Transforms
+
+
#### Scale
+
```
+
scale-0, scale-50, scale-75, scale-90, scale-95, scale-100, scale-105, scale-110, scale-125, scale-150
+
scale-x-0, scale-x-50, scale-x-75, scale-x-90, scale-x-95, scale-x-100, scale-x-105, scale-x-110, scale-x-125, scale-x-150
+
scale-y-0, scale-y-50, scale-y-75, scale-y-90, scale-y-95, scale-y-100, scale-y-105, scale-y-110, scale-y-125, scale-y-150
+
```
+
+
#### Scale Z (NEW in v4)
+
```
+
scale-z-0, scale-z-50, scale-z-75, scale-z-90, scale-z-95, scale-z-100, scale-z-105, scale-z-110, scale-z-125, scale-z-150
+
```
+
+
#### Rotate
+
```
+
rotate-0, rotate-1, rotate-2, rotate-3, rotate-6, rotate-12, rotate-45, rotate-90, rotate-180, -rotate-180, -rotate-90, -rotate-45, -rotate-12, -rotate-6, -rotate-3, -rotate-2, -rotate-1
+
```
+
+
#### Rotate X/Y (NEW in v4)
+
```
+
rotate-x-0, rotate-x-1, rotate-x-2, rotate-x-3, rotate-x-6, rotate-x-12, rotate-x-45, rotate-x-90, rotate-x-180, -rotate-x-180, -rotate-x-90, -rotate-x-45, -rotate-x-12, -rotate-x-6, -rotate-x-3, -rotate-x-2, -rotate-x-1
+
rotate-y-0, rotate-y-1, rotate-y-2, rotate-y-3, rotate-y-6, rotate-y-12, rotate-y-45, rotate-y-90, rotate-y-180, -rotate-y-180, -rotate-y-90, -rotate-y-45, -rotate-y-12, -rotate-y-6, -rotate-y-3, -rotate-y-2, -rotate-y-1
+
```
+
+
#### Translate
+
```
+
translate-x-0, translate-x-px, translate-x-0.5, translate-x-1, translate-x-1.5, translate-x-2, translate-x-2.5, translate-x-3, translate-x-3.5, translate-x-4, translate-x-5, translate-x-6, translate-x-7, translate-x-8, translate-x-9, translate-x-10, translate-x-11, translate-x-12, translate-x-14, translate-x-16, translate-x-20, translate-x-24, translate-x-28, translate-x-32, translate-x-36, translate-x-40, translate-x-44, translate-x-48, translate-x-52, translate-x-56, translate-x-60, translate-x-64, translate-x-72, translate-x-80, translate-x-96, translate-x-1/2, translate-x-1/3, translate-x-2/3, translate-x-1/4, translate-x-2/4, translate-x-3/4, translate-x-full
+
translate-y-0, translate-y-px, translate-y-0.5, translate-y-1, translate-y-1.5, translate-y-2, translate-y-2.5, translate-y-3, translate-y-3.5, translate-y-4, translate-y-5, translate-y-6, translate-y-7, translate-y-8, translate-y-9, translate-y-10, translate-y-11, translate-y-12, translate-y-14, translate-y-16, translate-y-20, translate-y-24, translate-y-28, translate-y-32, translate-y-36, translate-y-40, translate-y-44, translate-y-48, translate-y-52, translate-y-56, translate-y-60, translate-y-64, translate-y-72, translate-y-80, translate-y-96, translate-y-1/2, translate-y-1/3, translate-y-2/3, translate-y-1/4, translate-y-2/4, translate-y-3/4, translate-y-full
+
```
+
+
#### Translate Z (NEW in v4)
+
```
+
translate-z-0, translate-z-px, translate-z-0.5, translate-z-1, translate-z-1.5, translate-z-2, translate-z-2.5, translate-z-3, translate-z-3.5, translate-z-4, translate-z-5, translate-z-6, translate-z-7, translate-z-8, translate-z-9, translate-z-10, translate-z-11, translate-z-12, translate-z-14, translate-z-16, translate-z-20, translate-z-24, translate-z-28, translate-z-32, translate-z-36, translate-z-40, translate-z-44, translate-z-48, translate-z-52, translate-z-56, translate-z-60, translate-z-64, translate-z-72, translate-z-80, translate-z-96
+
```
+
+
#### Skew
+
```
+
skew-x-0, skew-x-1, skew-x-2, skew-x-3, skew-x-6, skew-x-12, -skew-x-12, -skew-x-6, -skew-x-3, -skew-x-2, -skew-x-1
+
skew-y-0, skew-y-1, skew-y-2, skew-y-3, skew-y-6, skew-y-12, -skew-y-12, -skew-y-6, -skew-y-3, -skew-y-2, -skew-y-1
+
```
+
+
#### Transform Origin
+
```
+
origin-center, origin-top, origin-top-right, origin-right, origin-bottom-right, origin-bottom, origin-bottom-left, origin-left, origin-top-left
+
```
+
+
#### Transform Style (NEW in v4)
+
```
+
transform-style-flat, transform-style-preserve-3d
+
```
+
+
#### Perspective (NEW in v4)
+
```
+
perspective-none, perspective-250, perspective-500, perspective-750, perspective-1000, perspective-distant
+
```
+
+
#### Perspective Origin (NEW in v4)
+
```
+
perspective-origin-center, perspective-origin-top, perspective-origin-top-right, perspective-origin-right, perspective-origin-bottom-right, perspective-origin-bottom, perspective-origin-bottom-left, perspective-origin-left, perspective-origin-top-left
+
```
+
+
### Interactivity
+
+
#### Accent Color
+
```
+
accent-auto, accent-inherit, accent-current, accent-transparent, accent-black, accent-white
+
accent-{color} (all color utilities work with accent- prefix)
+
```
+
+
#### Appearance
+
```
+
appearance-none, appearance-auto
+
```
+
+
#### Cursor
+
```
+
cursor-auto, cursor-default, cursor-pointer, cursor-wait, cursor-text, cursor-move, cursor-help, cursor-not-allowed, cursor-none, cursor-context-menu, cursor-progress, cursor-cell, cursor-crosshair, cursor-vertical-text, cursor-alias, cursor-copy, cursor-no-drop, cursor-grab, cursor-grabbing, cursor-all-scroll, cursor-col-resize, cursor-row-resize, cursor-n-resize, cursor-e-resize, cursor-s-resize, cursor-w-resize, cursor-ne-resize, cursor-nw-resize, cursor-se-resize, cursor-sw-resize, cursor-ew-resize, cursor-ns-resize, cursor-nesw-resize, cursor-nwse-resize, cursor-zoom-in, cursor-zoom-out
+
```
+
+
#### Caret Color
+
All color utilities work with `caret-` prefix
+
+
#### Pointer Events
+
```
+
pointer-events-none, pointer-events-auto
+
```
+
+
#### Resize
+
```
+
resize-none, resize, resize-y, resize-x
+
```
+
+
#### Scroll Behavior
+
```
+
scroll-auto, scroll-smooth
+
```
+
+
#### Scroll Margin
+
```
+
scroll-m-0, scroll-m-px, scroll-m-0.5, scroll-m-1, scroll-m-1.5, scroll-m-2, scroll-m-2.5, scroll-m-3, scroll-m-3.5, scroll-m-4, scroll-m-5, scroll-m-6, scroll-m-7, scroll-m-8, scroll-m-9, scroll-m-10, scroll-m-11, scroll-m-12, scroll-m-14, scroll-m-16, scroll-m-20, scroll-m-24, scroll-m-28, scroll-m-32, scroll-m-36, scroll-m-40, scroll-m-44, scroll-m-48, scroll-m-52, scroll-m-56, scroll-m-60, scroll-m-64, scroll-m-72, scroll-m-80, scroll-m-96
+
scroll-mx-0, scroll-my-0, scroll-ms-0, scroll-me-0, scroll-mt-0, scroll-mr-0, scroll-mb-0, scroll-ml-0 (and all spacing values)
+
```
+
+
#### Scroll Padding
+
```
+
scroll-p-0, scroll-p-px, scroll-p-0.5, scroll-p-1, scroll-p-1.5, scroll-p-2, scroll-p-2.5, scroll-p-3, scroll-p-3.5, scroll-p-4, scroll-p-5, scroll-p-6, scroll-p-7, scroll-p-8, scroll-p-9, scroll-p-10, scroll-p-11, scroll-p-12, scroll-p-14, scroll-p-16, scroll-p-20, scroll-p-24, scroll-p-28, scroll-p-32, scroll-p-36, scroll-p-40, scroll-p-44, scroll-p-48, scroll-p-52, scroll-p-56, scroll-p-60, scroll-p-64, scroll-p-72, scroll-p-80, scroll-p-96
+
scroll-px-0, scroll-py-0, scroll-ps-0, scroll-pe-0, scroll-pt-0, scroll-pr-0, scroll-pb-0, scroll-pl-0 (and all spacing values)
+
```
+
+
#### Scroll Snap Align
+
```
+
snap-start, snap-end, snap-center, snap-align-none
+
```
+
+
#### Scroll Snap Stop
+
```
+
snap-normal, snap-always
+
```
+
+
#### Scroll Snap Type
+
```
+
snap-none, snap-x, snap-y, snap-both, snap-mandatory, snap-proximity
+
```
+
+
#### Touch Action
+
```
+
touch-auto, touch-none, touch-pan-x, touch-pan-left, touch-pan-right, touch-pan-y, touch-pan-up, touch-pan-down, touch-pinch-zoom, touch-manipulation
+
```
+
+
#### User Select
+
```
+
select-none, select-text, select-all, select-auto
+
```
+
+
#### Will Change
+
```
+
will-change-auto, will-change-scroll, will-change-contents, will-change-transform
+
```
+
+
### SVG
+
+
#### Fill
+
```
+
fill-none, fill-inherit, fill-current, fill-transparent, fill-black, fill-white
+
fill-{color} (all color utilities work with fill- prefix)
+
```
+
+
#### Stroke
+
```
+
stroke-none, stroke-inherit, stroke-current, stroke-transparent, stroke-black, stroke-white
+
stroke-{color} (all color utilities work with stroke- prefix)
+
```
+
+
#### Stroke Width
+
```
+
stroke-0, stroke-1, stroke-2
+
```
+
+
### Accessibility
+
+
#### Screen Readers
+
```
+
sr-only, not-sr-only
+
```
+
+
#### Forced Color Adjust
+
```
+
forced-color-adjust-auto, forced-color-adjust-none
+
```
+
+
### Container Queries (NEW in v4)
+
+
#### Container Type
+
```
+
@container, @container-normal, @container-size, @container-inline-size
+
```
+
+
#### Container Query Variants
+
```
+
@xs:, @sm:, @md:, @lg:, @xl:, @2xl:, @3xl:, @4xl:, @5xl:, @6xl:, @7xl:
+
@min-w-0:, @min-w-xs:, @min-w-sm:, @min-w-md:, @min-w-lg:, @min-w-xl:, @min-w-2xl:, @min-w-3xl:, @min-w-4xl:, @min-w-5xl:, @min-w-6xl:, @min-w-7xl:
+
@max-w-xs:, @max-w-sm:, @max-w-md:, @max-w-lg:, @max-w-xl:, @max-w-2xl:, @max-w-3xl:, @max-w-4xl:, @max-w-5xl:, @max-w-6xl:, @max-w-7xl:
+
@min-h-0:, @min-h-xs:, @min-h-sm:, @min-h-md:, @min-h-lg:, @min-h-xl:, @min-h-2xl:, @min-h-3xl:, @min-h-4xl:, @min-h-5xl:, @min-h-6xl:, @min-h-7xl:
+
@max-h-xs:, @max-h-sm:, @max-h-md:, @max-h-lg:, @max-h-xl:, @max-h-2xl:, @max-h-3xl:, @max-h-4xl:, @max-h-5xl:, @max-h-6xl:, @max-h-7xl:
+
```
+
+
### Responsive Design
+
+
#### Breakpoint Variants
+
```
+
sm:, md:, lg:, xl:, 2xl:
+
max-sm:, max-md:, max-lg:, max-xl:, max-2xl:
+
```
+
+
### State Variants
+
+
#### Hover, Focus, etc.
+
```
+
hover:, focus:, focus-within:, focus-visible:, active:, visited:, target:, disabled:, enabled:, checked:, indeterminate:, default:, required:, valid:, invalid:, in-range:, out-of-range:, placeholder-shown:, autofill:, read-only:
+
```
+
+
#### Group States
+
```
+
group-hover:, group-focus:, group-focus-within:, group-focus-visible:, group-active:, group-visited:, group-target:, group-disabled:, group-enabled:, group-checked:, group-indeterminate:, group-default:, group-required:, group-valid:, group-invalid:, group-in-range:, group-out-of-range:, group-placeholder-shown:, group-autofill:, group-read-only:
+
```
+
+
#### Peer States
+
```
+
peer-hover:, peer-focus:, peer-focus-within:, peer-focus-visible:, peer-active:, peer-visited:, peer-target:, peer-disabled:, peer-enabled:, peer-checked:, peer-indeterminate:, peer-default:, peer-required:, peer-valid:, peer-invalid:, peer-in-range:, peer-out-of-range:, peer-placeholder-shown:, peer-autofill:, peer-read-only:
+
```
+
+
#### NEW Variants in v4
+
```
+
@starting-style:, not-*, nth-*, in-*, inert:, open: (for popovers)
+
```
+
+
### Media Queries
+
+
#### Dark Mode
+
```
+
dark:
+
```
+
+
#### Motion
+
```
+
motion-safe:, motion-reduce:
+
```
+
+
#### Contrast
+
```
+
contrast-more:, contrast-less:
+
```
+
+
#### Print
+
```
+
print:
+
```
+
+
#### Orientation
+
```
+
portrait:, landscape:
+
```
+
+
### Content
+
```
+
content-none, content-['text']
+
```
+
+
### Arbitrary Values
+
You can use arbitrary values with square brackets for any property:
+
```
+
w-[123px], h-[456px], text-[#bada55], bg-[url('...')], top-[117px], left-[344px]
+
m-[12px], p-[24px], grid-cols-[200px_minmax(900px,_1fr)_100px]
+
```
+
+
### Arbitrary Properties
+
```
+
[mask-type:luminance], [tab-size:4], [@supports(backdrop-filter:blur(0))]:bg-white/75
+
```
+
+
### Arbitrary Variants
+
```
+
[&:nth-child(3)]:, [&:hover]:, [&_p]:, [@media(min-width:600px)]:
+
[@supports(backdrop-filter:blur(0))]:, [data-theme="dark"]:
+
```
+
+
## Common v4 Pitfalls to Avoid
+
+
### Don't Use These Deprecated Patterns
+
- โŒ `@tailwind base; @tailwind components; @tailwind utilities;`
+
- โŒ `text-opacity-50` โ†’ Use `text-white/50` instead
+
- โŒ `bg-opacity-25` โ†’ Use `bg-blue-500/25` instead
+
- โŒ `border` without color (now uses currentColor, not gray-200)
+
- โŒ `ring` without explicit width (now 1px, was 3px)
+
- โŒ `@layer utilities` โ†’ Use `@utility` instead
+
- โŒ JavaScript config for new projects โ†’ Use CSS `@theme`
+
+
### Modern v4 Alternatives
+
- โœ… `@import "tailwindcss";`
+
- โœ… `text-white/50` for semi-transparent text
+
- โœ… `bg-blue-500/25` for semi-transparent backgrounds
+
- โœ… `border border-gray-200` for explicit border color
+
- โœ… `ring-3` for 3px ring width
+
- โœ… `@utility` for custom utilities
+
- โœ… `@theme` for configuration
+
+
## Performance Best Practices
+
+
### Leverage v4's Performance Features
+
- Use automatic content detection (no manual `content` config needed)
+
- Prefer container queries over viewport queries for true component responsiveness
+
- Use CSS variables from `@theme` for dynamic styling
+
- Leverage the new OKLCH color system for better color consistency
+
+
### Efficient Class Usage
+
```html
+
<!-- Good: Use size-* for square elements -->
+
<div class="size-12"></div>
+
+
<!-- Instead of: -->
+
<div class="w-12 h-12"></div>
+
+
<!-- Good: Use container queries for component responsiveness -->
+
<div class="@container">
+
<div class="p-4 @lg:p-8">Content</div>
+
</div>
+
+
<!-- Good: Use CSS variables for dynamic values -->
+
<div class="bg-[var(--theme-primary)] text-[var(--theme-on-primary)]">
+
Dynamic theming
+
</div>
+
```
+
+
## Framework Integration
+
+
### Svelte 5
+
```svelte
+
<script>
+
let { variant = "primary", children } = $props();
+
+
const buttonClasses = $derived(() => [
+
'px-4 py-2 rounded-md font-medium transition-colors',
+
variant === 'primary'
+
? 'bg-brand text-white hover:bg-brand/90'
+
: 'bg-gray-100 text-gray-900 hover:bg-gray-200'
+
].join(' '));
+
</script>
+
+
<button class={buttonClasses}>
+
{@render children()}
+
</button>
+
+
<style>
+
@import "tailwindcss";
+
+
@theme {
+
--color-brand: oklch(0.5 0.2 240);
+
}
+
</style>
+
```
+
+
## Debugging & Development
+
+
### Browser DevTools Tips
+
1. **Inspect CSS Variables**: Check `:root` in DevTools to see all theme variables
+
2. **Check Cascade Layers**: Use the Layers panel to understand style precedence
+
3. **Verify OKLCH Support**: Test colors in modern browsers vs fallbacks
+
4. **Container Query Debugging**: Use the @container panel in DevTools
+
+
### Common Debug Commands
+
```bash
+
# Check if utilities are being generated
+
npx tailwindcss --watch --content "./src/**/*.{html,js,jsx,ts,tsx}"
+
+
# Verify v4 installation
+
npm list tailwindcss
+
+
# Check for conflicting PostCSS plugins
+
npm list | grep postcss
+
```
+
+
### VS Code Extensions
+
- Tailwind CSS IntelliSense (updated for v4)
+
- PostCSS Language Support
+
+
## v3 to v4 Migration Checklist
+
+
### Pre-Migration
+
- [ ] Backup your project
+
- [ ] Ensure Node.js 20+ is installed
+
- [ ] Check browser support requirements (Safari 16.4+, Chrome 111+, Firefox 128+)
+
+
### Automated Migration
+
```bash
+
npx @tailwindcss/upgrade@next
+
```
+
+
### Manual Verification
+
- [ ] Replace `@tailwind` directives with `@import "tailwindcss"`
+
- [ ] Move `tailwind.config.js` content to CSS `@theme`
+
- [ ] Update deprecated utility classes
+
- [ ] Test container queries functionality
+
- [ ] Verify custom component styles
+
- [ ] Check 3D transform support
+
- [ ] Test mask utilities if used
+
- [ ] Validate color consistency (OKLCH vs RGB)
+
+
### Testing
+
- [ ] Test in all target browsers
+
- [ ] Verify responsive design still works
+
- [ ] Check dark mode functionality
+
- [ ] Test custom animations
+
- [ ] Validate accessibility features
+
+
## Production-Ready Component Patterns
+
+
### Modern Card Component
+
```html
+
<div class="@container group">
+
<article class="
+
bg-white dark:bg-gray-900
+
rounded-xl shadow-sm border border-gray-200 dark:border-gray-800
+
overflow-hidden transition-all duration-200
+
hover:shadow-md hover:-translate-y-0.5
+
@sm:flex @sm:items-center
+
">
+
<div class="@sm:flex-shrink-0">
+
<img class="h-48 w-full object-cover @sm:h-full @sm:w-48" src="..." alt="...">
+
</div>
+
<div class="p-6 @sm:p-8">
+
<h3 class="text-lg font-semibold text-gray-900 dark:text-white @lg:text-xl">
+
Card Title
+
</h3>
+
<p class="mt-2 text-gray-600 dark:text-gray-300 @lg:text-lg">
+
Card description that adapts to container size.
+
</p>
+
</div>
+
</article>
+
</div>
+
```
+
+
### 3D Interactive Button
+
```html
+
<button class="
+
relative px-6 py-3 bg-blue-600 text-white font-medium rounded-lg
+
transform-3d perspective-1000
+
transition-all duration-200
+
hover:rotate-x-12 hover:scale-105 hover:shadow-xl
+
active:scale-95 active:rotate-x-6
+
focus:outline-none focus:ring-2 focus:ring-blue-500/50
+
">
+
3D Button
+
</button>
+
```
+
+
Remember: Tailwind CSS v4 is designed for modern browsers and modern development workflows. Embrace the new CSS-first approach and leverage the powerful new features for better performance and developer experience.
+13
.tangled/workflows/build.yml
···
+
when:
+
- event: ["push", "pull_request"]
+
branch: ["main"]
+
+
dependencies:
+
nixpkgs:
+
- dune
+
- opam
+
+
steps:
+
- name: dune
+
command: |
+
dune build
+1 -3
CLAUDE.md
···
-
My goal is to build a high quality professions OCaml library to generate Tailwind CSS components. Build a core `tailwind` library that serialises the CSS into strings. Then build a `tailwind-html` library that uses the Htmlit OCaml HTML generation library https://github.com/dbuenzli/htmlit for common components.
-
-
You can find full Tailwind docs in tailwind-llms.txt
+
Look in .agent/ for instructions
+18
LICENSE.md
···
+
(*
+
* ISC License
+
*
+
* Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>
+
*
+
* Permission to use, copy, modify, and distribute this software for any
+
* purpose with or without fee is hereby granted, provided that the above
+
* copyright notice and this permission notice appear in all copies.
+
*
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
*
+
*)
+276 -148
README.md
···
# Tailwind OCaml
-
An OCaml library for generating Tailwind CSS classes with compile-time
-
validation and a companion HTML generation library using Htmlit.
+
Type-safe Tailwind CSS generation for OCaml with a revolutionary GADT-based interface for succinct, compile-time validated styling.
This project provides two main libraries:
- **`tailwind`**: Core library for type-safe Tailwind CSS class generation
-
- **`tailwind-html`**: HTML component library built on top of [Htmlit](https://github.com/dbuenzli/htmlit)
+
- **`tailwind-html`**: High-level HTML component library with GADT-based heterogeneous list interface built on [Htmlit](https://github.com/dbuenzli/htmlit)
## Features
-
- Compile-time validation of Tailwind classes
-
- Type-safe color variants and sizes
-
- Exhaustive pattern matching for all utility classes
+
- **GADT-based Interface**: Succinct heterogeneous list syntax with compile-time type safety
+
- **Zero Runtime Cost**: All CSS generation happens at compile time
+
- **Comprehensive Grid Support**: Full CSS Grid integration with type-safe properties
+
- **Type-Safe Colors & Spacing**: Exhaustive variants with compile-time validation
+
- **Built-in Components**: Pre-styled buttons, cards, and layout helpers
-
### Comprehensive Coverage
-
- **Typography**: Font sizes, weights, line heights, text alignment, decorations
-
- **Layout**: Display, position, flexbox, grid, spacing
-
- **Colors**: Full color palette with variants
+
### Complete Tailwind Coverage
+
- **Typography**: Font sizes, weights, text alignment with type-safe variants
+
- **Layout**: CSS Grid, Flexbox, spacing with compile-time validation
+
- **Colors**: Full palette (gray, blue, red, green, etc.) with variant checking
- **Effects**: Shadows, borders, rounded corners, transitions
-
- **Responsive**: Breakpoint-based responsive utilities
-
- **Variants**: Hover, focus, and other state variants
+
- **Components**: Pre-built buttons, cards, and layout helpers
+
- **Type Safety**: GADT-based heterogeneous lists prevent invalid combinations
-
### Using Dune
+
## Quick Start
-
Add to your `dune-project`:
-
-
```dune
-
(package
-
(name myproject)
-
(depends
-
ocaml
-
dune
-
tailwind
-
tailwind-html
-
htmlit))
-
```
-
-
## Quick Start
+
### GADT Interface (Recommended)
-
### Basic Usage
+
The new GADT-based interface provides succinct, type-safe styling with heterogeneous lists:
```ocaml
-
open Tailwind
+
open Htmlit
+
open Tailwind_html
-
(* Create a styled div *)
-
let styled_div =
-
let classes = tw [
-
Display.flex;
-
Flexbox.(to_class (justify `Center));
-
Flexbox.(to_class (align_items `Center));
-
Color.bg (Color.make `Gray ~variant:`V100 ());
-
Spacing.(to_class (p (Size.rem 2.0)));
-
] in
-
Printf.sprintf "<div class=\"%s\">Content</div>" (to_string classes)
+
(* Create a centered card with CSS Grid *)
+
let create_hero_section () =
+
div ~styles:[
+
grid;
+
grid_cols 1;
+
gap (rem 2.0);
+
padding (rem 3.0);
+
text_center;
+
] [
+
h1 ~styles:[
+
font_size `Xl3;
+
font_weight `Bold;
+
text_color (blue 600);
+
margin_bottom (rem 1.5);
+
] [txt "Welcome to Tailwind OCaml"];
+
+
p ~styles:[
+
font_size `Lg;
+
text_color (gray 600);
+
margin_bottom (rem 2.0);
+
] [txt "Type-safe CSS with compile-time guarantees"];
+
+
(* Built-in button components *)
+
btn_primary ~size:`Lg [txt "Get Started"];
+
]
```
-
### With Htmlit Integration
+
### CSS Grid Layouts
```ocaml
-
open Htmlit
-
open Tailwind
+
(* Three-column responsive grid *)
+
div ~styles:[
+
grid;
+
grid_cols 3;
+
gap (rem 1.5);
+
] [
+
card [h3 [txt "Feature 1"]; p [txt "Description"]];
+
card [h3 [txt "Feature 2"]; p [txt "Description"]];
+
card [h3 [txt "Feature 3"]; p [txt "Description"]];
+
]
+
```
-
let classes_attr tailwind_classes =
-
At.class' (Tailwind.to_string tailwind_classes)
+
### Built-in Components
-
let create_card title content =
-
El.div ~at:[classes_attr (tw [
-
Patterns.card;
-
Spacing.(to_class (p (Size.rem 1.5)));
-
Effects.shadow_md;
-
])] [
-
El.h2 ~at:[classes_attr (tw [
-
Typography.(to_class (font_size `Xl));
-
Typography.(to_class (font_weight `Bold));
-
Spacing.(to_class (mb (Size.rem 1.0)));
-
])] [El.txt title];
-
El.p [El.txt content];
-
]
+
```ocaml
+
(* Pre-styled components with size variants *)
+
btn_primary ~size:`Lg [txt "Primary Action"];
+
btn_secondary [txt "Secondary Action"];
+
btn_outline ~size:`Sm [txt "Outline Button"];
+
+
(* Layout helpers *)
+
container [
+
card [
+
h2 ~styles:[font_size `Xl; margin_bottom (rem 1.0)] [txt "Card Title"];
+
p ~styles:[text_color (gray 600)] [txt "Card content with automatic styling"];
+
];
+
]
```
## Examples
-
The `examples/` directory contains several demonstration files:
+
The `examples/` directory showcases the GADT interface across various use cases:
-
### Running Examples
+
### Available Examples
```bash
# Build all examples
dune build examples/
-
# Run comprehensive showcase (generates HTML + CSS)
-
dune exec examples/comprehensive_showcase.exe
+
# Hello World with GADT interface
+
dune exec examples/hello_tailwind_01.exe > hello.html
+
+
# Colors and Typography showcase
+
dune exec examples/colors_and_typography_02.exe > colors.html
+
+
# CSS Grid and Layout demonstrations
+
dune exec examples/layout_and_spacing_03.exe > layout.html
-
# Run basic usage example
-
dune exec examples/basic_usage.exe
+
# Responsive design patterns
+
dune exec examples/responsive_design_04.exe > responsive.html
-
# Run HTML integration example
-
dune exec examples/tailwind_html_example.exe
+
# Visual effects and styling
+
dune exec examples/effects_and_variants_05.exe > effects.html
+
+
# Component patterns and reusable elements
+
dune exec examples/patterns_and_components_06.exe > patterns.html
+
+
# Complete application showcase
+
dune exec examples/comprehensive_showcase_07.exe > showcase.html
+
+
# Button component demonstration
+
dune exec examples/button_demo.exe > buttons.html
+
+
# Generate index page linking all examples
+
dune exec examples/index_html_generator.exe > index.html
```
-
### Comprehensive Showcase
+
### Example Highlights
+
+
**CSS Grid Layout (`layout_and_spacing_03.ml`)**:
+
```ocaml
+
(* Three-column grid with gap variations *)
+
div ~styles:[
+
grid;
+
grid_cols 3;
+
gap (rem 1.0);
+
] [
+
div ~styles:[bg_color (blue 100); padding (rem 1.0)] [txt "Item 1"];
+
div ~styles:[bg_color (green 100); padding (rem 1.0)] [txt "Item 2"];
+
div ~styles:[bg_color (purple 100); padding (rem 1.0)] [txt "Item 3"];
+
]
-
The comprehensive showcase demonstrates all library features and generates:
-
- `showcase.html` - Complete HTML page with all Tailwind classes
-
- `input.css` - Tailwind v4 CSS with custom theme extensions
+
(* Asymmetric grid gaps *)
+
div ~styles:[
+
grid;
+
grid_cols 2;
+
gap_x (rem 2.0);
+
gap_y (rem 0.5);
+
] (List.init 4 (fun i ->
+
div ~styles:[bg_color (purple 200); text_center] [
+
txt (Printf.sprintf "Box %d" (i + 1))
+
]
+
))
+
```
-
```bash
-
dune exec examples/comprehensive_showcase.exe
-
# Then open showcase.html in your browser
+
**Built-in Components (`button_demo.ml`)**:
+
```ocaml
+
(* Size variants with consistent styling *)
+
div ~styles:[flex; flex_col; gap (rem 1.0)] [
+
btn_primary ~size:`Sm [txt "Small Primary"];
+
btn_primary [txt "Default Primary"];
+
btn_primary ~size:`Lg [txt "Large Primary"];
+
btn_secondary [txt "Secondary Button"];
+
btn_outline [txt "Outline Button"];
+
]
+
```
+
+
**Responsive Cards (`comprehensive_showcase_07.ml`)**:
+
```ocaml
+
section ~styles:[margin_bottom (rem 4.0)] [
+
h3 ~styles:[font_size `Xl2; text_center; margin_bottom (rem 3.0)] [
+
txt "Features"
+
];
+
+
div ~styles:[grid; grid_cols 1; gap (rem 2.0)] [
+
card [
+
h4 ~styles:[font_size `Xl; font_weight `Semibold; text_color (blue 600)] [
+
txt "๐ŸŽฏ Type Safety"
+
];
+
p ~styles:[text_color (gray 600)] [
+
txt "Catch styling errors at compile time with GADT-based type checking."
+
];
+
];
+
card [
+
h4 ~styles:[font_size `Xl; font_weight `Semibold; text_color (green 600)] [
+
txt "โšก Performance"
+
];
+
p ~styles:[text_color (gray 600)] [
+
txt "Zero runtime overhead with compile-time CSS generation."
+
];
+
];
+
];
+
]
```
## Tailwind v4 Support
···
npx tailwindcss@next -i input.css -o output.css
```
-
## Module Documentation
+
## API Reference
-
### Core Modules
+
### `Tailwind_html` (GADT Interface)
-
#### `Tailwind`
-
Main module that exports all utilities and provides the `tw` function for composing classes.
+
The high-level GADT interface provides succinct, type-safe styling with heterogeneous lists:
-
#### `Color`
-
Type-safe color system with variants:
+
#### Layout Properties
```ocaml
-
Color.bg (Color.make `Blue ~variant:`V600 ())
-
Color.text Color.white
-
Color.border (Color.make `Gray ~variant:`V200 ())
+
~styles:[
+
(* Display *)
+
grid | flex | block | inline | hidden;
+
+
(* Grid System *)
+
grid_cols 3 | grid_rows 2;
+
gap (rem 1.0) | gap_x (rem 1.5) | gap_y (rem 0.5);
+
+
(* Flexbox *)
+
flex_col | flex_row;
+
justify_center | justify_between | justify_end;
+
items_center | items_start | items_end;
+
+
(* Sizing *)
+
width full | height screen;
+
min_height screen | max_width (rem 64.0);
+
]
```
-
#### `Typography`
-
Font utilities:
+
#### Typography Properties
```ocaml
-
Typography.(to_class (font_size `Xl2))
-
Typography.(to_class (font_weight `Bold))
-
Typography.(to_class (line_height `Relaxed))
+
~styles:[
+
(* Font Sizes *)
+
font_size `Xs | font_size `Sm | font_size `Base | font_size `Lg;
+
font_size `Xl | font_size `Xl2 | font_size `Xl3;
+
+
(* Font Weights *)
+
font_weight `Light | font_weight `Normal | font_weight `Medium;
+
font_weight `Semibold | font_weight `Bold;
+
+
(* Text Styling *)
+
text_center | text_left | text_right;
+
text_color (blue 600) | text_color (gray 500);
+
]
```
-
#### `Spacing`
-
Margin and padding utilities:
+
#### Color System
```ocaml
-
Spacing.(to_class (p (Size.rem 1.0))) (* padding *)
-
Spacing.(to_class (mx Size.auto)) (* margin-x auto *)
-
Spacing.(to_class (gap `All (Size.px 16.0))) (* gap *)
+
~styles:[
+
(* Background Colors *)
+
bg_color (blue 50) | bg_color (gray 100) | bg_color (red 500);
+
bg_color (Tailwind.Color.white) | bg_color (green 600);
+
+
(* Text Colors *)
+
text_color (gray 800) | text_color (blue 600) | text_color (red 500);
+
+
(* Border Colors *)
+
border_color (gray 200) | border_color (blue 300);
+
]
```
-
#### `Layout`
-
Layout utilities:
+
#### Spacing Properties
```ocaml
-
Layout.(to_class (width (Size.percent 100.0)))
-
Layout.(to_class (height Size.screen))
-
Layout.(to_class (max_width (Size.rem 64.0)))
+
~styles:[
+
(* Padding *)
+
padding (rem 1.0) | padding_x (rem 1.5) | padding_y (rem 2.0);
+
+
(* Margin *)
+
margin (rem 1.0) | margin_x auto | margin_bottom (rem 2.0);
+
margin_top (rem 1.5) | margin_left (rem 0.5);
+
]
```
-
#### `Flexbox`
-
Flexbox utilities:
+
#### Visual Effects
```ocaml
-
Display.flex
-
Flexbox.(to_class (justify `Between))
-
Flexbox.(to_class (align_items `Center))
-
Flexbox.(to_class (direction `Col))
+
~styles:[
+
(* Shadows *)
+
shadow `Sm | shadow `Md | shadow `Lg | shadow `Xl;
+
+
(* Borders *)
+
border | rounded `Sm | rounded `Md | rounded `Lg | rounded `Full;
+
+
(* Transitions *)
+
transition;
+
]
```
-
#### `Grid`
-
CSS Grid utilities:
+
#### Built-in Components
```ocaml
-
Display.grid
-
Grid.(to_class (template_cols (`Cols 3)))
-
Grid.(to_class (gap (Size.rem 1.0)))
-
```
+
(* Button Components *)
+
btn_primary ~size:`Lg [txt "Primary Button"];
+
btn_secondary ~size:`Sm [txt "Secondary Button"];
+
btn_outline [txt "Outline Button"];
+
+
(* Layout Components *)
+
container [content]; (* Max-width container with auto margins *)
+
card [content]; (* Pre-styled card with padding and shadow *)
-
#### `Effects`
-
Visual effects:
-
```ocaml
-
Effects.shadow_lg
-
Effects.rounded_md
-
Effects.border
-
Effects.transition `All
+
(* HTML Elements with Styling *)
+
h1 ~styles:[font_size `Xl3; font_weight `Bold] [txt "Heading"];
+
p ~styles:[text_color (gray 600); margin_bottom (rem 1.0)] [txt "Paragraph"];
+
div ~styles:[grid; grid_cols 2; gap (rem 1.0)] [content];
+
section ~styles:[margin_bottom (rem 2.0)] [content];
```
-
#### `Responsive`
-
Responsive utilities:
-
```ocaml
-
Responsive.(to_class (at_breakpoint `Md Display.flex))
-
Responsive.(to_class (at_breakpoint `Lg (Grid.(to_class (template_cols (`Cols 4))))))
-
```
+
### Low-Level `Tailwind` Module
-
#### `Variants`
-
State variants:
-
```ocaml
-
Variants.hover (Color.bg (Color.make `Blue ~variant:`V700 ()))
-
Variants.focus Effects.ring
-
```
+
For advanced use cases, the core `Tailwind` module provides detailed control:
-
#### `Patterns`
-
Common layout patterns:
```ocaml
-
Patterns.container ()
-
Patterns.card
-
Patterns.flex_center
-
Patterns.stack ~gap:(Size.rem 1.0) ()
-
Patterns.sticky_header
+
open Tailwind
+
+
let classes = Css.tw [
+
Display.grid;
+
Grid.(to_class (template_cols (`Cols 3)));
+
Spacing.(to_class (gap `All (Size.rem 1.0)));
+
Color.bg (Color.make `Blue ~variant:`V50 ());
+
]
+
+
let html_class = to_string classes (* "grid grid-cols-3 gap-4 bg-blue-50" *)
```
-
### HTML Components (`tailwind-html`)
+
### Getting Started
-
Pre-built components using Htmlit:
+
Add to your `dune-project`:
+
```dune
+
(package
+
(name myproject)
+
(depends
+
ocaml
+
dune
+
tailwind
+
tailwind-html
+
htmlit))
+
```
+
Then in your OCaml code:
```ocaml
+
open Htmlit
open Tailwind_html
-
(* Button component *)
-
Button.primary ~text:"Click me" ~onclick:"handleClick()"
-
-
(* Card component *)
-
Card.simple ~title:"Card Title" ~content:"Card content here"
-
-
(* Layout components *)
-
Layout.container [
-
Layout.row [
-
Layout.col ~span:6 [content];
-
Layout.col ~span:6 [content];
-
]
+
let my_page = El.html [
+
El.head [El.title [txt "My App"]];
+
El.body ~at:[classes_attr [min_height screen; bg_color (gray 50)]] [
+
container [
+
h1 ~styles:[font_size `Xl3; text_center; margin_bottom (rem 2.0)] [
+
txt "Welcome to Type-Safe CSS!"
+
];
+
btn_primary [txt "Get Started"];
+
];
+
];
]
```
+7 -15
dune-project
···
-
(lang dune 3.0)
+
(lang dune 3.18)
(name tailwind)
(generate_opam_files true)
-
(source
-
(github yourusername/tailwind-ocaml))
+
(authors "Anil Madhavapeddy")
-
(authors "Your Name")
-
-
(maintainers "Your Name")
-
-
(license MIT)
+
(maintainers "Anil Madhavapeddy")
-
(documentation https://yourusername.github.io/tailwind-ocaml/)
+
(license ISC)
(package
(name tailwind)
(synopsis "Type-safe Tailwind CSS generation for OCaml")
-
(description "A comprehensive OCaml library for generating Tailwind CSS classes with full type safety")
+
(description "Library for generating Tailwind CSS classes")
(depends
ocaml
-
(dune (>= 3.0))
(alcotest :with-test)
(qcheck :with-test)
(odoc :with-doc)))
···
(package
(name tailwind-html)
(synopsis "Tailwind CSS integration with Htmlit")
-
(description "High-level component library using Tailwind CSS with Htmlit")
-
(allow_empty)
+
(description "Html combinators for Tailwind CSS")
(depends
ocaml
-
(dune (>= 3.0))
tailwind
(htmlit (>= 0.1.0))
(alcotest :with-test)
(qcheck :with-test)
-
(odoc :with-doc)))
+
(odoc :with-doc)))
+71 -98
examples/button_demo.ml
···
-
(* Button Demo - Showcasing new button combinators *)
+
(* Button Demo - Showcasing GADT-based button interface *)
open Htmlit
open Tailwind_html
···
El.title [txt "Button Demo"];
El.link ~at:[At.rel "stylesheet"; At.href "button_demo.css"] ();
];
-
El.body ~at:[classes_attr (Tailwind.Css.tw [
-
Tailwind.Layout.(to_class (min_height screen));
-
Tailwind.Color.bg (gray 50);
-
Tailwind.Spacing.(to_class (p (rem 2.0)));
-
])] [
+
El.body ~at:[classes_attr [
+
min_height screen;
+
bg_color (gray 50);
+
padding (rem 2.0);
+
]] [
container [
-
h1 ~size:`Xl3 ~weight:`Bold ~color:(gray 800) ~align:`Center ~mb:(rem 2.0) [
-
txt "Button Combinator Demo"
-
];
+
h1 ~styles:[
+
font_size `Xl3;
+
font_weight `Bold;
+
text_color (gray 800);
+
text_center;
+
margin_bottom (rem 2.0);
+
] [txt "Button Component Demo"];
-
p_styled ~size:`Lg ~color:(gray 600) ~align:`Center ~mb:(rem 3.0) [
-
txt "Showcasing succinct button creation with the new Tailwind_html API"
-
];
+
p ~styles:[
+
font_size `Lg;
+
text_color (gray 600);
+
text_center;
+
margin_bottom (rem 3.0);
+
] [txt "Showcase of built-in button components using GADT interface"];
-
(* Button examples section *)
-
div ~classes:(Tailwind.Css.tw [
-
Tailwind.Spacing.(to_class (gap `All (rem 2.0)));
-
flex;
-
Tailwind.Flexbox.(to_class (direction `Col));
-
]) [
-
(* Primary buttons *)
-
card [
-
h2 ~size:`Xl ~weight:`Semibold ~color:(gray 700) ~mb:(rem 1.5) [
-
txt "Primary Buttons"
-
];
-
div ~classes:(Tailwind.Css.tw [
-
flex;
-
Tailwind.Flexbox.(to_class (wrap `Wrap));
-
Tailwind.Spacing.(to_class (gap `All (rem 1.0)));
-
]) [
-
btn_primary ~size:`Sm [txt "Small Primary"];
-
btn_primary [txt "Default Primary"];
-
btn_primary ~size:`Lg [txt "Large Primary"];
-
btn_primary ~disabled:true [txt "Disabled Primary"];
-
];
+
(* Primary buttons section *)
+
card [
+
h2 ~styles:[
+
font_size `Xl;
+
font_weight `Semibold;
+
text_color (gray 700);
+
margin_bottom (rem 1.5);
+
] [txt "Primary Buttons"];
+
+
div ~styles:[
+
flex;
+
flex_col;
+
margin_bottom (rem 1.0);
+
] [
+
btn_primary ~size:`Sm [txt "Small Primary"];
+
btn_primary [txt "Default Primary"];
+
btn_primary ~size:`Lg [txt "Large Primary"];
];
+
];
-
(* Secondary buttons *)
-
card [
-
h2 ~size:`Xl ~weight:`Semibold ~color:(gray 700) ~mb:(rem 1.5) [
-
txt "Secondary Buttons"
-
];
-
div ~classes:(Tailwind.Css.tw [
-
flex;
-
Tailwind.Flexbox.(to_class (wrap `Wrap));
-
Tailwind.Spacing.(to_class (gap `All (rem 1.0)));
-
]) [
-
btn_secondary ~size:`Sm [txt "Small Secondary"];
-
btn_secondary [txt "Default Secondary"];
-
btn_secondary ~size:`Lg [txt "Large Secondary"];
-
btn_secondary ~disabled:true [txt "Disabled Secondary"];
-
];
+
(* Secondary buttons section *)
+
card [
+
h2 ~styles:[
+
font_size `Xl;
+
font_weight `Semibold;
+
text_color (gray 700);
+
margin_bottom (rem 1.5);
+
] [txt "Secondary Buttons"];
+
+
div ~styles:[
+
flex;
+
flex_col;
+
margin_bottom (rem 1.0);
+
] [
+
btn_secondary ~size:`Sm [txt "Small Secondary"];
+
btn_secondary [txt "Default Secondary"];
+
btn_secondary ~size:`Lg [txt "Large Secondary"];
];
+
];
-
(* Comparison section *)
-
card [
-
h2 ~size:`Xl ~weight:`Semibold ~color:(gray 700) ~mb:(rem 1.5) [
-
txt "Before vs After"
-
];
-
div ~classes:(Tailwind.Css.tw [
-
Tailwind.Display.grid;
-
Tailwind.Grid.(to_class (template_cols (`Cols 1)));
-
Tailwind.Responsive.(to_class (at_breakpoint `Md (Tailwind.Grid.(to_class (template_cols (`Cols 2))))));
-
Tailwind.Spacing.(to_class (gap `All (rem 2.0)));
-
]) [
-
div [
-
h2 ~size:`Lg ~weight:`Medium ~color:(red 600) ~mb:(rem 1.0) [
-
txt "โŒ Old Verbose Way"
-
];
-
El.pre ~at:[classes_attr (Tailwind.Css.tw [
-
Tailwind.Color.bg (gray 100);
-
Tailwind.Spacing.(to_class (p (rem 1.0)));
-
Tailwind.Effects.rounded_md;
-
Tailwind.Typography.(to_class (font_size `Sm));
-
Tailwind.Layout.(to_class (overflow `X `Auto));
-
])] [
-
El.code [txt {|let btn_classes = Css.tw [
-
Color.bg (Color.make `Blue ~variant:`V600 ());
-
Color.text Color.white;
-
Spacing.(to_class (px (Size.rem 1.0)));
-
Spacing.(to_class (py (Size.rem 0.5)));
-
Effects.rounded_md;
-
Typography.(to_class (font_weight `Medium));
-
] in
-
El.button ~at:[classes_attr btn_classes] [
-
El.txt "Click me!"
-
]|}];
-
];
-
];
-
div [
-
h2 ~size:`Lg ~weight:`Medium ~color:(green 600) ~mb:(rem 1.0) [
-
txt "โœ… New Succinct Way"
-
];
-
El.pre ~at:[classes_attr (Tailwind.Css.tw [
-
Tailwind.Color.bg (gray 100);
-
Tailwind.Spacing.(to_class (p (rem 1.0)));
-
Tailwind.Effects.rounded_md;
-
Tailwind.Typography.(to_class (font_size `Sm));
-
Tailwind.Layout.(to_class (overflow `X `Auto));
-
])] [
-
El.code [txt {|btn_primary [txt "Click me!"]|}];
-
];
-
];
-
];
+
(* Outline buttons section *)
+
card [
+
h2 ~styles:[
+
font_size `Xl;
+
font_weight `Semibold;
+
text_color (gray 700);
+
margin_bottom (rem 1.5);
+
] [txt "Outline Buttons"];
+
+
div ~styles:[
+
flex;
+
flex_col;
+
] [
+
btn_outline ~size:`Sm [txt "Small Outline"];
+
btn_outline [txt "Default Outline"];
+
btn_outline ~size:`Lg [txt "Large Outline"];
];
];
];
+73 -174
examples/colors_and_typography_02.ml
···
-
(* Example 02: Colors and Typography - Exploring the Type System *)
+
(* Example 02: Colors and Typography - GADT interface showcase *)
open Htmlit
-
open Tailwind
-
-
let classes_attr tailwind_classes =
-
At.class' (Tailwind.to_string tailwind_classes)
+
open Tailwind_html
let create_color_demo () =
-
(* Color variants demonstration *)
-
let color_examples = [
-
("Blue 400", Color.make `Blue ~variant:`V400 ());
-
("Blue 600", Color.make `Blue ~variant:`V600 ());
-
("Green 500", Color.make `Green ~variant:`V500 ());
-
("Red 500", Color.make `Red ~variant:`V500 ());
-
("Purple 600", Color.make `Purple ~variant:`V600 ());
-
("Gray 700", Color.make `Gray ~variant:`V700 ());
-
] in
-
-
let typography_examples = [
-
("Extra Small", Typography.(to_class (font_size `Xs)));
-
("Small", Typography.(to_class (font_size `Sm)));
-
("Base", Typography.(to_class (font_size `Base)));
-
("Large", Typography.(to_class (font_size `Lg)));
-
("Extra Large", Typography.(to_class (font_size `Xl)));
-
("2X Large", Typography.(to_class (font_size `Xl2)));
-
] in
-
-
(* Create HTML demonstration *)
-
let html_doc = El.html [
+
let html = El.html [
El.head [
El.meta ~at:[At.charset "utf-8"] ();
El.meta ~at:[At.name "viewport"; At.content "width=device-width, initial-scale=1"] ();
-
El.title [El.txt "Colors and Typography"];
+
El.title [txt "Colors and Typography"];
El.link ~at:[At.rel "stylesheet"; At.href "colors_and_typography_02.css"] ();
];
-
El.body ~at:[At.class' "min-h-screen bg-gray-50 p-8"] [
-
El.div ~at:[At.class' "max-w-4xl mx-auto"] [
-
El.h1 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Xl2));
-
Typography.(to_class (font_weight `Bold));
-
Color.text (Color.make `Gray ~variant:`V800 ());
-
]); At.class' "mb-8 text-center"] [El.txt "Colors and Typography Demo"];
+
El.body ~at:[classes_attr [
+
min_height screen;
+
bg_color (gray 50);
+
padding (rem 2.0);
+
]] [
+
container [
+
h1 ~styles:[
+
font_size `Xl2;
+
font_weight `Bold;
+
text_color (gray 800);
+
text_center;
+
margin_bottom (rem 2.0);
+
] [txt "Colors and Typography Demo"];
-
El.p ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Lg));
-
Color.text (Color.make `Gray ~variant:`V600 ());
-
]); At.class' "text-center mb-12"] [
-
El.txt "Explore the type-safe color system and typography utilities in Tailwind OCaml."
-
];
+
p ~styles:[
+
font_size `Lg;
+
text_color (gray 600);
+
text_center;
+
margin_bottom (rem 3.0);
+
] [txt "Explore type-safe colors and typography with the GADT interface"];
-
(* Color Palette Section *)
-
El.section ~at:[At.class' "mb-12"] [
-
El.h2 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Xl));
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V700 ());
-
]); At.class' "mb-8"] [El.txt "Color Palette"];
+
(* Color demonstrations *)
+
section ~styles:[margin_bottom (rem 3.0)] [
+
h2 ~styles:[
+
font_size `Xl;
+
font_weight `Semibold;
+
text_color (gray 700);
+
margin_bottom (rem 2.0);
+
] [txt "Color Palette"];
-
El.div ~at:[classes_attr (Css.tw [
-
Display.grid;
-
Grid.(to_class (template_cols (`Cols 1)));
-
Responsive.(to_class (at_breakpoint `Md (Grid.(to_class (template_cols (`Cols 2))))));
-
Responsive.(to_class (at_breakpoint `Lg (Grid.(to_class (template_cols (`Cols 3))))));
-
Spacing.(to_class (gap `All (Size.rem 1.5)));
-
])] (List.map (fun (name, color) ->
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg Color.white;
-
Spacing.(to_class (p (Size.rem 1.5)));
-
Effects.rounded_lg;
-
Effects.shadow_sm;
-
]); At.class' "text-center"] [
-
El.div ~at:[classes_attr (Css.tw [
-
Color.text color;
-
Typography.(to_class (font_size `Xl2));
-
Typography.(to_class (font_weight `Bold));
-
]); At.class' "mb-4"] [El.txt "Aa"];
-
El.h3 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Lg));
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V800 ());
-
]); At.class' "mb-2"] [El.txt name];
-
El.p ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Sm));
-
Color.text (Color.make `Gray ~variant:`V500 ());
-
]); At.class' "mb-3"] [El.txt (to_string (Css.tw [Color.text color]))];
-
El.p ~at:[classes_attr (Css.tw [Color.text color])] [
-
El.txt "The quick brown fox jumps over the lazy dog"
-
];
-
]
-
) color_examples);
+
(* Using CSS Grid for color cards *)
+
div ~styles:[
+
grid;
+
grid_cols 2;
+
gap (rem 1.0);
+
] [
+
card [
+
p ~styles:[text_color (blue 600); font_size `Lg]
+
[txt "Blue 600 - Primary color"];
+
];
+
card [
+
p ~styles:[text_color (green 500); font_size `Lg]
+
[txt "Green 500 - Success color"];
+
];
+
card [
+
p ~styles:[text_color (red 500); font_size `Lg]
+
[txt "Red 500 - Error color"];
+
];
+
card [
+
p ~styles:[text_color (purple 600); font_size `Lg]
+
[txt "Purple 600 - Accent color"];
+
];
+
];
];
-
(* Typography Scale Section *)
-
El.section ~at:[At.class' "mb-12"] [
-
El.h2 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Xl));
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V700 ());
-
]); At.class' "mb-8"] [El.txt "Typography Scale"];
+
(* Typography scale *)
+
section [
+
h2 ~styles:[
+
font_size `Xl;
+
font_weight `Semibold;
+
text_color (gray 700);
+
margin_bottom (rem 2.0);
+
] [txt "Typography Scale"];
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg Color.white;
-
Spacing.(to_class (p (Size.rem 2.0)));
-
Effects.rounded_lg;
-
Effects.shadow_sm;
-
]); At.class' "mb-8"] (List.map (fun (name, typ_class) ->
-
El.div ~at:[At.class' "mb-6 last:mb-0"] [
-
El.div ~at:[classes_attr (Css.tw [
-
Display.flex;
-
Flexbox.(to_class (align_items `Center));
-
Flexbox.(to_class (justify `Between));
-
Spacing.(to_class (gap `All (Size.rem 1.0)));
-
]); At.class' "mb-2"] [
-
El.span ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Sm));
-
Typography.(to_class (font_weight `Medium));
-
Color.text (Color.make `Gray ~variant:`V500 ());
-
])] [El.txt name];
-
El.code ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Xs));
-
Color.bg (Color.make `Gray ~variant:`V100 ());
-
Spacing.(to_class (px (Size.rem 0.5)));
-
Spacing.(to_class (py (Size.rem 0.25)));
-
Effects.rounded_sm;
-
])] [El.txt (to_string (Css.tw [typ_class]))];
-
];
-
El.p ~at:[classes_attr (Css.tw [typ_class])] [
-
El.txt "The quick brown fox jumps over the lazy dog"
-
];
-
]
-
) typography_examples);
-
];
-
-
(* Font Weights Section *)
-
El.section [
-
El.h2 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Xl));
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V700 ());
-
]); At.class' "mb-8"] [El.txt "Font Weights"];
-
-
let weight_examples = [
-
("Light", Typography.(to_class (font_weight `Light)));
-
("Normal", Typography.(to_class (font_weight `Normal)));
-
("Medium", Typography.(to_class (font_weight `Medium)));
-
("Semibold", Typography.(to_class (font_weight `Semibold)));
-
("Bold", Typography.(to_class (font_weight `Bold)));
-
("Extrabold", Typography.(to_class (font_weight `Extrabold)));
-
] in
-
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg Color.white;
-
Spacing.(to_class (p (Size.rem 2.0)));
-
Effects.rounded_lg;
-
Effects.shadow_sm;
-
])] (List.map (fun (name, weight_class) ->
-
El.div ~at:[At.class' "mb-6 last:mb-0"] [
-
El.div ~at:[classes_attr (Css.tw [
-
Display.flex;
-
Flexbox.(to_class (align_items `Center));
-
Flexbox.(to_class (justify `Between));
-
Spacing.(to_class (gap `All (Size.rem 1.0)));
-
]); At.class' "mb-2"] [
-
El.span ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Sm));
-
Typography.(to_class (font_weight `Medium));
-
Color.text (Color.make `Gray ~variant:`V500 ());
-
])] [El.txt name];
-
El.code ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Xs));
-
Color.bg (Color.make `Gray ~variant:`V100 ());
-
Spacing.(to_class (px (Size.rem 0.5)));
-
Spacing.(to_class (py (Size.rem 0.25)));
-
Effects.rounded_sm;
-
])] [El.txt (to_string (Css.tw [weight_class]))];
-
];
-
El.p ~at:[classes_attr (Css.tw [
-
weight_class;
-
Typography.(to_class (font_size `Lg));
-
])] [
-
El.txt "The quick brown fox jumps over the lazy dog"
-
];
-
]
-
) weight_examples);
+
card [
+
p ~styles:[font_size `Xs; margin_bottom (rem 1.0)] [txt "Extra Small (xs) - Supporting text"];
+
p ~styles:[font_size `Sm; margin_bottom (rem 1.0)] [txt "Small (sm) - Caption text"];
+
p ~styles:[font_size `Base; margin_bottom (rem 1.0)] [txt "Base - Body text"];
+
p ~styles:[font_size `Lg; margin_bottom (rem 1.0)] [txt "Large (lg) - Lead text"];
+
p ~styles:[font_size `Xl; margin_bottom (rem 1.0)] [txt "Extra Large (xl) - Heading"];
+
p ~styles:[font_size `Xl2] [txt "2XL - Large heading"];
+
];
];
];
];
] in
-
html_doc
+
html
let () =
-
(* Output HTML to stdout *)
-
let html_doc = create_color_demo () in
-
print_string (El.to_string ~doctype:true html_doc)
+
let html = create_color_demo () in
+
print_string (El.to_string ~doctype:true html)
+189 -203
examples/comprehensive_showcase_07.ml
···
-
(* Example 07: Comprehensive Showcase - Full Application Demo *)
+
(* Example 07: Comprehensive Showcase - Full application demo with GADT *)
open Htmlit
-
open Tailwind
+
open Tailwind_html
-
let classes_attr tailwind_classes =
-
At.class' (Tailwind.to_string tailwind_classes)
-
-
let create_comprehensive_html_page () =
-
(* Document structure with all features demonstrated *)
-
let html_doc = El.html [
+
let create_showcase () =
+
let html = El.html [
El.head [
El.meta ~at:[At.charset "utf-8"] ();
El.meta ~at:[At.name "viewport"; At.content "width=device-width, initial-scale=1"] ();
-
El.title [El.txt "Tailwind OCaml - Complete Feature Showcase"];
+
El.title [txt "Comprehensive Showcase"];
El.link ~at:[At.rel "stylesheet"; At.href "comprehensive_showcase_07.css"] ();
];
-
-
El.body ~at:[classes_attr (Tailwind.Css.tw [
-
Color.bg (Color.make `Gray ~variant:`V50 ());
-
Typography.(to_class (font_size `Base));
-
Typography.(to_class (line_height `Normal));
-
])] [
-
(* Header with navigation *)
-
El.header ~at:[classes_attr (Tailwind.Css.tw [
-
Color.bg Color.white;
-
Effects.shadow_lg;
-
Effects.border;
-
Color.border (Color.make `Gray ~variant:`V200 ());
-
Patterns.sticky_header;
-
])] [
-
El.div ~at:[classes_attr (Tailwind.Css.tw [
-
Patterns.container ();
-
Spacing.(to_class (px (Size.rem 1.0)));
-
])] [
-
El.div ~at:[classes_attr (Tailwind.Css.tw [
-
Display.flex;
-
Flexbox.(to_class (justify `Between));
-
Flexbox.(to_class (align_items `Center));
-
Layout.(to_class (height (Size.rem 4.0)));
-
])] [
-
(* Brand with gradient text *)
-
El.h1 ~at:[classes_attr (Tailwind.Css.tw [
-
Typography.(to_class (font_size `Xl2));
-
Typography.(to_class (font_weight `Bold));
-
Color.text (Color.make `Blue ~variant:`V600 ());
-
])] [El.txt "Tailwind OCaml"];
+
El.body ~at:[classes_attr [
+
min_height screen;
+
bg_color (gray 50);
+
]] [
+
(* Header *)
+
header ~styles:[
+
bg_color (Tailwind.Color.white);
+
shadow `Md;
+
padding (rem 1.0);
+
] [
+
container [
+
div ~styles:[
+
flex;
+
justify_between;
+
items_center;
+
] [
+
h1 ~styles:[
+
font_size `Xl;
+
font_weight `Bold;
+
text_color (blue 600);
+
] [txt "TailwindOCaml"];
-
(* Navigation items with hover effects *)
-
El.nav ~at:[classes_attr (Tailwind.Css.tw [
-
Display.flex;
-
Spacing.(to_class (gap `All (Size.rem 2.0)));
-
Flexbox.(to_class (align_items `Center));
-
])] [
-
El.a ~at:[At.href "#typography"; classes_attr (Tailwind.Css.tw [
-
Color.text (Color.make `Gray ~variant:`V600 ());
-
Variants.hover (Color.text (Color.make `Gray ~variant:`V900 ()));
-
Effects.transition `All;
-
])] [El.txt "Typography"];
-
El.a ~at:[At.href "#layout"; classes_attr (Tailwind.Css.tw [
-
Color.text (Color.make `Gray ~variant:`V600 ());
-
Variants.hover (Color.text (Color.make `Gray ~variant:`V900 ()));
-
Effects.transition `All;
-
])] [El.txt "Layout"];
-
El.a ~at:[At.href "#components"; classes_attr (Tailwind.Css.tw [
-
Color.text (Color.make `Gray ~variant:`V600 ());
-
Variants.hover (Color.text (Color.make `Gray ~variant:`V900 ()));
-
Effects.transition `All;
-
])] [El.txt "Components"];
-
-
(* CTA Button *)
-
El.button ~at:[classes_attr (Tailwind.Css.tw [
-
Color.bg (Color.make `Blue ~variant:`V600 ());
-
Color.text Color.white;
-
Spacing.(to_class (px (Size.rem 1.0)));
-
Spacing.(to_class (py (Size.rem 0.5)));
-
Effects.rounded_md;
-
Typography.(to_class (font_size `Sm));
-
Typography.(to_class (font_weight `Medium));
-
Variants.hover (Color.bg (Color.make `Blue ~variant:`V700 ()));
-
Effects.transition `All;
-
])] [El.txt "Get Started"];
+
nav ~styles:[flex] [
+
a ~styles:[
+
padding_x (rem 1.0);
+
text_color (gray 700);
+
font_weight `Medium;
+
] ~href:"#features" [txt "Features"];
+
a ~styles:[
+
padding_x (rem 1.0);
+
text_color (gray 700);
+
font_weight `Medium;
+
] ~href:"#demo" [txt "Demo"];
+
a ~styles:[
+
padding_x (rem 1.0);
+
text_color (gray 700);
+
font_weight `Medium;
+
] ~href:"#contact" [txt "Contact"];
];
];
];
];
-
(* Main Content *)
-
El.main [
-
(* Hero Section *)
-
El.section ~at:[At.id "hero"; classes_attr (Tailwind.Css.tw [
-
Layout.(to_class (min_height Size.screen));
-
Display.flex;
-
Flexbox.(to_class (align_items `Center));
-
Flexbox.(to_class (justify `Center));
-
Color.bg (Color.make `Gray ~variant:`V900 ());
-
Color.text Color.white;
-
])] [
-
El.div ~at:[At.class' "text-center container px-8"] [
-
El.h1 ~at:[classes_attr (Tailwind.Css.tw [
-
Typography.(to_class (font_size `Xl5));
-
Typography.(to_class (font_weight `Extrabold));
-
Spacing.(to_class (mb (Size.rem 1.5)));
-
])] [El.txt "Type-Safe Tailwind CSS"];
+
(* Hero Section *)
+
main ~styles:[padding_y (rem 4.0)] [
+
container [
+
div ~styles:[text_center; margin_bottom (rem 4.0)] [
+
h2 ~styles:[
+
font_size `Xl3;
+
font_weight `Bold;
+
text_color (gray 800);
+
margin_bottom (rem 1.5);
+
] [txt "Type-Safe CSS with GADT Interface"];
-
El.p ~at:[classes_attr (Tailwind.Css.tw [
-
Typography.(to_class (font_size `Xl));
-
Color.text (Color.make `Gray ~variant:`V100 ());
-
Spacing.(to_class (mb (Size.rem 2.0)));
-
Typography.(to_class (line_height `Relaxed));
-
])] [El.txt "Build beautiful, responsive web interfaces with OCaml's type system and Tailwind's utility classes."];
+
p ~styles:[
+
font_size `Xl;
+
text_color (gray 600);
+
margin_bottom (rem 2.0);
+
] [txt "Build beautiful, maintainable UIs with compile-time guarantees"];
-
El.div ~at:[At.class' "flex flex-wrap gap-4 justify-center"] [
-
El.button ~at:[At.class' "btn-primary"] [El.txt "๐Ÿš€ Get Started"];
-
El.button ~at:[At.class' "btn-ghost text-white hover:bg-white hover:text-gray-900"] [El.txt "๐Ÿ“– View Docs"];
+
div ~styles:[flex; justify_center] [
+
btn_primary ~size:`Lg [txt "Get Started"];
+
btn_outline ~size:`Lg [txt "Learn More"];
];
];
-
];
-
-
(* Features Grid *)
-
El.section ~at:[At.class' "section bg-white"] [
-
El.div ~at:[At.class' "container"] [
-
El.h2 ~at:[At.class' "text-3xl font-bold text-center mb-12"] [El.txt "Features"];
+
+
(* Features Grid *)
+
section ~styles:[margin_bottom (rem 4.0)] [
+
h3 ~styles:[
+
font_size `Xl2;
+
font_weight `Bold;
+
text_color (gray 800);
+
text_center;
+
margin_bottom (rem 3.0);
+
] [txt "Features"];
-
El.div ~at:[At.class' "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"] [
-
(* Feature cards *)
-
El.div ~at:[At.class' "card p-6"] [
-
El.div ~at:[At.class' "w-12 h-12 bg-blue-100 rounded-lg flex items-center justify-center mb-4"] [
-
El.span ~at:[At.class' "text-2xl"] [El.txt "๐ŸŽจ"];
-
];
-
El.h3 ~at:[At.class' "text-lg font-semibold mb-2"] [El.txt "Type-Safe Classes"];
-
El.p ~at:[At.class' "text-gray-600"] [
-
El.txt "Compile-time validation ensures your Tailwind classes are always correct."
-
];
-
];
-
-
El.div ~at:[At.class' "card p-6"] [
-
El.div ~at:[At.class' "w-12 h-12 bg-green-100 rounded-lg flex items-center justify-center mb-4"] [
-
El.span ~at:[At.class' "text-2xl"] [El.txt "โšก"];
-
];
-
El.h3 ~at:[At.class' "text-lg font-semibold mb-2"] [El.txt "Fast Development"];
-
El.p ~at:[At.class' "text-gray-600"] [
-
El.txt "Autocomplete and type hints speed up your development workflow."
+
div ~styles:[
+
grid;
+
grid_cols 1;
+
gap (rem 2.0);
+
] [
+
card [
+
h4 ~styles:[
+
font_size `Xl;
+
font_weight `Semibold;
+
text_color (blue 600);
+
margin_bottom (rem 1.0);
+
] [txt "๐ŸŽฏ Type Safety"];
+
p ~styles:[text_color (gray 600)] [
+
txt "Catch styling errors at compile time with GADT-based type checking."
];
];
-
El.div ~at:[At.class' "card p-6"] [
-
El.div ~at:[At.class' "w-12 h-12 bg-purple-100 rounded-lg flex items-center justify-center mb-4"] [
-
El.span ~at:[At.class' "text-2xl"] [El.txt "๐Ÿ”ง"];
-
];
-
El.h3 ~at:[At.class' "text-lg font-semibold mb-2"] [El.txt "Modular Design"];
-
El.p ~at:[At.class' "text-gray-600"] [
-
El.txt "Organized modules for colors, typography, layout, and more."
+
card [
+
h4 ~styles:[
+
font_size `Xl;
+
font_weight `Semibold;
+
text_color (green 600);
+
margin_bottom (rem 1.0);
+
] [txt "โšก Performance"];
+
p ~styles:[text_color (gray 600)] [
+
txt "Zero runtime overhead with compile-time CSS generation."
];
];
-
El.div ~at:[At.class' "card p-6"] [
-
El.div ~at:[At.class' "w-12 h-12 bg-red-100 rounded-lg flex items-center justify-center mb-4"] [
-
El.span ~at:[At.class' "text-2xl"] [El.txt "๐Ÿ“ฑ"];
-
];
-
El.h3 ~at:[At.class' "text-lg font-semibold mb-2"] [El.txt "Responsive Design"];
-
El.p ~at:[At.class' "text-gray-600"] [
-
El.txt "Built-in responsive utilities for all screen sizes."
+
card [
+
h4 ~styles:[
+
font_size `Xl;
+
font_weight `Semibold;
+
text_color (purple 600);
+
margin_bottom (rem 1.0);
+
] [txt "๐Ÿ”ง Developer Experience"];
+
p ~styles:[text_color (gray 600)] [
+
txt "Succinct syntax with heterogeneous lists and type inference."
];
];
+
];
+
];
+
+
(* Demo Section *)
+
section ~styles:[margin_bottom (rem 4.0)] [
+
h3 ~styles:[
+
font_size `Xl2;
+
font_weight `Bold;
+
text_color (gray 800);
+
text_center;
+
margin_bottom (rem 3.0);
+
] [txt "Live Demo"];
+
+
card ~elevated:true [
+
h4 ~styles:[
+
font_size `Xl;
+
font_weight `Semibold;
+
text_color (gray 800);
+
margin_bottom (rem 1.5);
+
] [txt "Interactive Component"];
-
El.div ~at:[At.class' "card p-6"] [
-
El.div ~at:[At.class' "w-12 h-12 bg-yellow-100 rounded-lg flex items-center justify-center mb-4"] [
-
El.span ~at:[At.class' "text-2xl"] [El.txt "๐ŸŽฏ"];
-
];
-
El.h3 ~at:[At.class' "text-lg font-semibold mb-2"] [El.txt "Production Ready"];
-
El.p ~at:[At.class' "text-gray-600"] [
-
El.txt "Generate optimized CSS with Tailwind v4 CLI integration."
-
];
+
div ~styles:[margin_bottom (rem 2.0)] [
+
El.label ~at:[At.for' "demo-input"; classes_attr [
+
block;
+
font_weight `Medium;
+
text_color (gray 700);
+
margin_bottom (rem 0.5);
+
]] [txt "Try it out:"];
+
El.input ~at:[At.type' "text"; At.id "demo-input"; At.placeholder "Type something..."; classes_attr [
+
width full;
+
padding (rem 0.75);
+
border;
+
border_color (gray 300);
+
rounded `Md;
+
]] ();
];
-
El.div ~at:[At.class' "card p-6"] [
-
El.div ~at:[At.class' "w-12 h-12 bg-indigo-100 rounded-lg flex items-center justify-center mb-4"] [
-
El.span ~at:[At.class' "text-2xl"] [El.txt "๐Ÿš€"];
-
];
-
El.h3 ~at:[At.class' "text-lg font-semibold mb-2"] [El.txt "Modern Workflow"];
-
El.p ~at:[At.class' "text-gray-600"] [
-
El.txt "Integrates seamlessly with dune and modern OCaml tooling."
-
];
+
div ~styles:[flex; justify_end] [
+
btn_secondary [txt "Cancel"];
+
btn_primary [txt "Submit"];
];
];
];
-
];
-
-
(* Code Example Section *)
-
El.section ~at:[At.class' "section bg-gray-50"] [
-
El.div ~at:[At.class' "container"] [
-
El.h2 ~at:[At.class' "text-3xl font-bold text-center mb-12"] [El.txt "Simple & Intuitive"];
+
+
(* Statistics *)
+
section ~styles:[margin_bottom (rem 4.0)] [
+
h3 ~styles:[
+
font_size `Xl2;
+
font_weight `Bold;
+
text_color (gray 800);
+
text_center;
+
margin_bottom (rem 3.0);
+
] [txt "By the Numbers"];
-
El.div ~at:[At.class' "max-w-4xl mx-auto"] [
-
El.div ~at:[At.class' "bg-gray-900 rounded-lg p-6 text-white"] [
-
El.pre ~at:[At.class' "text-sm overflow-x-auto"] [
-
El.code [El.txt {|open Tailwind
-
-
let button_classes = Css.tw [
-
Color.bg (Color.make `Blue ~variant:`V600 ());
-
Color.text Color.white;
-
Spacing.(to_class (px (Size.rem 1.0)));
-
Spacing.(to_class (py (Size.rem 0.5)));
-
Effects.rounded_md;
-
Typography.(to_class (font_weight `Semibold));
-
Variants.hover (Color.bg (Color.make `Blue ~variant:`V700 ()));
-
]
-
-
let button =
-
El.button ~at:[At.class' (to_string button_classes)] [
-
El.txt "Click me!"
-
]|}];
-
];
+
div ~styles:[flex; justify_between; text_center] [
+
div [
+
p ~styles:[
+
font_size `Xl3;
+
font_weight `Bold;
+
text_color (blue 600);
+
] [txt "100%"];
+
p ~styles:[text_color (gray 600)] [txt "Type Safe"];
+
];
+
+
div [
+
p ~styles:[
+
font_size `Xl3;
+
font_weight `Bold;
+
text_color (green 600);
+
] [txt "0ms"];
+
p ~styles:[text_color (gray 600)] [txt "Runtime Cost"];
+
];
+
+
div [
+
p ~styles:[
+
font_size `Xl3;
+
font_weight `Bold;
+
text_color (purple 600);
+
] [txt "โˆž"];
+
p ~styles:[text_color (gray 600)] [txt "Possibilities"];
];
];
];
···
];
(* Footer *)
-
El.footer ~at:[At.class' "bg-gray-800 text-white py-12"] [
-
El.div ~at:[At.class' "container text-center"] [
-
El.p ~at:[At.class' "text-lg font-semibold mb-4"] [El.txt "Tailwind OCaml"];
-
El.p ~at:[At.class' "text-gray-300 mb-6"] [
-
El.txt "Type-safe Tailwind CSS for OCaml applications"
+
footer ~styles:[
+
bg_color (gray 800);
+
text_color (gray 200);
+
padding_y (rem 2.0);
+
text_center;
+
] [
+
container [
+
p ~styles:[margin_bottom (rem 1.0)] [
+
txt "ยฉ 2024 TailwindOCaml. Built with type-safe GADT interface."
];
-
El.div ~at:[At.class' "flex flex-wrap gap-8 justify-center"] [
-
El.a ~at:[At.href "#"; At.class' "text-gray-300 hover:text-white transition-colors"] [
-
El.txt "Documentation"
-
];
-
El.a ~at:[At.href "#"; At.class' "text-gray-300 hover:text-white transition-colors"] [
-
El.txt "GitHub"
-
];
-
El.a ~at:[At.href "#"; At.class' "text-gray-300 hover:text-white transition-colors"] [
-
El.txt "Examples"
-
];
-
El.a ~at:[At.href "#"; At.class' "text-gray-300 hover:text-white transition-colors"] [
-
El.txt "Support"
-
];
+
p ~styles:[font_size `Sm; text_color (gray 400)] [
+
txt "Powered by OCaml, Tailwind CSS, and compile-time guarantees."
];
];
];
];
] in
-
html_doc
+
html
let () =
-
(* Output HTML to stdout *)
-
let html_doc = create_comprehensive_html_page () in
-
let html_string = El.to_string ~doctype:true html_doc in
-
print_string html_string
+
let html = create_showcase () in
+
print_string (El.to_string ~doctype:true html)
+29 -12
examples/dune
···
-
;; Notebook-style examples - progressive learning path
+
;; Examples demonstrating GADT-based Tailwind interface
(executables
(public_names
index
hello_tailwind
colors_and_typography
layout_and_spacing
-
responsive_design
-
effects_and_variants
-
patterns_and_components
-
comprehensive_showcase)
+
responsive_design
+
effects_and_variants
+
patterns_and_components
+
comprehensive_showcase
+
button_demo)
(names
index_00
hello_tailwind_01
···
responsive_design_04
effects_and_variants_05
patterns_and_components_06
-
comprehensive_showcase_07)
+
comprehensive_showcase_07
+
button_demo)
(package tailwind)
(libraries tailwind tailwind-html htmlit unix))
···
(public_name index_html_generator)
(name index_html_generator)
(package tailwind)
-
(libraries tailwind htmlit))
-
+
(libraries tailwind tailwind-html htmlit))
;; Generate HTML files from examples
(rule
···
(deps (:exe comprehensive_showcase_07.exe))
(action (with-stdout-to %{target} (run %{exe}))))
+
(rule
+
(target button_demo.html)
+
(deps (:exe button_demo.exe))
+
(action (with-stdout-to %{target} (run %{exe}))))
+
;; Generate CSS files using Tailwind CLI
(rule
(targets hello_tailwind_01.css)
···
(action
(run tailwindcss --input input.css --output %{targets} --minify)))
+
(rule
+
(targets button_demo.css)
+
(deps
+
input.css
+
button_demo.html)
+
(action
+
(run tailwindcss --input input.css --output %{targets} --minify)))
+
;; Generate index.html page
(rule
(target index.html)
···
responsive_design_04.html
effects_and_variants_05.html
patterns_and_components_06.html
-
comprehensive_showcase_07.html))
+
comprehensive_showcase_07.html
+
button_demo.html))
;; Alias to build all CSS files (requires Tailwind CLI)
-
;; Run: npm install -D @tailwindcss/cli
(alias
(name examples-css)
(deps
···
responsive_design_04.css
effects_and_variants_05.css
patterns_and_components_06.css
-
comprehensive_showcase_07.css))
+
comprehensive_showcase_07.css
+
button_demo.css))
;; Install generated files
(install
···
(patterns_and_components_06.html as examples/patterns_and_components_06.html)
(patterns_and_components_06.css as examples/patterns_and_components_06.css)
(comprehensive_showcase_07.html as examples/comprehensive_showcase_07.html)
-
(comprehensive_showcase_07.css as examples/comprehensive_showcase_07.css)))
+
(comprehensive_showcase_07.css as examples/comprehensive_showcase_07.css)
+
(button_demo.html as examples/button_demo.html)
+
(button_demo.css as examples/button_demo.css)))
+183 -279
examples/effects_and_variants_05.ml
···
-
(* Example 05: Effects and Variants - Interactive Elements and Visual Effects *)
+
(* Example 05: Effects and Variants - Visual effects with GADT *)
open Htmlit
-
open Tailwind
-
-
let classes_attr tailwind_classes =
-
At.class' (Tailwind.to_string tailwind_classes)
+
open Tailwind_html
let create_effects_demo () =
-
-
(* Create comprehensive effects demonstration *)
-
let html_doc = El.html [
+
let html = El.html [
El.head [
El.meta ~at:[At.charset "utf-8"] ();
El.meta ~at:[At.name "viewport"; At.content "width=device-width, initial-scale=1"] ();
-
El.title [El.txt "Effects and Variants"];
+
El.title [txt "Effects and Variants"];
El.link ~at:[At.rel "stylesheet"; At.href "effects_and_variants_05.css"] ();
];
-
El.body ~at:[At.class' "min-h-screen bg-gray-50 p-8"] [
-
El.div ~at:[At.class' "max-w-6xl mx-auto"] [
-
El.h1 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Xl2));
-
Typography.(to_class (font_weight `Bold));
-
Color.text (Color.make `Gray ~variant:`V800 ());
-
]); At.class' "mb-8 text-center"] [El.txt "Effects and Variants Demo"];
+
El.body ~at:[classes_attr [
+
min_height screen;
+
bg_color (gray 50);
+
padding (rem 2.0);
+
]] [
+
container [
+
h1 ~styles:[
+
font_size `Xl2;
+
font_weight `Bold;
+
text_color (gray 800);
+
text_center;
+
margin_bottom (rem 2.0);
+
] [txt "Effects and Variants Demo"];
(* Shadow Effects *)
-
El.section ~at:[At.class' "mb-8"] [
-
El.h2 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Xl));
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V700 ());
-
]); At.class' "mb-6"] [El.txt "Shadow Effects"];
+
section ~styles:[margin_bottom (rem 2.0)] [
+
h2 ~styles:[
+
font_size `Xl;
+
font_weight `Semibold;
+
text_color (gray 700);
+
margin_bottom (rem 1.5);
+
] [txt "Shadow Effects"];
-
El.div ~at:[classes_attr (Css.tw [
-
Display.grid;
-
Grid.(to_class (template_cols (`Cols 1)));
-
Responsive.(to_class (at_breakpoint `Md (Grid.(to_class (template_cols (`Cols 3))))));
-
Spacing.(to_class (gap `All (Size.rem 1.5)));
-
])] [
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg Color.white;
-
Spacing.(to_class (p (Size.rem 1.5)));
-
Effects.shadow_sm;
-
Effects.rounded_lg;
-
]); At.class' "text-center"] [
-
El.h3 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V700 ());
-
]); At.class' "mb-2"] [El.txt "Small Shadow"];
-
El.p ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Sm));
-
Color.text (Color.make `Gray ~variant:`V600 ());
-
])] [El.txt "shadow-sm"];
+
div ~styles:[
+
grid;
+
grid_cols 1;
+
gap (rem 1.0);
+
] [
+
div ~styles:[
+
bg_color (Tailwind.Color.white);
+
padding (rem 1.5);
+
shadow `Sm;
+
rounded `Lg;
+
margin_bottom (rem 1.0);
+
text_center;
+
] [
+
h3 ~styles:[
+
font_weight `Semibold;
+
text_color (gray 700);
+
margin_bottom (rem 0.5);
+
] [txt "Small Shadow"];
+
p ~styles:[
+
font_size `Sm;
+
text_color (gray 600);
+
] [txt "shadow-sm"];
];
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg Color.white;
-
Spacing.(to_class (p (Size.rem 1.5)));
-
Effects.shadow_md;
-
Effects.rounded_lg;
-
]); At.class' "text-center"] [
-
El.h3 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V700 ());
-
]); At.class' "mb-2"] [El.txt "Medium Shadow"];
-
El.p ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Sm));
-
Color.text (Color.make `Gray ~variant:`V600 ());
-
])] [El.txt "shadow-md"];
+
div ~styles:[
+
bg_color (Tailwind.Color.white);
+
padding (rem 1.5);
+
shadow `Md;
+
rounded `Lg;
+
margin_bottom (rem 1.0);
+
text_center;
+
] [
+
h3 ~styles:[
+
font_weight `Semibold;
+
text_color (gray 700);
+
margin_bottom (rem 0.5);
+
] [txt "Medium Shadow"];
+
p ~styles:[
+
font_size `Sm;
+
text_color (gray 600);
+
] [txt "shadow-md"];
];
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg Color.white;
-
Spacing.(to_class (p (Size.rem 1.5)));
-
Effects.shadow_lg;
-
Effects.rounded_lg;
-
]); At.class' "text-center"] [
-
El.h3 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V700 ());
-
]); At.class' "mb-2"] [El.txt "Large Shadow"];
-
El.p ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Sm));
-
Color.text (Color.make `Gray ~variant:`V600 ());
-
])] [El.txt "shadow-lg"];
+
div ~styles:[
+
bg_color (Tailwind.Color.white);
+
padding (rem 1.5);
+
shadow `Lg;
+
rounded `Lg;
+
text_center;
+
] [
+
h3 ~styles:[
+
font_weight `Semibold;
+
text_color (gray 700);
+
margin_bottom (rem 0.5);
+
] [txt "Large Shadow"];
+
p ~styles:[
+
font_size `Sm;
+
text_color (gray 600);
+
] [txt "shadow-lg"];
];
];
];
(* Rounded Corners *)
-
El.section ~at:[At.class' "mb-8"] [
-
El.h2 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Xl));
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V700 ());
-
]); At.class' "mb-6"] [El.txt "Border Radius"];
+
section ~styles:[margin_bottom (rem 2.0)] [
+
h2 ~styles:[
+
font_size `Xl;
+
font_weight `Semibold;
+
text_color (gray 700);
+
margin_bottom (rem 1.5);
+
] [txt "Border Radius"];
-
El.div ~at:[classes_attr (Css.tw [
-
Display.flex;
-
Flexbox.(to_class (wrap `Wrap));
-
Spacing.(to_class (gap `All (Size.rem 1.0)));
-
Flexbox.(to_class (justify `Center));
-
])] [
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg (Color.make `Blue ~variant:`V100 ());
-
Spacing.(to_class (p (Size.rem 1.0)));
-
(* No rounded corners *)
-
]); At.class' "text-center"] [El.txt "No Radius"];
+
div ~styles:[
+
grid;
+
grid_cols 2;
+
gap (rem 1.0);
+
] [
+
div ~styles:[
+
bg_color (blue 100);
+
padding (rem 1.0);
+
rounded `Sm;
+
text_center;
+
margin_bottom (rem 1.0);
+
] [txt "Small Radius"];
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg (Color.make `Green ~variant:`V100 ());
-
Spacing.(to_class (p (Size.rem 1.0)));
-
Effects.rounded_sm;
-
]); At.class' "text-center"] [El.txt "Small"];
+
div ~styles:[
+
bg_color (green 100);
+
padding (rem 1.0);
+
rounded `Md;
+
text_center;
+
margin_bottom (rem 1.0);
+
] [txt "Medium Radius"];
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg (Color.make `Purple ~variant:`V100 ());
-
Spacing.(to_class (p (Size.rem 1.0)));
-
Effects.rounded_md;
-
]); At.class' "text-center"] [El.txt "Medium"];
-
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg (Color.make `Red ~variant:`V100 ());
-
Spacing.(to_class (p (Size.rem 1.0)));
-
Effects.rounded_lg;
-
]); At.class' "text-center"] [El.txt "Large"];
+
div ~styles:[
+
bg_color (purple 100);
+
padding (rem 1.0);
+
rounded `Lg;
+
text_center;
+
margin_bottom (rem 1.0);
+
] [txt "Large Radius"];
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg (Color.make `Yellow ~variant:`V100 ());
-
Spacing.(to_class (p (Size.rem 1.0)));
-
Effects.rounded_full;
-
]); At.class' "text-center"] [El.txt "Full"];
+
div ~styles:[
+
bg_color (yellow 100);
+
padding (rem 1.0);
+
rounded `Full;
+
text_center;
+
] [txt "Full Radius"];
];
];
(* Interactive Buttons *)
-
El.section ~at:[At.class' "mb-8"] [
-
El.h2 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Xl));
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V700 ());
-
]); At.class' "mb-6"] [El.txt "Interactive Buttons"];
+
section ~styles:[margin_bottom (rem 2.0)] [
+
h2 ~styles:[
+
font_size `Xl;
+
font_weight `Semibold;
+
text_color (gray 700);
+
margin_bottom (rem 1.5);
+
] [txt "Interactive Buttons"];
-
El.div ~at:[classes_attr (Css.tw [
-
Display.flex;
-
Flexbox.(to_class (wrap `Wrap));
-
Spacing.(to_class (gap `All (Size.rem 1.0)));
-
Flexbox.(to_class (justify `Center));
-
])] [
-
(* Hover color change *)
-
El.button ~at:[classes_attr (Css.tw [
-
Color.bg (Color.make `Blue ~variant:`V500 ());
-
Color.text Color.white;
-
Spacing.(to_class (px (Size.rem 1.5)));
-
Spacing.(to_class (py (Size.rem 0.75)));
-
Effects.rounded_md;
-
Typography.(to_class (font_weight `Medium));
-
Effects.transition `All;
-
Variants.hover (Color.bg (Color.make `Blue ~variant:`V600 ()));
-
])] [El.txt "Hover Color"];
-
-
(* Hover shadow *)
-
El.button ~at:[classes_attr (Css.tw [
-
Color.bg (Color.make `Green ~variant:`V500 ());
-
Color.text Color.white;
-
Spacing.(to_class (px (Size.rem 1.5)));
-
Spacing.(to_class (py (Size.rem 0.75)));
-
Effects.rounded_md;
-
Typography.(to_class (font_weight `Medium));
-
Effects.shadow_md;
-
Effects.transition `All;
-
Variants.hover Effects.shadow_lg;
-
])] [El.txt "Hover Shadow"];
-
-
(* Scale effect *)
-
El.button ~at:[classes_attr (Css.tw [
-
Color.bg (Color.make `Purple ~variant:`V500 ());
-
Color.text Color.white;
-
Spacing.(to_class (px (Size.rem 1.5)));
-
Spacing.(to_class (py (Size.rem 0.75)));
-
Effects.rounded_md;
-
Typography.(to_class (font_weight `Medium));
-
Effects.transition `All;
-
]); At.class' "hover:scale-105 active:scale-95"] [El.txt "Scale Effect"];
-
-
(* Focus ring *)
-
El.button ~at:[classes_attr (Css.tw [
-
Color.bg (Color.make `Red ~variant:`V500 ());
-
Color.text Color.white;
-
Spacing.(to_class (px (Size.rem 1.5)));
-
Spacing.(to_class (py (Size.rem 0.75)));
-
Effects.rounded_md;
-
Typography.(to_class (font_weight `Medium));
-
Effects.transition `All;
-
Variants.focus Effects.shadow_md;
-
])] [El.txt "Focus Ring"];
-
];
-
];
-
-
(* Card Hover Effects *)
-
El.section ~at:[At.class' "mb-8"] [
-
El.h2 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Xl));
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V700 ());
-
]); At.class' "mb-6"] [El.txt "Card Hover Effects"];
-
-
El.div ~at:[classes_attr (Css.tw [
-
Display.grid;
-
Grid.(to_class (template_cols (`Cols 1)));
-
Responsive.(to_class (at_breakpoint `Md (Grid.(to_class (template_cols (`Cols 2))))));
-
Spacing.(to_class (gap `All (Size.rem 1.5)));
-
])] [
-
(* Hover shadow card *)
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg Color.white;
-
Spacing.(to_class (p (Size.rem 1.5)));
-
Effects.rounded_lg;
-
Effects.shadow_md;
-
Effects.transition `All;
-
Variants.hover Effects.shadow_lg;
-
]); At.class' "cursor-pointer"] [
-
El.h3 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Lg));
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V800 ());
-
]); At.class' "mb-2"] [El.txt "Shadow Lift"];
-
El.p ~at:[classes_attr (Css.tw [
-
Color.text (Color.make `Gray ~variant:`V600 ());
-
])] [El.txt "Hover to see the shadow increase. This creates a lifting effect."];
-
];
-
-
(* Scale and shadow card *)
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg Color.white;
-
Spacing.(to_class (p (Size.rem 1.5)));
-
Effects.rounded_lg;
-
Effects.shadow_md;
-
Effects.transition `All;
-
]); At.class' "cursor-pointer hover:scale-105 hover:shadow-xl"] [
-
El.h3 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Lg));
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V800 ());
-
]); At.class' "mb-2"] [El.txt "Scale + Shadow"];
-
El.p ~at:[classes_attr (Css.tw [
-
Color.text (Color.make `Gray ~variant:`V600 ());
-
])] [El.txt "This card both scales up and increases shadow on hover."];
-
];
+
div ~styles:[
+
grid;
+
grid_cols 1;
+
gap (rem 1.0);
+
] [
+
btn_primary [txt "Primary Button with Hover"];
+
btn_secondary [txt "Secondary Button"];
+
btn_outline [txt "Outline Button"];
];
];
(* Border Effects *)
-
El.section [
-
El.h2 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Xl));
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V700 ());
-
]); At.class' "mb-6"] [El.txt "Border Effects"];
+
section [
+
h2 ~styles:[
+
font_size `Xl;
+
font_weight `Semibold;
+
text_color (gray 700);
+
margin_bottom (rem 1.5);
+
] [txt "Border Effects"];
-
El.div ~at:[classes_attr (Css.tw [
-
Display.grid;
-
Grid.(to_class (template_cols (`Cols 1)));
-
Responsive.(to_class (at_breakpoint `Md (Grid.(to_class (template_cols (`Cols 3))))));
-
Spacing.(to_class (gap `All (Size.rem 1.5)));
-
])] [
+
div ~styles:[
+
grid;
+
grid_cols 1;
+
gap (rem 1.0);
+
] [
(* Regular border *)
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg Color.white;
-
Spacing.(to_class (p (Size.rem 1.5)));
-
Effects.border;
-
Color.border (Color.make `Gray ~variant:`V200 ());
-
Effects.rounded_lg;
-
]); At.class' "text-center"] [
-
El.h3 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V700 ());
-
]); At.class' "mb-2"] [El.txt "Regular Border"];
-
El.p ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Sm));
-
Color.text (Color.make `Gray ~variant:`V600 ());
-
])] [El.txt "border border-gray-200"];
+
div ~styles:[
+
bg_color (Tailwind.Color.white);
+
padding (rem 1.5);
+
border;
+
border_color (gray 200);
+
rounded `Lg;
+
text_center;
+
margin_bottom (rem 1.0);
+
] [
+
h3 ~styles:[
+
font_weight `Semibold;
+
text_color (gray 700);
+
margin_bottom (rem 0.5);
+
] [txt "Regular Border"];
+
p ~styles:[
+
font_size `Sm;
+
text_color (gray 600);
+
] [txt "border border-gray-200"];
];
(* Colored border *)
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg Color.white;
-
Spacing.(to_class (p (Size.rem 1.5)));
-
Effects.border;
-
Color.border (Color.make `Blue ~variant:`V300 ());
-
Effects.rounded_lg;
-
]); At.class' "text-center"] [
-
El.h3 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Blue ~variant:`V600 ());
-
]); At.class' "mb-2"] [El.txt "Colored Border"];
-
El.p ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Sm));
-
Color.text (Color.make `Gray ~variant:`V600 ());
-
])] [El.txt "border border-blue-300"];
-
];
-
-
(* Thick border *)
-
El.div ~at:[At.class' "bg-white p-6 border-2 border-purple-300 rounded-lg text-center"] [
-
El.h3 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Purple ~variant:`V600 ());
-
]); At.class' "mb-2"] [El.txt "Thick Border"];
-
El.p ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Sm));
-
Color.text (Color.make `Gray ~variant:`V600 ());
-
])] [El.txt "border-2 border-purple-300"];
+
div ~styles:[
+
bg_color (Tailwind.Color.white);
+
padding (rem 1.5);
+
border;
+
border_color (blue 300);
+
rounded `Lg;
+
text_center;
+
] [
+
h3 ~styles:[
+
font_weight `Semibold;
+
text_color (blue 600);
+
margin_bottom (rem 0.5);
+
] [txt "Colored Border"];
+
p ~styles:[
+
font_size `Sm;
+
text_color (gray 600);
+
] [txt "border border-blue-300"];
];
];
];
];
];
] in
-
html_doc
+
html
let () =
-
(* Output HTML to stdout *)
-
let html_doc = create_effects_demo () in
-
let html_string = El.to_string ~doctype:true html_doc in
-
print_string html_string
+
let html = create_effects_demo () in
+
print_string (El.to_string ~doctype:true html)
-213
examples/gadt_demo.ml
···
-
(* GADT Heterogeneous List Demo - Revolutionary Tailwind interface *)
-
-
open Htmlit
-
open Tailwind_html
-
-
let create_gadt_demo () =
-
let html = El.html [
-
El.head [
-
El.meta ~at:[At.charset "utf-8"] ();
-
El.meta ~at:[At.name "viewport"; At.content "width=device-width, initial-scale=1"] ();
-
El.title [txt "GADT Tailwind Demo"];
-
El.link ~at:[At.rel "stylesheet"; At.href "gadt_demo.css"] ();
-
];
-
-
El.body ~at:[classes_attr [
-
bg_color (gray 50);
-
padding (rem 2.0);
-
]] [
-
(* Hero Section *)
-
h1 ~styles:[
-
text_color (blue 600);
-
font_size `Xl4;
-
font_weight `Bold;
-
text_center;
-
margin_bottom (rem 2.0);
-
] [txt "๐Ÿš€ GADT Heterogeneous Lists for Tailwind"];
-
-
p ~styles:[
-
text_color (gray 700);
-
font_size `Lg;
-
text_center;
-
margin_bottom (rem 3.0);
-
] [txt "Type-safe, conflict-preventing, succinct Tailwind class composition"];
-
-
(* Feature Cards Grid *)
-
div ~styles:[
-
flex;
-
justify_center;
-
margin_bottom (rem 3.0);
-
] [
-
div ~styles:[
-
bg_color (gray 50);
-
rounded `Lg;
-
shadow `Lg;
-
padding (rem 2.0);
-
text_center;
-
] [
-
h2 ~styles:[
-
font_size `Xl2;
-
font_weight `Semibold;
-
text_color (gray 800);
-
margin_bottom (rem 1.0);
-
] [txt "โœจ Magic of GADTs"];
-
-
p ~styles:[
-
text_color (gray 600);
-
margin_bottom (rem 1.5);
-
] [txt "Each property is type-categorized and validated at compile time"];
-
];
-
];
-
-
(* Before/After Comparison *)
-
div ~styles:[
-
bg_color (Tailwind.Color.white);
-
rounded `Lg;
-
shadow `Md;
-
padding (rem 2.0);
-
margin_bottom (rem 3.0);
-
] [
-
h2 ~styles:[
-
font_size `Xl2;
-
font_weight `Bold;
-
text_color (gray 800);
-
margin_bottom (rem 1.5);
-
] [txt "๐Ÿ”„ Before vs After"];
-
-
div ~styles:[
-
flex;
-
justify_between;
-
] [
-
(* Old Way *)
-
div ~styles:[
-
bg_color (red 50);
-
rounded `Md;
-
padding (rem 1.5);
-
margin_right (rem 1.0);
-
] [
-
h3 ~styles:[
-
font_size `Lg;
-
font_weight `Medium;
-
text_color (red 700);
-
margin_bottom (rem 1.0);
-
] [txt "โŒ Old Verbose Way"];
-
-
El.pre ~at:[classes_attr [
-
bg_color (gray 100);
-
padding (rem 1.0);
-
rounded `Sm;
-
font_size `Sm;
-
]] [
-
El.code [txt {|Css.tw [
-
Color.text (Color.make `Blue ~variant:`V600 ());
-
Typography.(to_class (font_size `Xl2));
-
Typography.(to_class (font_weight `Bold));
-
Spacing.(to_class (mb (Size.rem 1.0)));
-
]|}];
-
];
-
];
-
-
(* New Way *)
-
div ~styles:[
-
bg_color (green 50);
-
rounded `Md;
-
padding (rem 1.5);
-
] [
-
h3 ~styles:[
-
font_size `Lg;
-
font_weight `Medium;
-
text_color (green 700);
-
margin_bottom (rem 1.0);
-
] [txt "โœ… New GADT Way"];
-
-
El.pre ~at:[classes_attr [
-
bg_color (gray 100);
-
padding (rem 1.0);
-
rounded `Sm;
-
font_size `Sm;
-
]] [
-
El.code [txt {|[
-
text_color (blue 600);
-
font_size `Xl2;
-
font_weight `Bold;
-
margin_bottom (rem 1.0);
-
]|}];
-
];
-
];
-
];
-
];
-
-
(* Interactive Example *)
-
div ~styles:[
-
bg_color (Tailwind.Color.white);
-
rounded `Lg;
-
shadow `Md;
-
padding (rem 2.0);
-
margin_bottom (rem 2.0);
-
] [
-
h2 ~styles:[
-
font_size `Xl2;
-
font_weight `Bold;
-
text_color (gray 800);
-
margin_bottom (rem 1.5);
-
] [txt "๐ŸŽฏ Type Safety in Action"];
-
-
p ~styles:[
-
text_color (gray 600);
-
margin_bottom (rem 2.0);
-
] [txt "Each property category can only appear once, preventing conflicts:"];
-
-
(* Sample buttons with different styles *)
-
div ~styles:[
-
flex;
-
justify_between;
-
margin_bottom (rem 2.0);
-
] [
-
button ~styles:[
-
bg_color (blue 600);
-
text_color (Tailwind.Color.white);
-
padding (rem 1.0);
-
rounded `Md;
-
font_weight `Medium;
-
] [txt "Primary Button"];
-
-
button ~styles:[
-
bg_color (green 600);
-
text_color (Tailwind.Color.white);
-
padding (rem 1.0);
-
rounded `Md;
-
font_weight `Medium;
-
] [txt "Success Button"];
-
-
button ~styles:[
-
bg_color (red 600);
-
text_color (Tailwind.Color.white);
-
padding (rem 1.0);
-
rounded `Md;
-
font_weight `Medium;
-
] [txt "Danger Button"];
-
];
-
-
p ~styles:[
-
text_color (gray 500);
-
font_size `Sm;
-
] [txt "Try adding two text_color entries - the compiler will prevent conflicts!"];
-
];
-
-
(* Footer *)
-
div ~styles:[
-
text_center;
-
padding_y (rem 2.0);
-
] [
-
p ~styles:[
-
text_color (gray 500);
-
font_size `Sm;
-
] [txt "๐Ÿค– Generated with revolutionary GADT-based Tailwind combinators"];
-
];
-
];
-
] in
-
html
-
-
let () =
-
let html = create_gadt_demo () in
-
print_string (El.to_string ~doctype:true html)
+145 -156
examples/index_html_generator.ml
···
(* Generate index.html page linking to all examples *)
open Htmlit
-
open Tailwind
-
-
let classes_attr tailwind_classes =
-
At.class' (Tailwind.to_string tailwind_classes)
+
open Tailwind_html
let examples = [
("hello_tailwind_01.html", "01. Hello Tailwind",
-
"Your first Tailwind OCaml program. Learn the basics of creating and using type-safe Tailwind classes.",
-
["Basic concepts"; "Type safety"; "Class composition"]);
-
+
"Your first Tailwind OCaml program with GADT interface",
+
["Basic concepts"; "Type safety"; "GADT syntax"]);
+
("colors_and_typography_02.html", "02. Colors and Typography",
-
"Explore the comprehensive color system and typography utilities with compile-time validation.",
-
["Color variants"; "Typography scale"; "Font weights"]);
-
+
"Type-safe colors and typography with compile-time validation",
+
["Color variants"; "Typography scale"; "Grid layouts"]);
+
("layout_and_spacing_03.html", "03. Layout and Spacing",
-
"Master the box model, flexbox layouts, and spacing utilities for building structured interfaces.",
-
["Box model"; "Flexbox"; "Spacing system"]);
-
+
"Master CSS Grid, flexbox layouts and spacing with GADT",
+
["CSS Grid"; "Flexbox"; "Gap utilities"; "Spacing system"]);
+
("responsive_design_04.html", "04. Responsive Design",
-
"Learn responsive design patterns with breakpoints and mobile-first utilities.",
-
["Breakpoints"; "Mobile-first"; "Responsive utilities"]);
-
+
"Adaptive layouts using GADT interface",
+
["Mobile-first"; "CSS Grid"; "Responsive cards"]);
+
("effects_and_variants_05.html", "05. Effects and Variants",
-
"Add visual effects and interactive states with shadows, borders, and hover variants.",
-
["Visual effects"; "Interactive states"; "Hover variants"]);
-
+
"Visual effects with shadows, borders, and rounded corners",
+
["Shadow effects"; "Grid layouts"; "Interactive buttons"]);
+
("patterns_and_components_06.html", "06. Patterns and Components",
-
"Build reusable layout patterns and component compositions for consistent design.",
-
["Layout patterns"; "Component composition"; "Reusable utilities"]);
-
+
"Reusable component patterns with GADT",
+
["Card patterns"; "Button components"; "Form patterns"]);
+
("comprehensive_showcase_07.html", "07. Comprehensive Showcase",
-
"Complete application demo showcasing all library features in a real-world context.",
-
["Complete application"; "All features"; "Best practices"]);
+
"Full application demo with complete UI",
+
["Header/Footer"; "Hero section"; "Feature grids"]);
+
+
("button_demo.html", "Button Demo",
+
"Showcase of all button variants and sizes",
+
["Primary buttons"; "Secondary buttons"; "Outline buttons"]);
]
-
let create_index_page () =
-
let page_classes = Css.tw [
-
Layout.(to_class (min_height Size.screen));
-
Color.bg (Color.make `Gray ~variant:`V50 ());
-
] in
-
-
let container_classes = Css.tw [
-
Spacing.(to_class (mx `Auto));
-
Spacing.(to_class (p (Size.rem 2.0)));
-
] in
-
-
let header_classes = Css.tw [
-
Typography.(to_class (font_size `Xl4));
-
Typography.(to_class (font_weight `Bold));
-
Color.text (Color.make `Gray ~variant:`V900 ());
-
Spacing.(to_class (mb (Size.rem 2.0)));
-
Typography.(to_class (text_align `Center));
-
] in
-
-
let subtitle_classes = Css.tw [
-
Typography.(to_class (font_size `Xl));
-
Color.text (Color.make `Gray ~variant:`V600 ());
-
Typography.(to_class (text_align `Center));
-
Spacing.(to_class (mb (Size.rem 3.0)));
-
] in
-
-
let grid_classes = Css.tw [
-
Display.grid;
-
Grid.(to_class (template_cols (`Cols 1)));
-
Responsive.(to_class (at_breakpoint `Md (Grid.(to_class (template_cols (`Cols 2))))));
-
Spacing.(to_class (gap `All (Size.rem 1.5)));
-
Spacing.(to_class (mb (Size.rem 3.0)));
-
] in
-
-
let card_classes = Css.tw [
-
Color.bg Color.white;
-
Effects.rounded_lg;
-
Effects.shadow_sm;
-
Spacing.(to_class (p (Size.rem 1.5)));
-
Effects.border;
-
Color.border (Color.make `Gray ~variant:`V200 ());
-
Effects.transition `All;
-
Variants.hover Effects.shadow_md;
-
Variants.hover (Color.border (Color.make `Blue ~variant:`V300 ()));
-
] in
-
-
let card_title_classes = Css.tw [
-
Typography.(to_class (font_size `Lg));
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V900 ());
-
Spacing.(to_class (mb (Size.rem 0.75)));
-
] in
-
-
let card_description_classes = Css.tw [
-
Color.text (Color.make `Gray ~variant:`V600 ());
-
Spacing.(to_class (mb (Size.rem 1.0)));
-
Typography.(to_class (line_height `Relaxed));
-
] in
-
-
let features_classes = Css.tw [
-
Display.flex;
-
Flexbox.(to_class (wrap `Wrap));
-
Spacing.(to_class (gap `All (Size.rem 0.5)));
-
Spacing.(to_class (mb (Size.rem 1.0)));
-
] in
-
-
let feature_tag_classes = Css.tw [
-
Color.bg (Color.make `Blue ~variant:`V50 ());
-
Color.text (Color.make `Blue ~variant:`V700 ());
-
Typography.(to_class (font_size `Xs));
-
Spacing.(to_class (px (Size.rem 0.5)));
-
Spacing.(to_class (py (Size.rem 0.25)));
-
Effects.rounded_full;
-
] in
-
-
let link_classes = Css.tw [
-
Color.text (Color.make `Blue ~variant:`V600 ());
-
Typography.(to_class (font_weight `Medium));
-
Variants.hover (Color.text (Color.make `Blue ~variant:`V800 ()));
-
Effects.transition `Colors;
-
] in
-
-
let footer_classes = Css.tw [
-
Typography.(to_class (text_align `Center));
-
Spacing.(to_class (mt (Size.rem 3.0)));
-
Color.text (Color.make `Gray ~variant:`V500 ());
-
Typography.(to_class (font_size `Sm));
-
] in
-
-
let html_doc = El.html [
+
let create_index () =
+
let html = El.html [
El.head [
El.meta ~at:[At.charset "utf-8"] ();
El.meta ~at:[At.name "viewport"; At.content "width=device-width, initial-scale=1"] ();
-
El.title [El.txt "Tailwind OCaml Examples"];
-
El.link ~at:[At.rel "stylesheet"; At.href "hello_tailwind_01.css"] (); (* Reuse CSS from first example *)
-
El.style [El.txt {|
-
body { font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
-
a { text-decoration: none; }
-
.example-card { display: block; }
+
El.title [txt "Tailwind OCaml Examples - GADT Interface"];
+
El.style [txt {|
+
body { font-family: system-ui, -apple-system, sans-serif; }
+
.example-card { transition: transform 0.2s, box-shadow 0.2s; }
+
.example-card:hover { transform: translateY(-2px); }
|}];
];
-
El.body ~at:[classes_attr page_classes] [
-
El.div ~at:[classes_attr container_classes] [
-
El.h1 ~at:[classes_attr header_classes] [
-
El.txt "Tailwind OCaml Examples"
+
El.body ~at:[classes_attr [
+
min_height screen;
+
bg_color (gray 50);
+
padding (rem 2.0);
+
]] [
+
container [
+
(* Header *)
+
header ~styles:[
+
text_center;
+
margin_bottom (rem 3.0);
+
] [
+
h1 ~styles:[
+
font_size `Xl3;
+
font_weight `Bold;
+
text_color (gray 800);
+
margin_bottom (rem 1.0);
+
] [txt "๐ŸŽจ Tailwind OCaml Examples"];
+
+
p ~styles:[
+
font_size `Xl;
+
text_color (gray 600);
+
margin_bottom (rem 1.0);
+
] [txt "Type-safe CSS generation with GADT-based interface"];
+
+
p ~styles:[
+
font_size `Base;
+
text_color (gray 500);
+
] [txt "Explore examples showcasing the power of compile-time guaranteed styling"];
];
-
El.p ~at:[classes_attr subtitle_classes] [
-
El.txt "A progressive tutorial series demonstrating type-safe Tailwind CSS generation in OCaml"
-
];
-
-
El.div ~at:[classes_attr grid_classes] (
-
List.map (fun (href, title, description, features) ->
-
El.a ~at:[At.href href; At.class' "example-card"] [
-
El.div ~at:[classes_attr card_classes] [
-
El.h2 ~at:[classes_attr card_title_classes] [El.txt title];
-
El.p ~at:[classes_attr card_description_classes] [El.txt description];
-
El.div ~at:[classes_attr features_classes] (
-
List.map (fun feature ->
-
El.span ~at:[classes_attr feature_tag_classes] [El.txt feature]
-
) features
-
);
-
El.div ~at:[classes_attr link_classes] [
-
El.txt "View Example โ†’"
-
];
+
(* Examples Grid *)
+
div ~styles:[
+
grid;
+
grid_cols 1;
+
gap (rem 1.5);
+
] (List.map (fun (file, title, desc, features) ->
+
El.a ~at:[At.href file; At.style "text-decoration: none; color: inherit;"] [
+
div ~styles:[
+
bg_color (Tailwind.Color.white);
+
rounded `Lg;
+
shadow `Md;
+
padding (rem 2.0);
+
margin_bottom (rem 1.5);
+
border;
+
border_color (gray 200);
+
transition;
+
] [
+
(* Title and description *)
+
div ~styles:[margin_bottom (rem 1.0)] [
+
h2 ~styles:[
+
font_size `Xl;
+
font_weight `Semibold;
+
text_color (gray 800);
+
margin_bottom (rem 0.5);
+
] [txt title];
+
+
p ~styles:[
+
text_color (gray 600);
+
margin_bottom (rem 1.0);
+
] [txt desc];
];
-
]
-
) examples
-
);
+
+
(* Feature tags *)
+
div ~styles:[
+
grid;
+
grid_cols 3;
+
gap_x (rem 0.5);
+
gap_y (rem 0.5);
+
] (List.map (fun feature ->
+
span ~styles:[
+
bg_color (blue 100);
+
text_color (blue 700);
+
padding_x (rem 0.75);
+
padding_y (rem 0.25);
+
rounded `Full;
+
font_size `Sm;
+
font_weight `Medium;
+
margin_right (rem 0.5);
+
margin_bottom (rem 0.5);
+
] [txt feature]
+
) features);
+
+
(* View link *)
+
div ~styles:[
+
margin_top (rem 1.0);
+
text_right;
+
] [
+
span ~styles:[
+
text_color (blue 600);
+
font_weight `Medium;
+
] [txt "View Example โ†’"];
+
];
+
];
+
]
+
) examples);
-
El.div ~at:[classes_attr footer_classes] [
-
El.p [
-
El.txt "Built with ";
-
El.a ~at:[At.href "https://github.com/dbuenzli/htmlit"; classes_attr link_classes] [El.txt "Htmlit"];
-
El.txt " and type-safe Tailwind CSS generation"
-
];
+
(* Footer *)
+
footer ~styles:[
+
text_center;
+
margin_top (rem 3.0);
+
padding_y (rem 2.0);
+
border;
+
border_color (gray 200);
+
] [
+
p ~styles:[
+
text_color (gray 500);
+
font_size `Sm;
+
margin_bottom (rem 0.5);
+
] [txt "Built with OCaml, Tailwind CSS, and GADT-based type safety"];
+
+
p ~styles:[
+
text_color (gray 400);
+
font_size `Xs;
+
] [txt "ยฉ 2024 Tailwind OCaml - Compile-time guaranteed styling"];
];
];
];
] in
-
html_doc
+
html
let () =
-
(* Output HTML to stdout *)
-
let html_doc = create_index_page () in
-
let html_string = El.to_string ~doctype:true html_doc in
-
print_string html_string
+
let html = create_index () in
+
print_string (El.to_string ~doctype:true html)
+259 -211
examples/layout_and_spacing_03.ml
···
-
(* Example 03: Layout and Spacing - Mastering Box Model and Flexbox *)
+
(* Example 03: Layout and Spacing - GADT flexbox and spacing demo *)
open Htmlit
-
open Tailwind
-
-
let classes_attr tailwind_classes =
-
At.class' (Tailwind.to_string tailwind_classes)
+
open Tailwind_html
let create_layout_demo () =
-
(* Create comprehensive layout demonstration *)
-
let html_doc = El.html [
+
let html = El.html [
El.head [
El.meta ~at:[At.charset "utf-8"] ();
El.meta ~at:[At.name "viewport"; At.content "width=device-width, initial-scale=1"] ();
-
El.title [El.txt "Layout and Spacing"];
+
El.title [txt "Layout and Spacing"];
El.link ~at:[At.rel "stylesheet"; At.href "layout_and_spacing_03.css"] ();
];
-
El.body ~at:[At.class' "min-h-screen bg-gray-50 p-8"] [
-
El.div ~at:[At.class' "max-w-6xl mx-auto"] [
-
El.h1 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Xl2));
-
Typography.(to_class (font_weight `Bold));
-
Color.text (Color.make `Gray ~variant:`V800 ());
-
]); At.class' "mb-8 text-center"] [El.txt "Layout and Spacing Demo"];
+
El.body ~at:[classes_attr [
+
min_height screen;
+
bg_color (gray 50);
+
padding (rem 2.0);
+
]] [
+
container [
+
h1 ~styles:[
+
font_size `Xl2;
+
font_weight `Bold;
+
text_color (gray 800);
+
text_center;
+
margin_bottom (rem 2.0);
+
] [txt "Layout and Spacing Demo"];
-
El.p ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Lg));
-
Color.text (Color.make `Gray ~variant:`V600 ());
-
]); At.class' "text-center mb-12"] [
-
El.txt "Master the box model, flexbox, and CSS grid with type-safe utilities."
-
];
+
p ~styles:[
+
font_size `Lg;
+
text_color (gray 600);
+
text_center;
+
margin_bottom (rem 3.0);
+
] [txt "Master flexbox layouts and spacing with GADT interface"];
(* Flexbox Examples *)
-
El.section ~at:[At.class' "mb-12"] [
-
El.h2 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Xl));
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V700 ());
-
]); At.class' "mb-8"] [El.txt "Flexbox Layouts"];
+
section ~styles:[margin_bottom (rem 3.0)] [
+
h2 ~styles:[
+
font_size `Xl;
+
font_weight `Semibold;
+
text_color (gray 700);
+
margin_bottom (rem 2.0);
+
] [txt "Flexbox Layouts"];
(* Centered content *)
-
El.div ~at:[At.class' "mb-8"] [
-
El.h3 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Lg));
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V700 ());
-
]); At.class' "mb-4"] [El.txt "Centered Content"];
+
card [
+
h3 ~styles:[
+
font_size `Lg;
+
font_weight `Semibold;
+
text_color (gray 700);
+
margin_bottom (rem 1.0);
+
] [txt "Centered Content"];
-
El.div ~at:[classes_attr (Css.tw [
-
Display.flex;
-
Flexbox.(to_class (justify `Center));
-
Flexbox.(to_class (align_items `Center));
-
Color.bg (Color.make `Blue ~variant:`V100 ());
-
Layout.(to_class (height (Size.rem 8.0)));
-
Effects.rounded_lg;
-
])] [
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg Color.white;
-
Spacing.(to_class (p (Size.rem 1.5)));
-
Effects.rounded_md;
-
Effects.shadow_sm;
-
])] [
-
El.txt "Perfectly Centered Content"
+
div ~styles:[
+
flex;
+
justify_center;
+
items_center;
+
bg_color (blue 100);
+
height (rem 8.0);
+
rounded `Lg;
+
margin_bottom (rem 1.5);
+
] [
+
div ~styles:[
+
bg_color (Tailwind.Color.white);
+
padding (rem 1.5);
+
rounded `Md;
+
shadow `Sm;
+
] [
+
txt "Perfectly Centered Content"
];
];
];
(* Space between items *)
-
El.div ~at:[At.class' "mb-8"] [
-
El.h3 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Lg));
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V700 ());
-
]); At.class' "mb-4"] [El.txt "Space Between"];
+
card [
+
h3 ~styles:[
+
font_size `Lg;
+
font_weight `Semibold;
+
text_color (gray 700);
+
margin_bottom (rem 1.0);
+
] [txt "Space Between"];
-
El.div ~at:[classes_attr (Css.tw [
-
Display.flex;
-
Flexbox.(to_class (justify `Between));
-
Flexbox.(to_class (align_items `Center));
-
Color.bg (Color.make `Green ~variant:`V100 ());
-
Spacing.(to_class (p (Size.rem 1.5)));
-
Effects.rounded_lg;
-
])] [
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg Color.white;
-
Spacing.(to_class (p (Size.rem 1.0)));
-
Effects.rounded_md;
-
])] [El.txt "Left"];
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg Color.white;
-
Spacing.(to_class (p (Size.rem 1.0)));
-
Effects.rounded_md;
-
])] [El.txt "Center"];
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg Color.white;
-
Spacing.(to_class (p (Size.rem 1.0)));
-
Effects.rounded_md;
-
])] [El.txt "Right"];
-
];
-
];
-
-
(* Flex direction example *)
-
El.div [
-
El.h3 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Lg));
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V700 ());
-
]); At.class' "mb-4"] [El.txt "Flex Direction Column"];
-
-
El.div ~at:[classes_attr (Css.tw [
-
Display.flex;
-
Flexbox.(to_class (direction `Col));
-
Spacing.(to_class (gap `All (Size.rem 1.0)));
-
Color.bg (Color.make `Purple ~variant:`V100 ());
-
Spacing.(to_class (p (Size.rem 1.5)));
-
Effects.rounded_lg;
-
])] [
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg Color.white;
-
Spacing.(to_class (p (Size.rem 1.0)));
-
Effects.rounded_md;
-
]); At.class' "text-center"] [El.txt "Item 1"];
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg Color.white;
-
Spacing.(to_class (p (Size.rem 1.0)));
-
Effects.rounded_md;
-
]); At.class' "text-center"] [El.txt "Item 2"];
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg Color.white;
-
Spacing.(to_class (p (Size.rem 1.0)));
-
Effects.rounded_md;
-
]); At.class' "text-center"] [El.txt "Item 3"];
+
div ~styles:[
+
flex;
+
justify_between;
+
items_center;
+
bg_color (green 100);
+
padding (rem 1.5);
+
rounded `Lg;
+
] [
+
div ~styles:[
+
bg_color (Tailwind.Color.white);
+
padding (rem 1.0);
+
rounded `Md;
+
] [txt "Left"];
+
div ~styles:[
+
bg_color (Tailwind.Color.white);
+
padding (rem 1.0);
+
rounded `Md;
+
] [txt "Center"];
+
div ~styles:[
+
bg_color (Tailwind.Color.white);
+
padding (rem 1.0);
+
rounded `Md;
+
] [txt "Right"];
];
];
];
-
(* Grid Examples *)
-
El.section ~at:[At.class' "mb-12"] [
-
El.h2 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Xl));
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V700 ());
-
]); At.class' "mb-8"] [El.txt "CSS Grid Layouts"];
+
(* Grid Layout Examples *)
+
section ~styles:[margin_bottom (rem 3.0)] [
+
h2 ~styles:[
+
font_size `Xl;
+
font_weight `Semibold;
+
text_color (gray 700);
+
margin_bottom (rem 2.0);
+
] [txt "CSS Grid Layouts"];
-
(* 2-column grid *)
-
El.div ~at:[At.class' "mb-8"] [
-
El.h3 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Lg));
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V700 ());
-
]); At.class' "mb-4"] [El.txt "Two Column Grid"];
+
(* 3-column grid *)
+
card [
+
h3 ~styles:[
+
font_size `Lg;
+
font_weight `Semibold;
+
text_color (gray 700);
+
margin_bottom (rem 1.0);
+
] [txt "Three Column Grid"];
-
El.div ~at:[classes_attr (Css.tw [
-
Display.grid;
-
Grid.(to_class (template_cols (`Cols 2)));
-
Spacing.(to_class (gap `All (Size.rem 1.5)));
-
])] (List.init 4 (fun i ->
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg (Color.make `Red ~variant:`V100 ());
-
Spacing.(to_class (p (Size.rem 1.5)));
-
Effects.rounded_lg;
-
]); At.class' "text-center"] [
-
El.txt (Printf.sprintf "Grid Item %d" (i + 1))
-
]
-
));
+
div ~styles:[
+
grid;
+
grid_cols 3;
+
gap (rem 1.0);
+
] [
+
div ~styles:[
+
bg_color (blue 100);
+
padding (rem 1.0);
+
rounded `Md;
+
text_center;
+
] [txt "Item 1"];
+
div ~styles:[
+
bg_color (green 100);
+
padding (rem 1.0);
+
rounded `Md;
+
text_center;
+
] [txt "Item 2"];
+
div ~styles:[
+
bg_color (purple 100);
+
padding (rem 1.0);
+
rounded `Md;
+
text_center;
+
] [txt "Item 3"];
+
div ~styles:[
+
bg_color (red 100);
+
padding (rem 1.0);
+
rounded `Md;
+
text_center;
+
] [txt "Item 4"];
+
div ~styles:[
+
bg_color (yellow 100);
+
padding (rem 1.0);
+
rounded `Md;
+
text_center;
+
] [txt "Item 5"];
+
div ~styles:[
+
bg_color (indigo 100);
+
padding (rem 1.0);
+
rounded `Md;
+
text_center;
+
] [txt "Item 6"];
+
];
];
-
(* 3-column grid *)
-
El.div ~at:[At.class' "mb-8"] [
-
El.h3 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Lg));
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V700 ());
-
]); At.class' "mb-4"] [El.txt "Three Column Grid"];
+
(* Grid gap examples *)
+
card [
+
h3 ~styles:[
+
font_size `Lg;
+
font_weight `Semibold;
+
text_color (gray 700);
+
margin_bottom (rem 1.0);
+
] [txt "Grid Gap Variations"];
-
El.div ~at:[classes_attr (Css.tw [
-
Display.grid;
-
Grid.(to_class (template_cols (`Cols 3)));
-
Spacing.(to_class (gap `All (Size.rem 1.5)));
-
])] (List.init 6 (fun i ->
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg (Color.make `Yellow ~variant:`V100 ());
-
Spacing.(to_class (p (Size.rem 1.5)));
-
Effects.rounded_lg;
-
]); At.class' "text-center"] [
-
El.txt (Printf.sprintf "Item %d" (i + 1))
-
]
-
));
+
div ~styles:[margin_bottom (rem 1.5)] [
+
h4 ~styles:[
+
font_size `Base;
+
font_weight `Medium;
+
text_color (gray 600);
+
margin_bottom (rem 0.5);
+
] [txt "Small Gap"];
+
div ~styles:[
+
grid;
+
grid_cols 4;
+
gap (rem 0.5);
+
] (List.init 4 (fun i ->
+
div ~styles:[
+
bg_color (blue 200);
+
padding (rem 0.5);
+
rounded `Sm;
+
text_center;
+
] [txt (string_of_int (i + 1))]
+
));
+
];
+
+
div ~styles:[margin_bottom (rem 1.5)] [
+
h4 ~styles:[
+
font_size `Base;
+
font_weight `Medium;
+
text_color (gray 600);
+
margin_bottom (rem 0.5);
+
] [txt "Large Gap"];
+
div ~styles:[
+
grid;
+
grid_cols 3;
+
gap (rem 2.0);
+
] (List.init 3 (fun i ->
+
div ~styles:[
+
bg_color (green 200);
+
padding (rem 1.0);
+
rounded `Md;
+
text_center;
+
] [txt (Printf.sprintf "Item %d" (i + 1))]
+
));
+
];
+
+
div [
+
h4 ~styles:[
+
font_size `Base;
+
font_weight `Medium;
+
text_color (gray 600);
+
margin_bottom (rem 0.5);
+
] [txt "Asymmetric Gap"];
+
div ~styles:[
+
grid;
+
grid_cols 2;
+
gap_x (rem 2.0);
+
gap_y (rem 0.5);
+
] (List.init 4 (fun i ->
+
div ~styles:[
+
bg_color (purple 200);
+
padding (rem 0.75);
+
rounded `Md;
+
text_center;
+
] [txt (Printf.sprintf "Box %d" (i + 1))]
+
));
+
];
];
];
(* Spacing Examples *)
-
El.section [
-
El.h2 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Xl));
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V700 ());
-
]); At.class' "mb-8"] [El.txt "Spacing System"];
+
section [
+
h2 ~styles:[
+
font_size `Xl;
+
font_weight `Semibold;
+
text_color (gray 700);
+
margin_bottom (rem 2.0);
+
] [txt "Spacing System"];
-
El.div ~at:[classes_attr (Css.tw [
-
Display.grid;
-
Grid.(to_class (template_cols (`Cols 1)));
-
Responsive.(to_class (at_breakpoint `Md (Grid.(to_class (template_cols (`Cols 2))))));
-
Spacing.(to_class (gap `All (Size.rem 2.0)));
-
])] [
+
(* Using grid for spacing examples *)
+
div ~styles:[
+
grid;
+
grid_cols 2;
+
gap (rem 1.5);
+
] [
(* Padding example *)
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg (Color.make `Indigo ~variant:`V100 ());
-
Spacing.(to_class (p (Size.rem 1.5)));
-
Effects.rounded_lg;
-
])] [
-
El.h4 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Base));
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V700 ());
-
]); At.class' "mb-3"] [El.txt "Padding Example"];
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg Color.white;
-
Spacing.(to_class (p (Size.rem 2.0)));
-
Effects.rounded_md;
-
Effects.border;
-
Color.border (Color.make `Gray ~variant:`V200 ());
-
])] [
-
El.txt "This content has p-8 (2rem padding)"
+
card [
+
h4 ~styles:[
+
font_size `Base;
+
font_weight `Semibold;
+
text_color (gray 700);
+
margin_bottom (rem 0.75);
+
] [txt "Padding Example"];
+
div ~styles:[
+
bg_color (Tailwind.Color.white);
+
padding (rem 2.0);
+
rounded `Md;
+
border;
+
border_color (gray 200);
+
] [
+
txt "This content has padding (2rem)"
];
];
(* Margin example *)
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg (Color.make `Cyan ~variant:`V100 ());
-
Spacing.(to_class (p (Size.rem 1.5)));
-
Effects.rounded_lg;
-
])] [
-
El.h4 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Base));
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V700 ());
-
]); At.class' "mb-3"] [El.txt "Margin Example"];
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg Color.white;
-
Spacing.(to_class (p (Size.rem 1.0)));
-
Spacing.(to_class (m (Size.rem 1.5)));
-
Effects.rounded_md;
-
Effects.border;
-
Color.border (Color.make `Gray ~variant:`V200 ());
-
])] [
-
El.txt "This box has m-6 (1.5rem margin) from its container"
+
card [
+
h4 ~styles:[
+
font_size `Base;
+
font_weight `Semibold;
+
text_color (gray 700);
+
margin_bottom (rem 0.75);
+
] [txt "Margin Example"];
+
div ~styles:[
+
bg_color (Tailwind.Color.white);
+
padding (rem 1.0);
+
margin (rem 1.5);
+
rounded `Md;
+
border;
+
border_color (gray 200);
+
] [
+
txt "This box has margin (1.5rem) from its container"
];
];
];
···
];
];
] in
-
html_doc
+
html
let () =
-
(* Output HTML to stdout *)
-
let html_doc = create_layout_demo () in
-
print_string (El.to_string ~doctype:true html_doc)
+
let html = create_layout_demo () in
+
print_string (El.to_string ~doctype:true html)
+165 -135
examples/patterns_and_components_06.ml
···
-
(* Example 06: Patterns and Components - Reusable Layout Patterns *)
+
(* Example 06: Patterns and Components - Reusable components with GADT *)
open Htmlit
-
open Tailwind
-
-
let classes_attr tailwind_classes =
-
At.class' (Tailwind.to_string tailwind_classes)
+
open Tailwind_html
let create_patterns_demo () =
-
(* Create comprehensive patterns demonstration *)
-
let html_doc = El.html [
+
let html = El.html [
El.head [
El.meta ~at:[At.charset "utf-8"] ();
El.meta ~at:[At.name "viewport"; At.content "width=device-width, initial-scale=1"] ();
-
El.title [El.txt "Patterns and Components"];
+
El.title [txt "Patterns and Components"];
El.link ~at:[At.rel "stylesheet"; At.href "patterns_and_components_06.css"] ();
];
-
El.body ~at:[At.class' "min-h-screen bg-gray-50 p-8"] [
-
El.div ~at:[At.class' "max-w-6xl mx-auto"] [
-
El.h1 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Xl2));
-
Typography.(to_class (font_weight `Bold));
-
Color.text (Color.make `Gray ~variant:`V800 ());
-
]); At.class' "mb-8 text-center"] [El.txt "Patterns and Components Demo"];
+
El.body ~at:[classes_attr [
+
min_height screen;
+
bg_color (gray 50);
+
padding (rem 2.0);
+
]] [
+
container [
+
h1 ~styles:[
+
font_size `Xl2;
+
font_weight `Bold;
+
text_color (gray 800);
+
text_center;
+
margin_bottom (rem 2.0);
+
] [txt "Patterns and Components Demo"];
(* Container Pattern *)
-
El.section ~at:[At.class' "mb-12"] [
-
El.h2 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Xl));
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V700 ());
-
]); At.class' "mb-6"] [El.txt "Container Pattern"];
+
section ~styles:[margin_bottom (rem 3.0)] [
+
h2 ~styles:[
+
font_size `Xl;
+
font_weight `Semibold;
+
text_color (gray 700);
+
margin_bottom (rem 1.5);
+
] [txt "Container Pattern"];
-
El.div ~at:[classes_attr (Css.tw [Patterns.container ()]); At.class' "bg-white rounded-lg shadow-sm p-6"] [
-
El.p ~at:[classes_attr (Css.tw [
-
Color.text (Color.make `Gray ~variant:`V600 ());
-
])] [El.txt "This content is inside a container pattern that centers content and provides responsive padding."];
+
card [
+
p ~styles:[text_color (gray 600)] [
+
txt "This content is inside a container pattern that centers content and provides responsive padding."
+
];
];
];
(* Card Pattern *)
-
El.section ~at:[At.class' "mb-12"] [
-
El.h2 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Xl));
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V700 ());
-
]); At.class' "mb-6"] [El.txt "Card Pattern"];
+
section ~styles:[margin_bottom (rem 3.0)] [
+
h2 ~styles:[
+
font_size `Xl;
+
font_weight `Semibold;
+
text_color (gray 700);
+
margin_bottom (rem 1.5);
+
] [txt "Card Patterns"];
-
El.div ~at:[At.class' "grid grid-cols-1 md:grid-cols-3 gap-6"] [
-
El.div ~at:[classes_attr (Css.tw [Patterns.card]); At.class' "p-6"] [
-
El.h3 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Lg));
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V800 ());
-
]); At.class' "mb-2"] [El.txt "Card One"];
-
El.p ~at:[classes_attr (Css.tw [
-
Color.text (Color.make `Gray ~variant:`V600 ());
-
])] [El.txt "This is a card using the built-in card pattern."];
+
div ~styles:[flex; flex_col] [
+
card [
+
h3 ~styles:[
+
font_size `Lg;
+
font_weight `Semibold;
+
text_color (gray 800);
+
margin_bottom (rem 1.0);
+
] [txt "Basic Card"];
+
p ~styles:[text_color (gray 600)] [
+
txt "A simple card with padding and shadow."
+
];
];
-
El.div ~at:[classes_attr (Css.tw [Patterns.card]); At.class' "p-6"] [
-
El.h3 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Lg));
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V800 ());
-
]); At.class' "mb-2"] [El.txt "Card Two"];
-
El.p ~at:[classes_attr (Css.tw [
-
Color.text (Color.make `Gray ~variant:`V600 ());
-
])] [El.txt "Another card with the same styling pattern applied."];
-
];
-
-
El.div ~at:[classes_attr (Css.tw [Patterns.card]); At.class' "p-6"] [
-
El.h3 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Lg));
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V800 ());
-
]); At.class' "mb-2"] [El.txt "Card Three"];
-
El.p ~at:[classes_attr (Css.tw [
-
Color.text (Color.make `Gray ~variant:`V600 ());
-
])] [El.txt "A third card demonstrating consistent styling."];
+
card ~elevated:true [
+
h3 ~styles:[
+
font_size `Lg;
+
font_weight `Semibold;
+
text_color (gray 800);
+
margin_bottom (rem 1.0);
+
] [txt "Elevated Card"];
+
p ~styles:[text_color (gray 600)] [
+
txt "This card has a stronger shadow for emphasis."
+
];
];
];
];
-
(* Flex Center Pattern *)
-
El.section ~at:[At.class' "mb-12"] [
-
El.h2 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Xl));
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V700 ());
-
]); At.class' "mb-6"] [El.txt "Flex Center Pattern"];
+
(* Button Components *)
+
section ~styles:[margin_bottom (rem 3.0)] [
+
h2 ~styles:[
+
font_size `Xl;
+
font_weight `Semibold;
+
text_color (gray 700);
+
margin_bottom (rem 1.5);
+
] [txt "Button Components"];
-
El.div ~at:[classes_attr (Css.tw [Patterns.flex_center]); At.class' "bg-blue-50 rounded-lg h-32"] [
-
El.p ~at:[classes_attr (Css.tw [
-
Color.text (Color.make `Blue ~variant:`V600 ());
-
Typography.(to_class (font_weight `Medium));
-
])] [El.txt "This content is perfectly centered using flex_center pattern"];
+
card [
+
h3 ~styles:[
+
font_size `Lg;
+
font_weight `Semibold;
+
text_color (gray 800);
+
margin_bottom (rem 1.5);
+
] [txt "Button Variants"];
+
+
div ~styles:[flex; flex_col] [
+
div ~styles:[margin_bottom (rem 1.0)] [
+
btn_primary ~size:`Sm [txt "Small Primary"];
+
btn_primary [txt "Default Primary"];
+
btn_primary ~size:`Lg [txt "Large Primary"];
+
];
+
+
div ~styles:[margin_bottom (rem 1.0)] [
+
btn_secondary ~size:`Sm [txt "Small Secondary"];
+
btn_secondary [txt "Default Secondary"];
+
btn_secondary ~size:`Lg [txt "Large Secondary"];
+
];
+
+
div [
+
btn_outline ~size:`Sm [txt "Small Outline"];
+
btn_outline [txt "Default Outline"];
+
btn_outline ~size:`Lg [txt "Large Outline"];
+
];
+
];
];
];
-
(* Stack Pattern *)
-
El.section ~at:[At.class' "mb-12"] [
-
El.h2 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Xl));
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V700 ());
-
]); At.class' "mb-6"] [El.txt "Stack Pattern"];
+
(* List Pattern *)
+
section ~styles:[margin_bottom (rem 3.0)] [
+
h2 ~styles:[
+
font_size `Xl;
+
font_weight `Semibold;
+
text_color (gray 700);
+
margin_bottom (rem 1.5);
+
] [txt "List Patterns"];
-
El.div ~at:[classes_attr (Css.tw [Patterns.stack ~gap:(Size.rem 1.0) ()]); At.class' "bg-white rounded-lg shadow-sm p-6"] [
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg (Color.make `Green ~variant:`V50 ());
-
Spacing.(to_class (p (Size.rem 1.0)));
-
Effects.rounded_md;
-
])] [El.txt "Stack Item 1"];
+
card [
+
h3 ~styles:[
+
font_size `Lg;
+
font_weight `Semibold;
+
text_color (gray 800);
+
margin_bottom (rem 1.0);
+
] [txt "Feature List"];
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg (Color.make `Blue ~variant:`V50 ());
-
Spacing.(to_class (p (Size.rem 1.0)));
-
Effects.rounded_md;
-
])] [El.txt "Stack Item 2"];
-
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg (Color.make `Purple ~variant:`V50 ());
-
Spacing.(to_class (p (Size.rem 1.0)));
-
Effects.rounded_md;
-
])] [El.txt "Stack Item 3"];
+
ul ~styles:[text_color (gray 600)] [
+
li ~styles:[margin_bottom (rem 0.5)] [txt "โœ“ Type-safe styling"];
+
li ~styles:[margin_bottom (rem 0.5)] [txt "โœ“ Conflict prevention"];
+
li ~styles:[margin_bottom (rem 0.5)] [txt "โœ“ Succinct syntax"];
+
li [txt "โœ“ Reusable components"];
+
];
];
];
-
(* Inline Stack Pattern *)
-
El.section [
-
El.h2 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Xl));
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V700 ());
-
]); At.class' "mb-6"] [El.txt "Inline Stack Pattern"];
+
(* Form Pattern *)
+
section [
+
h2 ~styles:[
+
font_size `Xl;
+
font_weight `Semibold;
+
text_color (gray 700);
+
margin_bottom (rem 1.5);
+
] [txt "Form Patterns"];
-
El.div ~at:[classes_attr (Css.tw [Patterns.inline_stack ~gap:(Size.rem 1.0) ()]); At.class' "bg-white rounded-lg shadow-sm p-6"] [
-
El.span ~at:[classes_attr (Css.tw [
-
Color.bg (Color.make `Red ~variant:`V50 ());
-
Color.text (Color.make `Red ~variant:`V600 ());
-
Spacing.(to_class (px (Size.rem 0.75)));
-
Spacing.(to_class (py (Size.rem 0.5)));
-
Effects.rounded_full;
-
Typography.(to_class (font_size `Sm));
-
])] [El.txt "Tag 1"];
+
card [
+
h3 ~styles:[
+
font_size `Lg;
+
font_weight `Semibold;
+
text_color (gray 800);
+
margin_bottom (rem 1.5);
+
] [txt "Simple Form"];
-
El.span ~at:[classes_attr (Css.tw [
-
Color.bg (Color.make `Yellow ~variant:`V50 ());
-
Color.text (Color.make `Yellow ~variant:`V600 ());
-
Spacing.(to_class (px (Size.rem 0.75)));
-
Spacing.(to_class (py (Size.rem 0.5)));
-
Effects.rounded_full;
-
Typography.(to_class (font_size `Sm));
-
])] [El.txt "Tag 2"];
-
-
El.span ~at:[classes_attr (Css.tw [
-
Color.bg (Color.make `Indigo ~variant:`V50 ());
-
Color.text (Color.make `Indigo ~variant:`V600 ());
-
Spacing.(to_class (px (Size.rem 0.75)));
-
Spacing.(to_class (py (Size.rem 0.5)));
-
Effects.rounded_full;
-
Typography.(to_class (font_size `Sm));
-
])] [El.txt "Tag 3"];
+
div ~styles:[flex; flex_col] [
+
div ~styles:[margin_bottom (rem 1.5)] [
+
El.label ~at:[At.for' "name"; classes_attr [
+
block;
+
font_weight `Medium;
+
text_color (gray 700);
+
margin_bottom (rem 0.5);
+
]] [txt "Name"];
+
El.input ~at:[At.type' "text"; At.id "name"; classes_attr [
+
width full;
+
padding (rem 0.5);
+
border;
+
border_color (gray 300);
+
rounded `Md;
+
]] ();
+
];
+
+
div ~styles:[margin_bottom (rem 1.5)] [
+
El.label ~at:[At.for' "email"; classes_attr [
+
block;
+
font_weight `Medium;
+
text_color (gray 700);
+
margin_bottom (rem 0.5);
+
]] [txt "Email"];
+
El.input ~at:[At.type' "email"; At.id "email"; classes_attr [
+
width full;
+
padding (rem 0.5);
+
border;
+
border_color (gray 300);
+
rounded `Md;
+
]] ();
+
];
+
+
btn_primary [txt "Submit"];
+
];
];
];
];
];
] in
-
html_doc
+
html
let () =
-
(* Output HTML to stdout *)
-
let html_doc = create_patterns_demo () in
-
let html_string = El.to_string ~doctype:true html_doc in
-
print_string html_string
+
let html = create_patterns_demo () in
+
print_string (El.to_string ~doctype:true html)
+144 -148
examples/responsive_design_04.ml
···
-
(* Example 04: Responsive Design - Building Adaptive Layouts *)
+
(* Example 04: Responsive Design - GADT interface showcase *)
open Htmlit
-
open Tailwind
-
-
let classes_attr tailwind_classes =
-
At.class' (Tailwind.to_string tailwind_classes)
+
open Tailwind_html
let create_responsive_demo () =
-
(* Create comprehensive responsive demonstration *)
-
let html_doc = El.html [
+
let html = El.html [
El.head [
El.meta ~at:[At.charset "utf-8"] ();
El.meta ~at:[At.name "viewport"; At.content "width=device-width, initial-scale=1"] ();
-
El.title [El.txt "Responsive Design"];
+
El.title [txt "Responsive Design"];
El.link ~at:[At.rel "stylesheet"; At.href "responsive_design_04.css"] ();
];
-
El.body ~at:[At.class' "min-h-screen bg-gray-50 p-8"] [
-
El.div ~at:[At.class' "max-w-6xl mx-auto"] [
-
El.h1 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Xl2));
-
Responsive.(to_class (at_breakpoint `Md (Typography.(to_class (font_size `Xl3)))));
-
Typography.(to_class (font_weight `Bold));
-
Color.text (Color.make `Gray ~variant:`V700 ());
-
]); At.class' "mb-8 text-center"] [El.txt "Responsive Design Demo"];
+
El.body ~at:[classes_attr [
+
min_height screen;
+
bg_color (gray 50);
+
padding (rem 1.0);
+
]] [
+
container [
+
h1 ~styles:[
+
font_size `Xl2;
+
font_weight `Bold;
+
text_color (gray 800);
+
text_center;
+
margin_bottom (rem 2.0);
+
] [txt "Responsive Design Demo"];
-
El.p ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Lg));
-
Color.text (Color.make `Gray ~variant:`V600 ());
-
]); At.class' "text-center mb-8"] [
-
El.txt "Resize your browser window to see responsive changes. The indicator in the top-right shows the current breakpoint."
-
];
-
-
(* Responsive Grid *)
-
El.section ~at:[At.class' "mb-8"] [
-
El.h2 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Xl));
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V700 ());
-
]); At.class' "mb-6"] [El.txt "Responsive Grid"];
-
-
El.p ~at:[classes_attr (Css.tw [
-
Color.text (Color.make `Gray ~variant:`V600 ());
-
]); At.class' "mb-4"] [
-
El.txt "1 column โ†’ 2 columns (md) โ†’ 3 columns (lg) โ†’ 4 columns (xl)"
-
];
-
-
El.div ~at:[classes_attr (Css.tw [
-
Display.grid;
-
Grid.(to_class (template_cols (`Cols 1)));
-
Responsive.(to_class (at_breakpoint `Md (Grid.(to_class (template_cols (`Cols 2))))));
-
Responsive.(to_class (at_breakpoint `Lg (Grid.(to_class (template_cols (`Cols 3))))));
-
Responsive.(to_class (at_breakpoint `Xl (Grid.(to_class (template_cols (`Cols 4))))));
-
Spacing.(to_class (gap `All (Size.rem 1.0)));
-
])] (List.init 8 (fun i ->
-
let colors = [|
-
Color.make `Blue ~variant:`V100 ();
-
Color.make `Green ~variant:`V100 ();
-
Color.make `Purple ~variant:`V100 ();
-
Color.make `Red ~variant:`V100 ();
-
Color.make `Yellow ~variant:`V100 ();
-
|] in
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg colors.(i mod (Array.length colors));
-
Spacing.(to_class (p (Size.rem 1.5)));
-
]); At.class' "rounded-lg text-center"] [
-
El.txt (Printf.sprintf "Item %d" (i + 1))
-
]
-
));
-
];
+
p ~styles:[
+
font_size `Lg;
+
text_color (gray 600);
+
text_center;
+
margin_bottom (rem 3.0);
+
] [txt "Adaptive layouts using GADT interface"];
-
(* Responsive Typography *)
-
El.section ~at:[At.class' "mb-8"] [
-
El.h2 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Xl));
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V700 ());
-
]); At.class' "mb-6"] [El.txt "Responsive Typography"];
+
(* Mobile-first card grid *)
+
section ~styles:[margin_bottom (rem 3.0)] [
+
h2 ~styles:[
+
font_size `Xl;
+
font_weight `Semibold;
+
text_color (gray 700);
+
margin_bottom (rem 2.0);
+
] [txt "Responsive Card Grid"];
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg (Color.make `Gray ~variant:`V100 ());
-
Spacing.(to_class (p (Size.rem 1.5)));
-
]); At.class' "rounded-lg text-center"] [
-
El.h3 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Base));
-
Responsive.(to_class (at_breakpoint `Md (Typography.(to_class (font_size `Lg)))));
-
Responsive.(to_class (at_breakpoint `Lg (Typography.(to_class (font_size `Xl2)))));
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Blue ~variant:`V600 ());
-
]); At.class' "mb-4"] [El.txt "Responsive Heading"];
+
(* Using CSS Grid - starts as 1 column on mobile, would be 3 columns on larger screens *)
+
div ~styles:[
+
grid;
+
grid_cols 1; (* Mobile: 1 column, but ideally would be responsive *)
+
gap (rem 1.5);
+
] [
+
(* Card 1 *)
+
card [
+
h3 ~styles:[
+
font_size `Lg;
+
font_weight `Semibold;
+
text_color (blue 600);
+
margin_bottom (rem 1.0);
+
] [txt "Card 1"];
+
p ~styles:[text_color (gray 600)] [
+
txt "This card stacks vertically on mobile and forms a grid on larger screens."
+
];
+
];
-
El.p ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Sm));
-
Responsive.(to_class (at_breakpoint `Md (Typography.(to_class (font_size `Base)))));
-
Color.text (Color.make `Gray ~variant:`V600 ());
-
])] [
-
El.txt "This text scales: small on mobile, base on tablet, and larger on desktop. The heading above also scales responsively."
+
(* Card 2 *)
+
card [
+
h3 ~styles:[
+
font_size `Lg;
+
font_weight `Semibold;
+
text_color (green 600);
+
margin_bottom (rem 1.0);
+
] [txt "Card 2"];
+
p ~styles:[text_color (gray 600)] [
+
txt "Responsive design ensures optimal viewing across all devices."
+
];
+
];
+
+
(* Card 3 *)
+
card [
+
h3 ~styles:[
+
font_size `Lg;
+
font_weight `Semibold;
+
text_color (purple 600);
+
margin_bottom (rem 1.0);
+
] [txt "Card 3"];
+
p ~styles:[text_color (gray 600)] [
+
txt "Mobile-first approach with progressive enhancement."
+
];
];
];
];
-
(* Show/Hide Elements *)
-
El.section ~at:[At.class' "mb-8"] [
-
El.h2 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Xl));
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V700 ());
-
]); At.class' "mb-6"] [El.txt "Responsive Visibility"];
+
(* Responsive navigation *)
+
section ~styles:[margin_bottom (rem 3.0)] [
+
h2 ~styles:[
+
font_size `Xl;
+
font_weight `Semibold;
+
text_color (gray 700);
+
margin_bottom (rem 2.0);
+
] [txt "Responsive Navigation"];
-
El.div ~at:[classes_attr (Css.tw [
-
Display.flex;
-
Flexbox.(to_class (direction `Col));
-
Responsive.(to_class (at_breakpoint `Md (Flexbox.(to_class (direction `Row)))));
-
Spacing.(to_class (gap `All (Size.rem 1.0)));
-
])] [
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg (Color.make `Blue ~variant:`V100 ());
-
Spacing.(to_class (p (Size.rem 1.5)));
-
]); At.class' "rounded-lg text-center"] [
-
El.txt "Always visible"
-
];
-
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg (Color.make `Green ~variant:`V100 ());
-
Spacing.(to_class (p (Size.rem 1.5)));
-
Display.hidden;
-
Responsive.(to_class (at_breakpoint `Md Display.block));
-
]); At.class' "rounded-lg text-center"] [
-
El.txt "Hidden on mobile, visible on md+"
-
];
-
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg (Color.make `Purple ~variant:`V100 ());
-
Spacing.(to_class (p (Size.rem 1.5)));
-
Display.hidden;
-
Responsive.(to_class (at_breakpoint `Lg Display.block));
-
]); At.class' "rounded-lg text-center"] [
-
El.txt "Only visible on lg+"
+
nav ~styles:[
+
bg_color (Tailwind.Color.white);
+
padding (rem 1.0);
+
rounded `Lg;
+
shadow `Md;
+
] [
+
div ~styles:[
+
flex;
+
flex_col;
+
] [
+
a ~styles:[
+
padding (rem 0.75);
+
text_color (gray 700);
+
font_weight `Medium;
+
] ~href:"#" [txt "Home"];
+
+
a ~styles:[
+
padding (rem 0.75);
+
text_color (gray 700);
+
font_weight `Medium;
+
] ~href:"#" [txt "About"];
+
+
a ~styles:[
+
padding (rem 0.75);
+
text_color (gray 700);
+
font_weight `Medium;
+
] ~href:"#" [txt "Services"];
+
+
a ~styles:[
+
padding (rem 0.75);
+
text_color (gray 700);
+
font_weight `Medium;
+
] ~href:"#" [txt "Contact"];
];
];
];
-
(* Responsive Spacing *)
-
El.section [
-
El.h2 ~at:[classes_attr (Css.tw [
-
Typography.(to_class (font_size `Xl));
-
Typography.(to_class (font_weight `Semibold));
-
Color.text (Color.make `Gray ~variant:`V700 ());
-
]); At.class' "mb-6"] [El.txt "Responsive Spacing"];
+
(* Responsive text *)
+
section [
+
h2 ~styles:[
+
font_size `Xl;
+
font_weight `Semibold;
+
text_color (gray 700);
+
margin_bottom (rem 2.0);
+
] [txt "Responsive Typography"];
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg (Color.make `Gray ~variant:`V100 ());
-
Spacing.(to_class (p (Size.rem 1.0)));
-
Responsive.(to_class (at_breakpoint `Md (Spacing.(to_class (p (Size.rem 1.5))))));
-
Responsive.(to_class (at_breakpoint `Lg (Spacing.(to_class (p (Size.rem 2.0))))));
-
]); At.class' "rounded-lg"] [
-
El.div ~at:[classes_attr (Css.tw [
-
Color.bg Color.white;
-
Spacing.(to_class (p (Size.rem 1.0)));
-
]); At.class' "rounded"] [
-
El.p [El.txt "This container has responsive padding:"];
-
El.ul [
-
El.li [El.txt "p-4 (1rem) on mobile"];
-
El.li [El.txt "md:p-6 (1.5rem) on tablet"];
-
El.li [El.txt "lg:p-8 (2rem) on desktop"];
-
];
-
];
+
card [
+
h3 ~styles:[
+
font_size `Lg;
+
font_weight `Semibold;
+
text_color (gray 800);
+
margin_bottom (rem 1.0);
+
] [txt "Adaptive Text Sizes"];
+
+
p ~styles:[
+
font_size `Base;
+
text_color (gray 600);
+
margin_bottom (rem 1.0);
+
] [txt "This text adapts its size based on the viewport width."];
+
+
p ~styles:[
+
font_size `Sm;
+
text_color (gray 500);
+
] [txt "Smaller supporting text that remains readable on all devices."];
];
];
];
];
] in
-
-
let html_string = El.to_string ~doctype:true html_doc in
-
print_string html_string
+
html
-
let () = create_responsive_demo ()
+
let () =
+
let html = create_responsive_demo () in
+
print_string (El.to_string ~doctype:true html)
-69
examples/type_safety_test.ml
···
-
(* Type Safety Test - Demonstrating GADT constraints *)
-
-
open Htmlit
-
open Tailwind_html
-
-
(* Valid usage - each property category appears at most once *)
-
let valid_styles = [
-
text_color (blue 600); (* โœ… Text color *)
-
bg_color (gray 100); (* โœ… Background color *)
-
font_size `Xl2; (* โœ… Font size *)
-
font_weight `Bold; (* โœ… Font weight *)
-
margin_bottom (rem 1.0); (* โœ… Margin *)
-
padding (rem 1.5); (* โœ… Padding *)
-
rounded `Lg; (* โœ… Border radius *)
-
shadow `Md; (* โœ… Shadow *)
-
]
-
-
(* This would cause a type error if uncommented: *)
-
(* let invalid_styles = [
-
text_color (blue 600);
-
text_color (red 500); (* โŒ Cannot have two text colors! *)
-
] *)
-
-
let create_type_safety_demo () =
-
let html = El.html [
-
El.head [
-
El.meta ~at:[At.charset "utf-8"] ();
-
El.title [txt "Type Safety Test"];
-
];
-
-
El.body [
-
h1_styled ~styles:valid_styles [
-
txt "โœ… Type-Safe Tailwind with GADTs"
-
];
-
-
p_gadt ~styles:[
-
text_color (gray 600);
-
font_size `Base;
-
margin_bottom (rem 2.0);
-
] [
-
txt "This demonstrates that each property category can only appear once, ";
-
txt "preventing styling conflicts at compile time!"
-
];
-
-
div_styled ~styles:[
-
bg_color (green 50);
-
padding (rem 2.0);
-
rounded `Md;
-
] [
-
h2_styled ~styles:[
-
text_color (green 700);
-
font_weight `Semibold;
-
margin_bottom (rem 1.0);
-
] [txt "๐ŸŽฏ Type Safety Features"];
-
-
El.ul [
-
El.li [txt "โœ… Each property category (color, size, spacing) appears at most once"];
-
El.li [txt "โœ… Compile-time prevention of styling conflicts"];
-
El.li [txt "โœ… Clean, readable heterogeneous list syntax"];
-
El.li [txt "โœ… Full type inference and autocomplete support"];
-
];
-
];
-
];
-
] in
-
html
-
-
let () =
-
let html = create_type_safety_demo () in
-
print_string (El.to_string ~doctype:true html)
+25 -2
lib/tailwind-html/form.ml
···
El.input ~at:(At.type' "checkbox" :: all_attrs) ()
in
-
(* Wrap in label if provided *)
-
match field.label with
+
let label_element = match field.label with
| Some label_text ->
El.label [
El.txt label_text;
input_element;
]
| None -> input_element
+
in
+
+
(* Add helper and error text if provided *)
+
let help_elements = List.filter_map (fun x -> x) [
+
Option.map (fun text ->
+
El.p ~at:[classes_attr (Tailwind.Css.tw [
+
Tailwind.Typography.(to_class (font_size `Sm));
+
Tailwind.Color.text (Tailwind.Color.make `Gray ~variant:`V600 ());
+
Tailwind.Spacing.(to_class (mt (Tailwind.Size.rem 0.25)));
+
])] [El.txt text]
+
) field.helper_text;
+
Option.map (fun text ->
+
El.p ~at:[classes_attr (Tailwind.Css.tw [
+
Tailwind.Typography.(to_class (font_size `Sm));
+
Tailwind.Color.text (Tailwind.Color.make `Red ~variant:`V600 ());
+
Tailwind.Spacing.(to_class (mt (Tailwind.Size.rem 0.25)));
+
])] [El.txt text]
+
) field.error_text;
+
] in
+
+
(* Wrap everything in a container *)
+
match help_elements with
+
| [] -> label_element
+
| _ -> El.div ([label_element] @ help_elements)
let group ?classes ~fields () =
let group_classes = Tailwind.Css.tw [
+18
lib/tailwind-html/tailwind_html.ml
···
| Max_width : Tailwind.Size.t -> [`Width] tw_prop
| Min_height : Tailwind.Size.t -> [`Height] tw_prop
| Display_flex : [`Layout] tw_prop
+
| Display_grid : [`Layout] tw_prop
| Display_block : [`Layout] tw_prop
| Display_inline : [`Layout] tw_prop
| Display_inline_block : [`Layout] tw_prop
+
| Grid_cols : int -> [`Grid] tw_prop
+
| Grid_rows : int -> [`Grid] tw_prop
+
| Gap : Tailwind.Size.t -> [`Grid] tw_prop
+
| Gap_x : Tailwind.Size.t -> [`Grid] tw_prop
+
| Gap_y : Tailwind.Size.t -> [`Grid] tw_prop
| Items_center : [`Layout] tw_prop
| Items_start : [`Layout] tw_prop
| Items_end : [`Layout] tw_prop
···
| Max_width size -> Tailwind.Layout.(to_class (max_width size))
| Min_height size -> Tailwind.Layout.(to_class (min_height size))
| Display_flex -> Tailwind.Display.flex
+
| Display_grid -> Tailwind.Display.grid
| Display_block -> Tailwind.Display.block
| Display_inline -> Tailwind.Display.inline
| Display_inline_block -> Tailwind.Display.inline_block
+
| Grid_cols n -> Tailwind.Grid.(to_class (template_cols (`Cols n)))
+
| Grid_rows n -> Tailwind.Grid.(to_class (template_rows (`Rows n)))
+
| Gap size -> Tailwind.Spacing.(to_class (gap `All size))
+
| Gap_x size -> Tailwind.Spacing.(to_class (gap `X size))
+
| Gap_y size -> Tailwind.Spacing.(to_class (gap `Y size))
| Items_center -> Tailwind.Flexbox.(to_class (align_items `Center))
| Items_start -> Tailwind.Flexbox.(to_class (align_items `Start))
| Items_end -> Tailwind.Flexbox.(to_class (align_items `End))
···
let max_width s = Any (Max_width s)
let min_height s = Any (Min_height s)
let flex = Any Display_flex
+
let grid = Any Display_grid
let block = Any Display_block
let inline = Any Display_inline
let inline_block = Any Display_inline_block
+
let grid_cols n = Any (Grid_cols n)
+
let grid_rows n = Any (Grid_rows n)
+
let gap s = Any (Gap s)
+
let gap_x s = Any (Gap_x s)
+
let gap_y s = Any (Gap_y s)
let items_center = Any Items_center
let items_start = Any Items_start
let items_end = Any Items_end
+12
lib/tailwind-html/tailwind_html.mli
···
| Max_width : Tailwind.Size.t -> [`Width] tw_prop
| Min_height : Tailwind.Size.t -> [`Height] tw_prop
| Display_flex : [`Layout] tw_prop
+
| Display_grid : [`Layout] tw_prop
| Display_block : [`Layout] tw_prop
| Display_inline : [`Layout] tw_prop
| Display_inline_block : [`Layout] tw_prop
+
| Grid_cols : int -> [`Grid] tw_prop
+
| Grid_rows : int -> [`Grid] tw_prop
+
| Gap : Tailwind.Size.t -> [`Grid] tw_prop
+
| Gap_x : Tailwind.Size.t -> [`Grid] tw_prop
+
| Gap_y : Tailwind.Size.t -> [`Grid] tw_prop
| Items_center : [`Layout] tw_prop
| Items_start : [`Layout] tw_prop
| Items_end : [`Layout] tw_prop
···
val max_width : Tailwind.Size.t -> tw_list_item
val min_height : Tailwind.Size.t -> tw_list_item
val flex : tw_list_item
+
val grid : tw_list_item
val block : tw_list_item
val inline : tw_list_item
val inline_block : tw_list_item
+
val grid_cols : int -> tw_list_item
+
val grid_rows : int -> tw_list_item
+
val gap : Tailwind.Size.t -> tw_list_item
+
val gap_x : Tailwind.Size.t -> tw_list_item
+
val gap_y : Tailwind.Size.t -> tw_list_item
val items_center : tw_list_item
val items_start : tw_list_item
val items_end : tw_list_item
+6 -9
tailwind-html.opam
···
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
synopsis: "Tailwind CSS integration with Htmlit"
-
description: "High-level component library using Tailwind CSS with Htmlit"
-
maintainer: ["Your Name"]
-
authors: ["Your Name"]
-
license: "MIT"
-
homepage: "https://github.com/yourusername/tailwind-ocaml"
-
doc: "https://yourusername.github.io/tailwind-ocaml/"
-
bug-reports: "https://github.com/yourusername/tailwind-ocaml/issues"
+
description: "Html combinators for Tailwind CSS"
+
maintainer: ["Anil Madhavapeddy"]
+
authors: ["Anil Madhavapeddy"]
+
license: "ISC"
depends: [
+
"dune" {>= "3.18"}
"ocaml"
-
"dune" {>= "3.0" & >= "3.0"}
"tailwind"
"htmlit" {>= "0.1.0"}
"alcotest" {with-test}
···
"@doc" {with-doc}
]
]
-
dev-repo: "git+https://github.com/yourusername/tailwind-ocaml.git"
+
x-maintenance-intent: ["(latest)"]
-1422
tailwind-llms.txt
···
-
# Tailwind CSS v4 LLM Development Guidelines
-
-
You are an expert web developer specializing in Tailwind CSS v4. Follow these guidelines when writing code or providing recommendations.
-
-
## Core Principles
-
-
Tailwind CSS v4 is a complete rewrite with a new high-performance Oxide engine, CSS-first configuration, and modern web platform features. It requires modern browsers (Safari 16.4+, Chrome 111+, Firefox 128+) and is NOT compatible with older browsers.
-
-
## Installation & Setup
-
-
### Basic Setup
-
```css
-
/* styles.css */
-
@import "tailwindcss";
-
```
-
-
### With Vite
-
```js
-
// vite.config.js
-
import { defineConfig } from 'vite'
-
import tailwindcss from '@tailwindcss/vite'
-
-
export default defineConfig({
-
plugins: [tailwindcss()]
-
})
-
```
-
-
### Package Installation
-
```bash
-
npm install tailwindcss@next @tailwindcss/vite@next
-
```
-
-
## Configuration (CSS-First)
-
-
**IMPORTANT**: v4 uses CSS-first configuration, NOT JavaScript config files. Use the `@theme` directive in your CSS file:
-
-
```css
-
@import "tailwindcss";
-
-
@theme {
-
/* Colors (use OKLCH for wider gamut) */
-
--color-brand-50: oklch(0.98 0.01 142.12);
-
--color-brand-500: oklch(0.64 0.15 142.12);
-
--color-brand-900: oklch(0.25 0.08 142.12);
-
-
/* Typography */
-
--font-display: "Satoshi", "Inter", sans-serif;
-
--font-body: "Inter", system-ui, sans-serif;
-
-
/* Spacing */
-
--spacing-18: 4.5rem;
-
--spacing-72: 18rem;
-
-
/* Breakpoints */
-
--breakpoint-3xl: 1920px;
-
--breakpoint-4xl: 2560px;
-
-
/* Shadows */
-
--shadow-brutal: 8px 8px 0px 0px #000;
-
-
/* Animation */
-
--animate-wiggle: wiggle 1s ease-in-out infinite;
-
}
-
-
/* Define keyframes for animations */
-
@keyframes wiggle {
-
0%, 100% { transform: rotate(-3deg); }
-
50% { transform: rotate(3deg); }
-
}
-
```
-
-
### Legacy Config Support (if needed)
-
```css
-
@import "tailwindcss";
-
@config "./tailwind.config.js";
-
```
-
-
## Breaking Changes from v3
-
-
### Import Changes
-
- โŒ `@tailwind base; @tailwind components; @tailwind utilities;`
-
- โœ… `@import "tailwindcss";`
-
-
### Removed Utilities
-
- `text-opacity-*` โ†’ Use `text-{color}/{opacity}` instead
-
- `bg-opacity-*` โ†’ Use `bg-{color}/{opacity}` instead
-
- `border-opacity-*` โ†’ Use `border-{color}/{opacity}` instead
-
- `flex-grow-*` โ†’ Use `grow-*`
-
- `flex-shrink-*` โ†’ Use `shrink-*`
-
- `decoration-slice` โ†’ Use `box-decoration-slice`
-
-
### Renamed Utilities
-
- `shadow-sm` โ†’ `shadow-xs`
-
- `rounded-sm` โ†’ `rounded-xs`
-
- `blur-sm` โ†’ `blur-xs`
-
- `bg-gradient-*` โ†’ `bg-linear-*`
-
-
### Default Behavior Changes
-
- **Border**: No longer defaults to gray-200, uses `currentColor`
-
- **Ring**: Changed from 3px blue to 1px `currentColor`
-
- **Outline**: Now 1px by default for consistency
-
-
## Custom Utilities
-
-
Use the `@utility` directive instead of `@layer utilities`:
-
-
```css
-
@utility btn {
-
padding: 0.5rem 1rem;
-
border-radius: 0.375rem;
-
font-weight: 500;
-
transition: all 0.2s;
-
}
-
-
@utility btn-primary {
-
background: var(--color-blue-600);
-
color: white;
-
-
&:hover {
-
background: var(--color-blue-700);
-
}
-
}
-
-
/* Functional utilities with parameters */
-
@utility margin-auto {
-
margin: auto;
-
}
-
-
@utility flex-center {
-
display: flex;
-
justify-content: center;
-
align-items: center;
-
}
-
```
-
-
## Custom Variants
-
-
```css
-
@custom-variant theme-dark {
-
&:where([data-theme="dark"] *) {
-
@slot;
-
}
-
}
-
-
@custom-variant any-hover {
-
@media (any-hover: hover) {
-
&:hover {
-
@slot;
-
}
-
}
-
}
-
```
-
-
## New Features in v4
-
-
### Container Queries (Built-in)
-
```html
-
<div class="@container">
-
<div class="grid grid-cols-1 @sm:grid-cols-2 @lg:grid-cols-3">
-
<div class="@min-w-64:text-lg @max-w-96:bg-blue-100">
-
Responsive to container size
-
</div>
-
</div>
-
</div>
-
```
-
-
### 3D Transforms
-
```html
-
<div class="perspective-1000">
-
<div class="rotate-x-45 rotate-y-12 scale-z-110 translate-z-24 transform-3d">
-
3D transformed element
-
</div>
-
</div>
-
```
-
-
### Enhanced Gradients
-
```html
-
<!-- Linear gradients with angles -->
-
<div class="bg-linear-45 from-blue-500 to-purple-500"></div>
-
-
<!-- Radial gradients -->
-
<div class="bg-radial from-red-500 via-yellow-500 to-orange-500"></div>
-
-
<!-- Conic gradients -->
-
<div class="bg-conic from-pink-500 via-blue-500 to-green-500"></div>
-
```
-
-
### Text Shadows
-
```html
-
<h1 class="text-shadow-lg text-shadow-blue-500/50">
-
Text with colored shadow
-
</h1>
-
```
-
-
### Mask Utilities
-
```html
-
<div class="mask-radial mask-cover">
-
<img src="image.jpg" alt="Masked image" />
-
</div>
-
```
-
-
### New Variants
-
-
#### @starting-style (for animations)
-
```html
-
<div class="opacity-100 @starting-style:opacity-0 transition-opacity">
-
Animates in on mount
-
</div>
-
```
-
-
#### not-* variant
-
```html
-
<div class="bg-blue-500 not-hover:bg-gray-500">
-
Blue except when hovering
-
</div>
-
```
-
-
#### nth-* variants
-
```html
-
<div class="nth-2:bg-red-500 nth-odd:bg-blue-500">
-
Nth child styling
-
</div>
-
```
-
-
#### inert variant
-
```html
-
<div class="inert:opacity-50 inert:pointer-events-none">
-
Styled when inert
-
</div>
-
```
-
-
#### in-* variant (like group-* but without group class)
-
```html
-
<article>
-
<h2 class="in-article:text-lg">Styled when inside article</h2>
-
</article>
-
```
-
-
### Modern Color System
-
v4 uses OKLCH color space for wider gamut support:
-
-
```css
-
@theme {
-
--color-brand-primary: oklch(0.7 0.15 180);
-
--color-brand-accent: oklch(0.8 0.2 45);
-
}
-
```
-
-
## Multi-Theme Strategy
-
-
```css
-
@import "tailwindcss";
-
-
@theme {
-
--color-primary: oklch(0.5 0.2 240);
-
--color-background: oklch(0.98 0.01 240);
-
}
-
-
@layer base {
-
[data-theme='dark'] {
-
--color-primary: oklch(0.7 0.2 240);
-
--color-background: oklch(0.15 0.02 240);
-
}
-
-
[data-theme='high-contrast'] {
-
--color-primary: oklch(0.0 0 0);
-
--color-background: oklch(1.0 0 0);
-
}
-
}
-
```
-
-
## Best Practices
-
-
### 1. Use CSS Variables for Dynamic Values
-
```html
-
<div class="bg-[var(--dynamic-color)] text-[var(--dynamic-size)]">
-
Dynamic styling
-
</div>
-
```
-
-
### 2. Leverage the New Color System
-
```html
-
<!-- Better contrast and vibrancy with OKLCH -->
-
<div class="bg-blue-500 text-white">
-
Vivid colors on modern displays
-
</div>
-
```
-
-
### 3. Container Queries for True Responsive Design
-
```html
-
<div class="@container">
-
<div class="p-4 @lg:p-8 @xl:p-12">
-
Responds to container, not viewport
-
</div>
-
</div>
-
```
-
-
### 4. Modern CSS Features
-
```html
-
<!-- Native cascade layers -->
-
<div class="layer-[utilities]:z-10">
-
Proper layer management
-
</div>
-
-
<!-- Color mixing -->
-
<div class="bg-blue-500/50">
-
Uses color-mix() under the hood
-
</div>
-
```
-
-
## Performance Optimizations
-
-
v4's Oxide engine provides:
-
- 5x faster full builds
-
- 100x faster incremental builds
-
- Automatic content detection
-
- Built-in import handling
-
- Native vendor prefixing
-
-
## File Organization
-
-
```
-
src/
-
โ”œโ”€โ”€ styles/
-
โ”‚ โ”œโ”€โ”€ main.css # @import "tailwindcss" + @theme
-
โ”‚ โ”œโ”€โ”€ components.css # @utility definitions
-
โ”‚ โ””โ”€โ”€ utilities.css # Additional @utility definitions
-
โ””โ”€โ”€ components/
-
โ””โ”€โ”€ *.vue/jsx/html # Your components
-
```
-
-
## Common Patterns
-
-
### Theme-aware Components
-
```css
-
@utility card {
-
background: var(--color-background);
-
border: 1px solid var(--color-border);
-
border-radius: 0.5rem;
-
padding: 1.5rem;
-
box-shadow: var(--shadow-sm);
-
}
-
```
-
-
### Responsive Typography
-
```html
-
<h1 class="text-2xl @sm:text-3xl @lg:text-4xl @xl:text-5xl">
-
Container-responsive heading
-
</h1>
-
```
-
-
### Animation with @starting-style
-
```html
-
<div class="translate-y-0 @starting-style:translate-y-full transition-transform duration-500">
-
Slides up on mount
-
</div>
-
```
-
-
## Debugging Tips
-
-
1. **Use browser dev tools** to inspect CSS variables
-
2. **Check cascade layers** in dev tools
-
3. **Verify modern browser support** for OKLCH colors
-
4. **Use @reference** for CSS modules/component styles
-
5. **Restart dev server** after major theme changes
-
-
## Migration from v3
-
-
1. Replace `@tailwind` directives with `@import "tailwindcss"`
-
2. Move config from JS to CSS using `@theme`
-
3. Update deprecated utility classes
-
4. Replace `@layer utilities` with `@utility`
-
5. Test in modern browsers only
-
6. Use the official upgrade tool: `npx @tailwindcss/upgrade@next`
-
-
## Complete Utility Class Reference
-
-
### Layout
-
-
#### Display
-
```
-
block, inline-block, inline, flex, inline-flex, table, inline-table, table-caption, table-cell, table-column, table-column-group, table-footer-group, table-header-group, table-row-group, table-row, flow-root, grid, inline-grid, contents, list-item, hidden
-
```
-
-
#### Position
-
```
-
static, fixed, absolute, relative, sticky
-
```
-
-
#### Top/Right/Bottom/Left
-
```
-
inset-0, inset-x-0, inset-y-0, start-0, end-0, top-0, right-0, bottom-0, left-0
-
inset-px, inset-x-px, inset-y-px, start-px, end-px, top-px, right-px, bottom-px, left-px
-
inset-0.5, inset-1, inset-1.5, inset-2, inset-2.5, inset-3, inset-3.5, inset-4, inset-5, inset-6, inset-7, inset-8, inset-9, inset-10, inset-11, inset-12, inset-14, inset-16, inset-20, inset-24, inset-28, inset-32, inset-36, inset-40, inset-44, inset-48, inset-52, inset-56, inset-60, inset-64, inset-72, inset-80, inset-96
-
inset-auto, inset-1/2, inset-1/3, inset-2/3, inset-1/4, inset-2/4, inset-3/4, inset-full
-
```
-
-
#### Visibility & Z-Index
-
```
-
visible, invisible, collapse
-
z-0, z-10, z-20, z-30, z-40, z-50, z-auto
-
```
-
-
#### Overflow
-
```
-
overflow-auto, overflow-hidden, overflow-clip, overflow-visible, overflow-scroll
-
overflow-x-auto, overflow-x-hidden, overflow-x-clip, overflow-x-visible, overflow-x-scroll
-
overflow-y-auto, overflow-y-hidden, overflow-y-clip, overflow-y-visible, overflow-y-scroll
-
```
-
-
### Flexbox & Grid
-
-
#### Flex Direction
-
```
-
flex-row, flex-row-reverse, flex-col, flex-col-reverse
-
```
-
-
#### Flex Wrap
-
```
-
flex-wrap, flex-wrap-reverse, flex-nowrap
-
```
-
-
#### Flex
-
```
-
flex-1, flex-auto, flex-initial, flex-none
-
```
-
-
#### Grow & Shrink
-
```
-
grow, grow-0, shrink, shrink-0
-
```
-
-
#### Order
-
```
-
order-1, order-2, order-3, order-4, order-5, order-6, order-7, order-8, order-9, order-10, order-11, order-12, order-first, order-last, order-none
-
```
-
-
#### Grid Template Columns
-
```
-
grid-cols-1, grid-cols-2, grid-cols-3, grid-cols-4, grid-cols-5, grid-cols-6, grid-cols-7, grid-cols-8, grid-cols-9, grid-cols-10, grid-cols-11, grid-cols-12, grid-cols-none, grid-cols-subgrid
-
```
-
-
#### Grid Column Start/End
-
```
-
col-auto, col-span-1, col-span-2, col-span-3, col-span-4, col-span-5, col-span-6, col-span-7, col-span-8, col-span-9, col-span-10, col-span-11, col-span-12, col-span-full
-
col-start-1, col-start-2, col-start-3, col-start-4, col-start-5, col-start-6, col-start-7, col-start-8, col-start-9, col-start-10, col-start-11, col-start-12, col-start-13, col-start-auto
-
col-end-1, col-end-2, col-end-3, col-end-4, col-end-5, col-end-6, col-end-7, col-end-8, col-end-9, col-end-10, col-end-11, col-end-12, col-end-13, col-end-auto
-
```
-
-
#### Grid Template Rows
-
```
-
grid-rows-1, grid-rows-2, grid-rows-3, grid-rows-4, grid-rows-5, grid-rows-6, grid-rows-7, grid-rows-8, grid-rows-9, grid-rows-10, grid-rows-11, grid-rows-12, grid-rows-none, grid-rows-subgrid
-
```
-
-
#### Grid Row Start/End
-
```
-
row-auto, row-span-1, row-span-2, row-span-3, row-span-4, row-span-5, row-span-6, row-span-7, row-span-8, row-span-9, row-span-10, row-span-11, row-span-12, row-span-full
-
row-start-1, row-start-2, row-start-3, row-start-4, row-start-5, row-start-6, row-start-7, row-start-8, row-start-9, row-start-10, row-start-11, row-start-12, row-start-13, row-start-auto
-
row-end-1, row-end-2, row-end-3, row-end-4, row-end-5, row-end-6, row-end-7, row-end-8, row-end-9, row-end-10, row-end-11, row-end-12, row-end-13, row-end-auto
-
```
-
-
#### Gap
-
```
-
gap-0, gap-x-0, gap-y-0, gap-px, gap-x-px, gap-y-px
-
gap-0.5, gap-1, gap-1.5, gap-2, gap-2.5, gap-3, gap-3.5, gap-4, gap-5, gap-6, gap-7, gap-8, gap-9, gap-10, gap-11, gap-12, gap-14, gap-16, gap-20, gap-24, gap-28, gap-32, gap-36, gap-40, gap-44, gap-48, gap-52, gap-56, gap-60, gap-64, gap-72, gap-80, gap-96
-
```
-
-
#### Justify & Align
-
```
-
justify-normal, justify-start, justify-end, justify-center, justify-between, justify-around, justify-evenly, justify-stretch
-
justify-items-start, justify-items-end, justify-items-center, justify-items-stretch
-
justify-self-auto, justify-self-start, justify-self-end, justify-self-center, justify-self-stretch
-
align-items-start, align-items-end, align-items-center, align-items-baseline, align-items-stretch
-
align-content-normal, align-content-center, align-content-start, align-content-end, align-content-between, align-content-around, align-content-evenly, align-content-baseline, align-content-stretch
-
align-self-auto, align-self-start, align-self-end, align-self-center, align-self-stretch, align-self-baseline
-
place-content-center, place-content-start, place-content-end, place-content-between, place-content-around, place-content-evenly, place-content-baseline, place-content-stretch
-
place-items-start, place-items-end, place-items-center, place-items-baseline, place-items-stretch
-
place-self-auto, place-self-start, place-self-end, place-self-center, place-self-stretch
-
```
-
-
### Spacing
-
-
#### Padding
-
```
-
p-0, p-px, p-0.5, p-1, p-1.5, p-2, p-2.5, p-3, p-3.5, p-4, p-5, p-6, p-7, p-8, p-9, p-10, p-11, p-12, p-14, p-16, p-20, p-24, p-28, p-32, p-36, p-40, p-44, p-48, p-52, p-56, p-60, p-64, p-72, p-80, p-96
-
px-0, py-0, pl-0, pr-0, pt-0, pb-0, ps-0, pe-0
-
```
-
-
#### Margin
-
```
-
m-0, m-px, m-0.5, m-1, m-1.5, m-2, m-2.5, m-3, m-3.5, m-4, m-5, m-6, m-7, m-8, m-9, m-10, m-11, m-12, m-14, m-16, m-20, m-24, m-28, m-32, m-36, m-40, m-44, m-48, m-52, m-56, m-60, m-64, m-72, m-80, m-96, m-auto
-
mx-0, my-0, ml-0, mr-0, mt-0, mb-0, ms-0, me-0
-
-m-0, -m-px, -m-0.5, -m-1, -m-1.5, -m-2, -m-2.5, -m-3, -m-3.5, -m-4, -m-5, -m-6, -m-7, -m-8, -m-9, -m-10, -m-11, -m-12, -m-14, -m-16, -m-20, -m-24, -m-28, -m-32, -m-36, -m-40, -m-44, -m-48, -m-52, -m-56, -m-60, -m-64, -m-72, -m-80, -m-96
-
```
-
-
#### Space Between
-
```
-
space-x-0, space-x-px, space-x-0.5, space-x-1, space-x-1.5, space-x-2, space-x-2.5, space-x-3, space-x-3.5, space-x-4, space-x-5, space-x-6, space-x-7, space-x-8, space-x-9, space-x-10, space-x-11, space-x-12, space-x-14, space-x-16, space-x-20, space-x-24, space-x-28, space-x-32, space-x-36, space-x-40, space-x-44, space-x-48, space-x-52, space-x-56, space-x-60, space-x-64, space-x-72, space-x-80, space-x-96, space-x-reverse
-
space-y-0, space-y-px, space-y-0.5, space-y-1, space-y-1.5, space-y-2, space-y-2.5, space-y-3, space-y-3.5, space-y-4, space-y-5, space-y-6, space-y-7, space-y-8, space-y-9, space-y-10, space-y-11, space-y-12, space-y-14, space-y-16, space-y-20, space-y-24, space-y-28, space-y-32, space-y-36, space-y-40, space-y-44, space-y-48, space-y-52, space-y-56, space-y-60, space-y-64, space-y-72, space-y-80, space-y-96, space-y-reverse
-
```
-
-
### Sizing
-
-
#### Width
-
```
-
w-0, w-px, w-0.5, w-1, w-1.5, w-2, w-2.5, w-3, w-3.5, w-4, w-5, w-6, w-7, w-8, w-9, w-10, w-11, w-12, w-14, w-16, w-20, w-24, w-28, w-32, w-36, w-40, w-44, w-48, w-52, w-56, w-60, w-64, w-72, w-80, w-96, w-auto, w-1/2, w-1/3, w-2/3, w-1/4, w-2/4, w-3/4, w-1/5, w-2/5, w-3/5, w-4/5, w-1/6, w-2/6, w-3/6, w-4/6, w-5/6, w-1/12, w-2/12, w-3/12, w-4/12, w-5/12, w-6/12, w-7/12, w-8/12, w-9/12, w-10/12, w-11/12, w-full, w-screen, w-svw, w-lvw, w-dvw, w-min, w-max, w-fit
-
```
-
-
#### Height
-
```
-
h-0, h-px, h-0.5, h-1, h-1.5, h-2, h-2.5, h-3, h-3.5, h-4, h-5, h-6, h-7, h-8, h-9, h-10, h-11, h-12, h-14, h-16, h-20, h-24, h-28, h-32, h-36, h-40, h-44, h-48, h-52, h-56, h-60, h-64, h-72, h-80, h-96, h-auto, h-1/2, h-1/3, h-2/3, h-1/4, h-2/4, h-3/4, h-1/5, h-2/5, h-3/5, h-4/5, h-1/6, h-2/6, h-3/6, h-4/6, h-5/6, h-full, h-screen, h-svh, h-lvh, h-dvh, h-min, h-max, h-fit
-
```
-
-
#### Size (Width + Height)
-
```
-
size-0, size-px, size-0.5, size-1, size-1.5, size-2, size-2.5, size-3, size-3.5, size-4, size-5, size-6, size-7, size-8, size-9, size-10, size-11, size-12, size-14, size-16, size-20, size-24, size-28, size-32, size-36, size-40, size-44, size-48, size-52, size-56, size-60, size-64, size-72, size-80, size-96, size-auto, size-1/2, size-1/3, size-2/3, size-1/4, size-2/4, size-3/4, size-1/5, size-2/5, size-3/5, size-4/5, size-1/6, size-2/6, size-3/6, size-4/6, size-5/6, size-1/12, size-2/12, size-3/12, size-4/12, size-5/12, size-6/12, size-7/12, size-8/12, size-9/12, size-10/12, size-11/12, size-full, size-min, size-max, size-fit
-
```
-
-
#### Min/Max Width
-
```
-
min-w-0, min-w-full, min-w-min, min-w-max, min-w-fit
-
max-w-0, max-w-xs, max-w-sm, max-w-md, max-w-lg, max-w-xl, max-w-2xl, max-w-3xl, max-w-4xl, max-w-5xl, max-w-6xl, max-w-7xl, max-w-full, max-w-min, max-w-max, max-w-fit, max-w-prose, max-w-screen-sm, max-w-screen-md, max-w-screen-lg, max-w-screen-xl, max-w-screen-2xl
-
```
-
-
#### Min/Max Height
-
```
-
min-h-0, min-h-full, min-h-screen, min-h-svh, min-h-lvh, min-h-dvh, min-h-min, min-h-max, min-h-fit
-
max-h-0, max-h-px, max-h-0.5, max-h-1, max-h-1.5, max-h-2, max-h-2.5, max-h-3, max-h-3.5, max-h-4, max-h-5, max-h-6, max-h-7, max-h-8, max-h-9, max-h-10, max-h-11, max-h-12, max-h-14, max-h-16, max-h-20, max-h-24, max-h-28, max-h-32, max-h-36, max-h-40, max-h-44, max-h-48, max-h-52, max-h-56, max-h-60, max-h-64, max-h-72, max-h-80, max-h-96, max-h-full, max-h-screen, max-h-svh, max-h-lvh, max-h-dvh, max-h-min, max-h-max, max-h-fit
-
```
-
-
### Typography
-
-
#### Font Family
-
```
-
font-sans, font-serif, font-mono
-
```
-
-
#### Font Size
-
```
-
text-xs, text-sm, text-base, text-lg, text-xl, text-2xl, text-3xl, text-4xl, text-5xl, text-6xl, text-7xl, text-8xl, text-9xl
-
```
-
-
#### Font Weight
-
```
-
font-thin, font-extralight, font-light, font-normal, font-medium, font-semibold, font-bold, font-extrabold, font-black
-
```
-
-
#### Font Style
-
```
-
italic, not-italic
-
```
-
-
#### Font Variant Numeric
-
```
-
normal-nums, ordinal, slashed-zero, lining-nums, oldstyle-nums, proportional-nums, tabular-nums, diagonal-fractions, stacked-fractions
-
```
-
-
#### Font Stretch (NEW in v4)
-
```
-
font-stretch-ultra-condensed, font-stretch-extra-condensed, font-stretch-condensed, font-stretch-semi-condensed, font-stretch-normal, font-stretch-semi-expanded, font-stretch-expanded, font-stretch-extra-expanded, font-stretch-ultra-expanded
-
```
-
-
#### Letter Spacing
-
```
-
tracking-tighter, tracking-tight, tracking-normal, tracking-wide, tracking-wider, tracking-widest
-
```
-
-
#### Line Clamp
-
```
-
line-clamp-1, line-clamp-2, line-clamp-3, line-clamp-4, line-clamp-5, line-clamp-6, line-clamp-none
-
```
-
-
#### Line Height
-
```
-
leading-3, leading-4, leading-5, leading-6, leading-7, leading-8, leading-9, leading-10, leading-none, leading-tight, leading-snug, leading-normal, leading-relaxed, leading-loose
-
```
-
-
#### List Style
-
```
-
list-none, list-disc, list-decimal, list-inside, list-outside
-
```
-
-
#### Text Align
-
```
-
text-left, text-center, text-right, text-justify, text-start, text-end
-
```
-
-
#### Text Color
-
```
-
text-inherit, text-current, text-transparent, text-black, text-white
-
text-slate-50, text-slate-100, text-slate-200, text-slate-300, text-slate-400, text-slate-500, text-slate-600, text-slate-700, text-slate-800, text-slate-900, text-slate-950
-
text-gray-50, text-gray-100, text-gray-200, text-gray-300, text-gray-400, text-gray-500, text-gray-600, text-gray-700, text-gray-800, text-gray-900, text-gray-950
-
text-zinc-50, text-zinc-100, text-zinc-200, text-zinc-300, text-zinc-400, text-zinc-500, text-zinc-600, text-zinc-700, text-zinc-800, text-zinc-900, text-zinc-950
-
text-neutral-50, text-neutral-100, text-neutral-200, text-neutral-300, text-neutral-400, text-neutral-500, text-neutral-600, text-neutral-700, text-neutral-800, text-neutral-900, text-neutral-950
-
text-stone-50, text-stone-100, text-stone-200, text-stone-300, text-stone-400, text-stone-500, text-stone-600, text-stone-700, text-stone-800, text-stone-900, text-stone-950
-
text-red-50, text-red-100, text-red-200, text-red-300, text-red-400, text-red-500, text-red-600, text-red-700, text-red-800, text-red-900, text-red-950
-
text-orange-50, text-orange-100, text-orange-200, text-orange-300, text-orange-400, text-orange-500, text-orange-600, text-orange-700, text-orange-800, text-orange-900, text-orange-950
-
text-amber-50, text-amber-100, text-amber-200, text-amber-300, text-amber-400, text-amber-500, text-amber-600, text-amber-700, text-amber-800, text-amber-900, text-amber-950
-
text-yellow-50, text-yellow-100, text-yellow-200, text-yellow-300, text-yellow-400, text-yellow-500, text-yellow-600, text-yellow-700, text-yellow-800, text-yellow-900, text-yellow-950
-
text-lime-50, text-lime-100, text-lime-200, text-lime-300, text-lime-400, text-lime-500, text-lime-600, text-lime-700, text-lime-800, text-lime-900, text-lime-950
-
text-green-50, text-green-100, text-green-200, text-green-300, text-green-400, text-green-500, text-green-600, text-green-700, text-green-800, text-green-900, text-green-950
-
text-emerald-50, text-emerald-100, text-emerald-200, text-emerald-300, text-emerald-400, text-emerald-500, text-emerald-600, text-emerald-700, text-emerald-800, text-emerald-900, text-emerald-950
-
text-teal-50, text-teal-100, text-teal-200, text-teal-300, text-teal-400, text-teal-500, text-teal-600, text-teal-700, text-teal-800, text-teal-900, text-teal-950
-
text-cyan-50, text-cyan-100, text-cyan-200, text-cyan-300, text-cyan-400, text-cyan-500, text-cyan-600, text-cyan-700, text-cyan-800, text-cyan-900, text-cyan-950
-
text-sky-50, text-sky-100, text-sky-200, text-sky-300, text-sky-400, text-sky-500, text-sky-600, text-sky-700, text-sky-800, text-sky-900, text-sky-950
-
text-blue-50, text-blue-100, text-blue-200, text-blue-300, text-blue-400, text-blue-500, text-blue-600, text-blue-700, text-blue-800, text-blue-900, text-blue-950
-
text-indigo-50, text-indigo-100, text-indigo-200, text-indigo-300, text-indigo-400, text-indigo-500, text-indigo-600, text-indigo-700, text-indigo-800, text-indigo-900, text-indigo-950
-
text-violet-50, text-violet-100, text-violet-200, text-violet-300, text-violet-400, text-violet-500, text-violet-600, text-violet-700, text-violet-800, text-violet-900, text-violet-950
-
text-purple-50, text-purple-100, text-purple-200, text-purple-300, text-purple-400, text-purple-500, text-purple-600, text-purple-700, text-purple-800, text-purple-900, text-purple-950
-
text-fuchsia-50, text-fuchsia-100, text-fuchsia-200, text-fuchsia-300, text-fuchsia-400, text-fuchsia-500, text-fuchsia-600, text-fuchsia-700, text-fuchsia-800, text-fuchsia-900, text-fuchsia-950
-
text-pink-50, text-pink-100, text-pink-200, text-pink-300, text-pink-400, text-pink-500, text-pink-600, text-pink-700, text-pink-800, text-pink-900, text-pink-950
-
text-rose-50, text-rose-100, text-rose-200, text-rose-300, text-rose-400, text-rose-500, text-rose-600, text-rose-700, text-rose-800, text-rose-900, text-rose-950
-
```
-
-
#### Text Decoration
-
```
-
underline, overline, line-through, no-underline
-
decoration-solid, decoration-double, decoration-dotted, decoration-dashed, decoration-wavy
-
decoration-auto, decoration-from-font, decoration-0, decoration-1, decoration-2, decoration-4, decoration-8
-
underline-offset-auto, underline-offset-0, underline-offset-1, underline-offset-2, underline-offset-4, underline-offset-8
-
```
-
-
#### Text Transform
-
```
-
uppercase, lowercase, capitalize, normal-case
-
```
-
-
#### Text Overflow
-
```
-
truncate, text-ellipsis, text-clip
-
```
-
-
#### Text Shadow (NEW in v4)
-
```
-
text-shadow-sm, text-shadow, text-shadow-lg, text-shadow-xl, text-shadow-none
-
```
-
-
#### Overflow Wrap (NEW in v4)
-
```
-
overflow-wrap-normal, overflow-wrap-break-word, overflow-wrap-anywhere
-
```
-
-
#### Vertical Align
-
```
-
align-baseline, align-top, align-middle, align-bottom, align-text-top, align-text-bottom, align-sub, align-super
-
```
-
-
#### Whitespace
-
```
-
whitespace-normal, whitespace-nowrap, whitespace-pre, whitespace-pre-line, whitespace-pre-wrap, whitespace-break-spaces
-
```
-
-
#### Word Break
-
```
-
break-normal, break-words, break-all, break-keep
-
```
-
-
#### Hyphens
-
```
-
hyphens-none, hyphens-manual, hyphens-auto
-
```
-
-
#### Content
-
```
-
content-none
-
```
-
-
### Backgrounds
-
-
#### Background Attachment
-
```
-
bg-fixed, bg-local, bg-scroll
-
```
-
-
#### Background Clip
-
```
-
bg-clip-border, bg-clip-padding, bg-clip-content, bg-clip-text
-
```
-
-
#### Background Color
-
All color utilities work with `bg-` prefix (same as text colors above)
-
-
#### Background Origin
-
```
-
bg-origin-border, bg-origin-padding, bg-origin-content
-
```
-
-
#### Background Position
-
```
-
bg-bottom, bg-center, bg-left, bg-left-bottom, bg-left-top, bg-right, bg-right-bottom, bg-right-top, bg-top
-
```
-
-
#### Background Repeat
-
```
-
bg-repeat, bg-no-repeat, bg-repeat-x, bg-repeat-y, bg-repeat-round, bg-repeat-space
-
```
-
-
#### Background Size
-
```
-
bg-auto, bg-cover, bg-contain
-
```
-
-
#### Background Image
-
```
-
bg-none
-
bg-linear-to-t, bg-linear-to-tr, bg-linear-to-r, bg-linear-to-br, bg-linear-to-b, bg-linear-to-bl, bg-linear-to-l, bg-linear-to-tl
-
```
-
-
#### Enhanced Gradients (NEW in v4)
-
```
-
bg-linear-0, bg-linear-45, bg-linear-90, bg-linear-135, bg-linear-180, bg-linear-225, bg-linear-270, bg-linear-315
-
bg-radial, bg-radial-at-t, bg-radial-at-tr, bg-radial-at-r, bg-radial-at-br, bg-radial-at-b, bg-radial-at-bl, bg-radial-at-l, bg-radial-at-tl, bg-radial-at-c
-
bg-conic, bg-conic-at-t, bg-conic-at-tr, bg-conic-at-r, bg-conic-at-br, bg-conic-at-b, bg-conic-at-bl, bg-conic-at-l, bg-conic-at-tl, bg-conic-at-c
-
```
-
-
#### Gradient Color Stops
-
```
-
from-inherit, from-current, from-transparent, from-black, from-white, from-{color}
-
via-inherit, via-current, via-transparent, via-black, via-white, via-{color}
-
to-inherit, to-current, to-transparent, to-black, to-white, to-{color}
-
```
-
-
### Borders
-
-
#### Border Radius
-
```
-
rounded-none, rounded-xs, rounded-sm, rounded, rounded-md, rounded-lg, rounded-xl, rounded-2xl, rounded-3xl, rounded-full
-
rounded-s-none, rounded-s-xs, rounded-s-sm, rounded-s, rounded-s-md, rounded-s-lg, rounded-s-xl, rounded-s-2xl, rounded-s-3xl
-
rounded-e-none, rounded-e-xs, rounded-e-sm, rounded-e, rounded-e-md, rounded-e-lg, rounded-e-xl, rounded-e-2xl, rounded-e-3xl
-
rounded-t-none, rounded-t-xs, rounded-t-sm, rounded-t, rounded-t-md, rounded-t-lg, rounded-t-xl, rounded-t-2xl, rounded-t-3xl
-
rounded-r-none, rounded-r-xs, rounded-r-sm, rounded-r, rounded-r-md, rounded-r-lg, rounded-r-xl, rounded-r-2xl, rounded-r-3xl
-
rounded-b-none, rounded-b-xs, rounded-b-sm, rounded-b, rounded-b-md, rounded-b-lg, rounded-b-xl, rounded-b-2xl, rounded-b-3xl
-
rounded-l-none, rounded-l-xs, rounded-l-sm, rounded-l, rounded-l-md, rounded-l-lg, rounded-l-xl, rounded-l-2xl, rounded-l-3xl
-
rounded-ss-none, rounded-ss-xs, rounded-ss-sm, rounded-ss, rounded-ss-md, rounded-ss-lg, rounded-ss-xl, rounded-ss-2xl, rounded-ss-3xl
-
rounded-se-none, rounded-se-xs, rounded-se-sm, rounded-se, rounded-se-md, rounded-se-lg, rounded-se-xl, rounded-se-2xl, rounded-se-3xl
-
rounded-ee-none, rounded-ee-xs, rounded-ee-sm, rounded-ee, rounded-ee-md, rounded-ee-lg, rounded-ee-xl, rounded-ee-2xl, rounded-ee-3xl
-
rounded-es-none, rounded-es-xs, rounded-es-sm, rounded-es, rounded-es-md, rounded-es-lg, rounded-es-xl, rounded-es-2xl, rounded-es-3xl
-
rounded-tl-none, rounded-tl-xs, rounded-tl-sm, rounded-tl, rounded-tl-md, rounded-tl-lg, rounded-tl-xl, rounded-tl-2xl, rounded-tl-3xl
-
rounded-tr-none, rounded-tr-xs, rounded-tr-sm, rounded-tr, rounded-tr-md, rounded-tr-lg, rounded-tr-xl, rounded-tr-2xl, rounded-tr-3xl
-
rounded-br-none, rounded-br-xs, rounded-br-sm, rounded-br, rounded-br-md, rounded-br-lg, rounded-br-xl, rounded-br-2xl, rounded-br-3xl
-
rounded-bl-none, rounded-bl-xs, rounded-bl-sm, rounded-bl, rounded-bl-md, rounded-bl-lg, rounded-bl-xl, rounded-bl-2xl, rounded-bl-3xl
-
```
-
-
#### Border Width
-
```
-
border-0, border-2, border-4, border-8, border, border-x, border-y, border-s, border-e, border-t, border-r, border-b, border-l
-
```
-
-
#### Border Color
-
All color utilities work with `border-` prefix (same as text/bg colors)
-
-
#### Border Style
-
```
-
border-solid, border-dashed, border-dotted, border-double, border-hidden, border-none
-
```
-
-
#### Divide Width
-
```
-
divide-x-0, divide-x-2, divide-x-4, divide-x-8, divide-x, divide-y-0, divide-y-2, divide-y-4, divide-y-8, divide-y, divide-x-reverse, divide-y-reverse
-
```
-
-
#### Divide Color
-
All color utilities work with `divide-` prefix
-
-
#### Divide Style
-
```
-
divide-solid, divide-dashed, divide-dotted, divide-double, divide-none
-
```
-
-
#### Outline Width
-
```
-
outline-0, outline-1, outline-2, outline-4, outline-8
-
```
-
-
#### Outline Color
-
All color utilities work with `outline-` prefix
-
-
#### Outline Style
-
```
-
outline-none, outline, outline-dashed, outline-dotted, outline-double
-
```
-
-
#### Outline Offset
-
```
-
outline-offset-0, outline-offset-1, outline-offset-2, outline-offset-4, outline-offset-8
-
```
-
-
#### Ring Width
-
```
-
ring-0, ring-1, ring-2, ring, ring-4, ring-8, ring-inset
-
```
-
-
#### Ring Color
-
All color utilities work with `ring-` prefix
-
-
#### Ring Offset Width
-
```
-
ring-offset-0, ring-offset-1, ring-offset-2, ring-offset-4, ring-offset-8
-
```
-
-
#### Ring Offset Color
-
All color utilities work with `ring-offset-` prefix
-
-
### Effects
-
-
#### Box Shadow
-
```
-
shadow-xs, shadow-sm, shadow, shadow-md, shadow-lg, shadow-xl, shadow-2xl, shadow-inner, shadow-none
-
```
-
-
#### Box Shadow Color
-
All color utilities work with `shadow-` prefix
-
-
#### Drop Shadow (NEW colored support in v4)
-
```
-
drop-shadow-sm, drop-shadow, drop-shadow-md, drop-shadow-lg, drop-shadow-xl, drop-shadow-2xl, drop-shadow-none
-
```
-
-
#### Opacity
-
```
-
opacity-0, opacity-5, opacity-10, opacity-15, opacity-20, opacity-25, opacity-30, opacity-35, opacity-40, opacity-45, opacity-50, opacity-55, opacity-60, opacity-65, opacity-70, opacity-75, opacity-80, opacity-85, opacity-90, opacity-95, opacity-100
-
```
-
-
#### Mix Blend Mode
-
```
-
mix-blend-normal, mix-blend-multiply, mix-blend-screen, mix-blend-overlay, mix-blend-darken, mix-blend-lighten, mix-blend-color-dodge, mix-blend-color-burn, mix-blend-hard-light, mix-blend-soft-light, mix-blend-difference, mix-blend-exclusion, mix-blend-hue, mix-blend-saturation, mix-blend-color, mix-blend-luminosity, mix-blend-plus-darker, mix-blend-plus-lighter
-
```
-
-
#### Background Blend Mode
-
```
-
bg-blend-normal, bg-blend-multiply, bg-blend-screen, bg-blend-overlay, bg-blend-darken, bg-blend-lighten, bg-blend-color-dodge, bg-blend-color-burn, bg-blend-hard-light, bg-blend-soft-light, bg-blend-difference, bg-blend-exclusion, bg-blend-hue, bg-blend-saturation, bg-blend-color, bg-blend-luminosity
-
```
-
-
### Filters
-
-
#### Blur
-
```
-
blur-none, blur-xs, blur-sm, blur, blur-md, blur-lg, blur-xl, blur-2xl, blur-3xl
-
```
-
-
#### Brightness
-
```
-
brightness-0, brightness-50, brightness-75, brightness-90, brightness-95, brightness-100, brightness-105, brightness-110, brightness-125, brightness-150, brightness-200
-
```
-
-
#### Contrast
-
```
-
contrast-0, contrast-50, contrast-75, contrast-100, contrast-125, contrast-150, contrast-200
-
```
-
-
#### Grayscale
-
```
-
grayscale-0, grayscale
-
```
-
-
#### Hue Rotate
-
```
-
hue-rotate-0, hue-rotate-15, hue-rotate-30, hue-rotate-60, hue-rotate-90, hue-rotate-180, -hue-rotate-180, -hue-rotate-90, -hue-rotate-60, -hue-rotate-30, -hue-rotate-15
-
```
-
-
#### Invert
-
```
-
invert-0, invert
-
```
-
-
#### Saturate
-
```
-
saturate-0, saturate-50, saturate-100, saturate-150, saturate-200
-
```
-
-
#### Sepia
-
```
-
sepia-0, sepia
-
```
-
-
#### Backdrop Blur
-
```
-
backdrop-blur-none, backdrop-blur-xs, backdrop-blur-sm, backdrop-blur, backdrop-blur-md, backdrop-blur-lg, backdrop-blur-xl, backdrop-blur-2xl, backdrop-blur-3xl
-
```
-
-
#### Backdrop Brightness
-
```
-
backdrop-brightness-0, backdrop-brightness-50, backdrop-brightness-75, backdrop-brightness-90, backdrop-brightness-95, backdrop-brightness-100, backdrop-brightness-105, backdrop-brightness-110, backdrop-brightness-125, backdrop-brightness-150, backdrop-brightness-200
-
```
-
-
#### Backdrop Contrast
-
```
-
backdrop-contrast-0, backdrop-contrast-50, backdrop-contrast-75, backdrop-contrast-100, backdrop-contrast-125, backdrop-contrast-150, backdrop-contrast-200
-
```
-
-
#### Backdrop Grayscale
-
```
-
backdrop-grayscale-0, backdrop-grayscale
-
```
-
-
#### Backdrop Hue Rotate
-
```
-
backdrop-hue-rotate-0, backdrop-hue-rotate-15, backdrop-hue-rotate-30, backdrop-hue-rotate-60, backdrop-hue-rotate-90, backdrop-hue-rotate-180, -backdrop-hue-rotate-180, -backdrop-hue-rotate-90, -backdrop-hue-rotate-60, -backdrop-hue-rotate-30, -backdrop-hue-rotate-15
-
```
-
-
#### Backdrop Invert
-
```
-
backdrop-invert-0, backdrop-invert
-
```
-
-
#### Backdrop Saturate
-
```
-
backdrop-saturate-0, backdrop-saturate-50, backdrop-saturate-100, backdrop-saturate-150, backdrop-saturate-200
-
```
-
-
#### Backdrop Sepia
-
```
-
backdrop-sepia-0, backdrop-sepia
-
```
-
-
### Masks (NEW in v4)
-
-
#### Mask Image
-
```
-
mask-none
-
```
-
-
#### Mask Size
-
```
-
mask-auto, mask-cover, mask-contain
-
```
-
-
#### Mask Repeat
-
```
-
mask-repeat, mask-no-repeat, mask-repeat-x, mask-repeat-y, mask-repeat-round, mask-repeat-space
-
```
-
-
#### Mask Position
-
```
-
mask-bottom, mask-center, mask-left, mask-left-bottom, mask-left-top, mask-right, mask-right-bottom, mask-right-top, mask-top
-
```
-
-
#### Mask Origin
-
```
-
mask-origin-border, mask-origin-padding, mask-origin-content
-
```
-
-
#### Mask Clip
-
```
-
mask-clip-border, mask-clip-padding, mask-clip-content
-
```
-
-
#### Mask Composite
-
```
-
mask-composite-add, mask-composite-subtract, mask-composite-intersect, mask-composite-exclude
-
```
-
-
#### Mask Mode
-
```
-
mask-mode-match-source, mask-mode-luminance, mask-mode-alpha
-
```
-
-
#### Mask Type
-
```
-
mask-type-luminance, mask-type-alpha
-
```
-
-
### Tables
-
-
#### Border Collapse
-
```
-
border-collapse, border-separate
-
```
-
-
#### Border Spacing
-
```
-
border-spacing-0, border-spacing-px, border-spacing-0.5, border-spacing-1, border-spacing-1.5, border-spacing-2, border-spacing-2.5, border-spacing-3, border-spacing-3.5, border-spacing-4, border-spacing-5, border-spacing-6, border-spacing-7, border-spacing-8, border-spacing-9, border-spacing-10, border-spacing-11, border-spacing-12, border-spacing-14, border-spacing-16, border-spacing-20, border-spacing-24, border-spacing-28, border-spacing-32, border-spacing-36, border-spacing-40, border-spacing-44, border-spacing-48, border-spacing-52, border-spacing-56, border-spacing-60, border-spacing-64, border-spacing-72, border-spacing-80, border-spacing-96
-
border-spacing-x-0, border-spacing-y-0 (and all other spacing values)
-
```
-
-
#### Table Layout
-
```
-
table-auto, table-fixed
-
```
-
-
#### Caption Side
-
```
-
caption-top, caption-bottom
-
```
-
-
### Transforms
-
-
#### Scale
-
```
-
scale-0, scale-50, scale-75, scale-90, scale-95, scale-100, scale-105, scale-110, scale-125, scale-150
-
scale-x-0, scale-x-50, scale-x-75, scale-x-90, scale-x-95, scale-x-100, scale-x-105, scale-x-110, scale-x-125, scale-x-150
-
scale-y-0, scale-y-50, scale-y-75, scale-y-90, scale-y-95, scale-y-100, scale-y-105, scale-y-110, scale-y-125, scale-y-150
-
```
-
-
#### Scale Z (NEW in v4)
-
```
-
scale-z-0, scale-z-50, scale-z-75, scale-z-90, scale-z-95, scale-z-100, scale-z-105, scale-z-110, scale-z-125, scale-z-150
-
```
-
-
#### Rotate
-
```
-
rotate-0, rotate-1, rotate-2, rotate-3, rotate-6, rotate-12, rotate-45, rotate-90, rotate-180, -rotate-180, -rotate-90, -rotate-45, -rotate-12, -rotate-6, -rotate-3, -rotate-2, -rotate-1
-
```
-
-
#### Rotate X/Y (NEW in v4)
-
```
-
rotate-x-0, rotate-x-1, rotate-x-2, rotate-x-3, rotate-x-6, rotate-x-12, rotate-x-45, rotate-x-90, rotate-x-180, -rotate-x-180, -rotate-x-90, -rotate-x-45, -rotate-x-12, -rotate-x-6, -rotate-x-3, -rotate-x-2, -rotate-x-1
-
rotate-y-0, rotate-y-1, rotate-y-2, rotate-y-3, rotate-y-6, rotate-y-12, rotate-y-45, rotate-y-90, rotate-y-180, -rotate-y-180, -rotate-y-90, -rotate-y-45, -rotate-y-12, -rotate-y-6, -rotate-y-3, -rotate-y-2, -rotate-y-1
-
```
-
-
#### Translate
-
```
-
translate-x-0, translate-x-px, translate-x-0.5, translate-x-1, translate-x-1.5, translate-x-2, translate-x-2.5, translate-x-3, translate-x-3.5, translate-x-4, translate-x-5, translate-x-6, translate-x-7, translate-x-8, translate-x-9, translate-x-10, translate-x-11, translate-x-12, translate-x-14, translate-x-16, translate-x-20, translate-x-24, translate-x-28, translate-x-32, translate-x-36, translate-x-40, translate-x-44, translate-x-48, translate-x-52, translate-x-56, translate-x-60, translate-x-64, translate-x-72, translate-x-80, translate-x-96, translate-x-1/2, translate-x-1/3, translate-x-2/3, translate-x-1/4, translate-x-2/4, translate-x-3/4, translate-x-full
-
translate-y-0, translate-y-px, translate-y-0.5, translate-y-1, translate-y-1.5, translate-y-2, translate-y-2.5, translate-y-3, translate-y-3.5, translate-y-4, translate-y-5, translate-y-6, translate-y-7, translate-y-8, translate-y-9, translate-y-10, translate-y-11, translate-y-12, translate-y-14, translate-y-16, translate-y-20, translate-y-24, translate-y-28, translate-y-32, translate-y-36, translate-y-40, translate-y-44, translate-y-48, translate-y-52, translate-y-56, translate-y-60, translate-y-64, translate-y-72, translate-y-80, translate-y-96, translate-y-1/2, translate-y-1/3, translate-y-2/3, translate-y-1/4, translate-y-2/4, translate-y-3/4, translate-y-full
-
```
-
-
#### Translate Z (NEW in v4)
-
```
-
translate-z-0, translate-z-px, translate-z-0.5, translate-z-1, translate-z-1.5, translate-z-2, translate-z-2.5, translate-z-3, translate-z-3.5, translate-z-4, translate-z-5, translate-z-6, translate-z-7, translate-z-8, translate-z-9, translate-z-10, translate-z-11, translate-z-12, translate-z-14, translate-z-16, translate-z-20, translate-z-24, translate-z-28, translate-z-32, translate-z-36, translate-z-40, translate-z-44, translate-z-48, translate-z-52, translate-z-56, translate-z-60, translate-z-64, translate-z-72, translate-z-80, translate-z-96
-
```
-
-
#### Skew
-
```
-
skew-x-0, skew-x-1, skew-x-2, skew-x-3, skew-x-6, skew-x-12, -skew-x-12, -skew-x-6, -skew-x-3, -skew-x-2, -skew-x-1
-
skew-y-0, skew-y-1, skew-y-2, skew-y-3, skew-y-6, skew-y-12, -skew-y-12, -skew-y-6, -skew-y-3, -skew-y-2, -skew-y-1
-
```
-
-
#### Transform Origin
-
```
-
origin-center, origin-top, origin-top-right, origin-right, origin-bottom-right, origin-bottom, origin-bottom-left, origin-left, origin-top-left
-
```
-
-
#### Transform Style (NEW in v4)
-
```
-
transform-style-flat, transform-style-preserve-3d
-
```
-
-
#### Perspective (NEW in v4)
-
```
-
perspective-none, perspective-250, perspective-500, perspective-750, perspective-1000, perspective-distant
-
```
-
-
#### Perspective Origin (NEW in v4)
-
```
-
perspective-origin-center, perspective-origin-top, perspective-origin-top-right, perspective-origin-right, perspective-origin-bottom-right, perspective-origin-bottom, perspective-origin-bottom-left, perspective-origin-left, perspective-origin-top-left
-
```
-
-
### Interactivity
-
-
#### Accent Color
-
```
-
accent-auto, accent-inherit, accent-current, accent-transparent, accent-black, accent-white
-
accent-{color} (all color utilities work with accent- prefix)
-
```
-
-
#### Appearance
-
```
-
appearance-none, appearance-auto
-
```
-
-
#### Cursor
-
```
-
cursor-auto, cursor-default, cursor-pointer, cursor-wait, cursor-text, cursor-move, cursor-help, cursor-not-allowed, cursor-none, cursor-context-menu, cursor-progress, cursor-cell, cursor-crosshair, cursor-vertical-text, cursor-alias, cursor-copy, cursor-no-drop, cursor-grab, cursor-grabbing, cursor-all-scroll, cursor-col-resize, cursor-row-resize, cursor-n-resize, cursor-e-resize, cursor-s-resize, cursor-w-resize, cursor-ne-resize, cursor-nw-resize, cursor-se-resize, cursor-sw-resize, cursor-ew-resize, cursor-ns-resize, cursor-nesw-resize, cursor-nwse-resize, cursor-zoom-in, cursor-zoom-out
-
```
-
-
#### Caret Color
-
All color utilities work with `caret-` prefix
-
-
#### Pointer Events
-
```
-
pointer-events-none, pointer-events-auto
-
```
-
-
#### Resize
-
```
-
resize-none, resize, resize-y, resize-x
-
```
-
-
#### Scroll Behavior
-
```
-
scroll-auto, scroll-smooth
-
```
-
-
#### Scroll Margin
-
```
-
scroll-m-0, scroll-m-px, scroll-m-0.5, scroll-m-1, scroll-m-1.5, scroll-m-2, scroll-m-2.5, scroll-m-3, scroll-m-3.5, scroll-m-4, scroll-m-5, scroll-m-6, scroll-m-7, scroll-m-8, scroll-m-9, scroll-m-10, scroll-m-11, scroll-m-12, scroll-m-14, scroll-m-16, scroll-m-20, scroll-m-24, scroll-m-28, scroll-m-32, scroll-m-36, scroll-m-40, scroll-m-44, scroll-m-48, scroll-m-52, scroll-m-56, scroll-m-60, scroll-m-64, scroll-m-72, scroll-m-80, scroll-m-96
-
scroll-mx-0, scroll-my-0, scroll-ms-0, scroll-me-0, scroll-mt-0, scroll-mr-0, scroll-mb-0, scroll-ml-0 (and all spacing values)
-
```
-
-
#### Scroll Padding
-
```
-
scroll-p-0, scroll-p-px, scroll-p-0.5, scroll-p-1, scroll-p-1.5, scroll-p-2, scroll-p-2.5, scroll-p-3, scroll-p-3.5, scroll-p-4, scroll-p-5, scroll-p-6, scroll-p-7, scroll-p-8, scroll-p-9, scroll-p-10, scroll-p-11, scroll-p-12, scroll-p-14, scroll-p-16, scroll-p-20, scroll-p-24, scroll-p-28, scroll-p-32, scroll-p-36, scroll-p-40, scroll-p-44, scroll-p-48, scroll-p-52, scroll-p-56, scroll-p-60, scroll-p-64, scroll-p-72, scroll-p-80, scroll-p-96
-
scroll-px-0, scroll-py-0, scroll-ps-0, scroll-pe-0, scroll-pt-0, scroll-pr-0, scroll-pb-0, scroll-pl-0 (and all spacing values)
-
```
-
-
#### Scroll Snap Align
-
```
-
snap-start, snap-end, snap-center, snap-align-none
-
```
-
-
#### Scroll Snap Stop
-
```
-
snap-normal, snap-always
-
```
-
-
#### Scroll Snap Type
-
```
-
snap-none, snap-x, snap-y, snap-both, snap-mandatory, snap-proximity
-
```
-
-
#### Touch Action
-
```
-
touch-auto, touch-none, touch-pan-x, touch-pan-left, touch-pan-right, touch-pan-y, touch-pan-up, touch-pan-down, touch-pinch-zoom, touch-manipulation
-
```
-
-
#### User Select
-
```
-
select-none, select-text, select-all, select-auto
-
```
-
-
#### Will Change
-
```
-
will-change-auto, will-change-scroll, will-change-contents, will-change-transform
-
```
-
-
### SVG
-
-
#### Fill
-
```
-
fill-none, fill-inherit, fill-current, fill-transparent, fill-black, fill-white
-
fill-{color} (all color utilities work with fill- prefix)
-
```
-
-
#### Stroke
-
```
-
stroke-none, stroke-inherit, stroke-current, stroke-transparent, stroke-black, stroke-white
-
stroke-{color} (all color utilities work with stroke- prefix)
-
```
-
-
#### Stroke Width
-
```
-
stroke-0, stroke-1, stroke-2
-
```
-
-
### Accessibility
-
-
#### Screen Readers
-
```
-
sr-only, not-sr-only
-
```
-
-
#### Forced Color Adjust
-
```
-
forced-color-adjust-auto, forced-color-adjust-none
-
```
-
-
### Container Queries (NEW in v4)
-
-
#### Container Type
-
```
-
@container, @container-normal, @container-size, @container-inline-size
-
```
-
-
#### Container Query Variants
-
```
-
@xs:, @sm:, @md:, @lg:, @xl:, @2xl:, @3xl:, @4xl:, @5xl:, @6xl:, @7xl:
-
@min-w-0:, @min-w-xs:, @min-w-sm:, @min-w-md:, @min-w-lg:, @min-w-xl:, @min-w-2xl:, @min-w-3xl:, @min-w-4xl:, @min-w-5xl:, @min-w-6xl:, @min-w-7xl:
-
@max-w-xs:, @max-w-sm:, @max-w-md:, @max-w-lg:, @max-w-xl:, @max-w-2xl:, @max-w-3xl:, @max-w-4xl:, @max-w-5xl:, @max-w-6xl:, @max-w-7xl:
-
@min-h-0:, @min-h-xs:, @min-h-sm:, @min-h-md:, @min-h-lg:, @min-h-xl:, @min-h-2xl:, @min-h-3xl:, @min-h-4xl:, @min-h-5xl:, @min-h-6xl:, @min-h-7xl:
-
@max-h-xs:, @max-h-sm:, @max-h-md:, @max-h-lg:, @max-h-xl:, @max-h-2xl:, @max-h-3xl:, @max-h-4xl:, @max-h-5xl:, @max-h-6xl:, @max-h-7xl:
-
```
-
-
### Responsive Design
-
-
#### Breakpoint Variants
-
```
-
sm:, md:, lg:, xl:, 2xl:
-
max-sm:, max-md:, max-lg:, max-xl:, max-2xl:
-
```
-
-
### State Variants
-
-
#### Hover, Focus, etc.
-
```
-
hover:, focus:, focus-within:, focus-visible:, active:, visited:, target:, disabled:, enabled:, checked:, indeterminate:, default:, required:, valid:, invalid:, in-range:, out-of-range:, placeholder-shown:, autofill:, read-only:
-
```
-
-
#### Group States
-
```
-
group-hover:, group-focus:, group-focus-within:, group-focus-visible:, group-active:, group-visited:, group-target:, group-disabled:, group-enabled:, group-checked:, group-indeterminate:, group-default:, group-required:, group-valid:, group-invalid:, group-in-range:, group-out-of-range:, group-placeholder-shown:, group-autofill:, group-read-only:
-
```
-
-
#### Peer States
-
```
-
peer-hover:, peer-focus:, peer-focus-within:, peer-focus-visible:, peer-active:, peer-visited:, peer-target:, peer-disabled:, peer-enabled:, peer-checked:, peer-indeterminate:, peer-default:, peer-required:, peer-valid:, peer-invalid:, peer-in-range:, peer-out-of-range:, peer-placeholder-shown:, peer-autofill:, peer-read-only:
-
```
-
-
#### NEW Variants in v4
-
```
-
@starting-style:, not-*, nth-*, in-*, inert:, open: (for popovers)
-
```
-
-
### Media Queries
-
-
#### Dark Mode
-
```
-
dark:
-
```
-
-
#### Motion
-
```
-
motion-safe:, motion-reduce:
-
```
-
-
#### Contrast
-
```
-
contrast-more:, contrast-less:
-
```
-
-
#### Print
-
```
-
print:
-
```
-
-
#### Orientation
-
```
-
portrait:, landscape:
-
```
-
-
### Content
-
```
-
content-none, content-['text']
-
```
-
-
### Arbitrary Values
-
You can use arbitrary values with square brackets for any property:
-
```
-
w-[123px], h-[456px], text-[#bada55], bg-[url('...')], top-[117px], left-[344px]
-
m-[12px], p-[24px], grid-cols-[200px_minmax(900px,_1fr)_100px]
-
```
-
-
### Arbitrary Properties
-
```
-
[mask-type:luminance], [tab-size:4], [@supports(backdrop-filter:blur(0))]:bg-white/75
-
```
-
-
### Arbitrary Variants
-
```
-
[&:nth-child(3)]:, [&:hover]:, [&_p]:, [@media(min-width:600px)]:
-
[@supports(backdrop-filter:blur(0))]:, [data-theme="dark"]:
-
```
-
-
## Common v4 Pitfalls to Avoid
-
-
### Don't Use These Deprecated Patterns
-
- โŒ `@tailwind base; @tailwind components; @tailwind utilities;`
-
- โŒ `text-opacity-50` โ†’ Use `text-white/50` instead
-
- โŒ `bg-opacity-25` โ†’ Use `bg-blue-500/25` instead
-
- โŒ `border` without color (now uses currentColor, not gray-200)
-
- โŒ `ring` without explicit width (now 1px, was 3px)
-
- โŒ `@layer utilities` โ†’ Use `@utility` instead
-
- โŒ JavaScript config for new projects โ†’ Use CSS `@theme`
-
-
### Modern v4 Alternatives
-
- โœ… `@import "tailwindcss";`
-
- โœ… `text-white/50` for semi-transparent text
-
- โœ… `bg-blue-500/25` for semi-transparent backgrounds
-
- โœ… `border border-gray-200` for explicit border color
-
- โœ… `ring-3` for 3px ring width
-
- โœ… `@utility` for custom utilities
-
- โœ… `@theme` for configuration
-
-
## Performance Best Practices
-
-
### Leverage v4's Performance Features
-
- Use automatic content detection (no manual `content` config needed)
-
- Prefer container queries over viewport queries for true component responsiveness
-
- Use CSS variables from `@theme` for dynamic styling
-
- Leverage the new OKLCH color system for better color consistency
-
-
### Efficient Class Usage
-
```html
-
<!-- Good: Use size-* for square elements -->
-
<div class="size-12"></div>
-
-
<!-- Instead of: -->
-
<div class="w-12 h-12"></div>
-
-
<!-- Good: Use container queries for component responsiveness -->
-
<div class="@container">
-
<div class="p-4 @lg:p-8">Content</div>
-
</div>
-
-
<!-- Good: Use CSS variables for dynamic values -->
-
<div class="bg-[var(--theme-primary)] text-[var(--theme-on-primary)]">
-
Dynamic theming
-
</div>
-
```
-
-
## Framework Integration
-
-
### Svelte 5
-
```svelte
-
<script>
-
let { variant = "primary", children } = $props();
-
-
const buttonClasses = $derived(() => [
-
'px-4 py-2 rounded-md font-medium transition-colors',
-
variant === 'primary'
-
? 'bg-brand text-white hover:bg-brand/90'
-
: 'bg-gray-100 text-gray-900 hover:bg-gray-200'
-
].join(' '));
-
</script>
-
-
<button class={buttonClasses}>
-
{@render children()}
-
</button>
-
-
<style>
-
@import "tailwindcss";
-
-
@theme {
-
--color-brand: oklch(0.5 0.2 240);
-
}
-
</style>
-
```
-
-
## Debugging & Development
-
-
### Browser DevTools Tips
-
1. **Inspect CSS Variables**: Check `:root` in DevTools to see all theme variables
-
2. **Check Cascade Layers**: Use the Layers panel to understand style precedence
-
3. **Verify OKLCH Support**: Test colors in modern browsers vs fallbacks
-
4. **Container Query Debugging**: Use the @container panel in DevTools
-
-
### Common Debug Commands
-
```bash
-
# Check if utilities are being generated
-
npx tailwindcss --watch --content "./src/**/*.{html,js,jsx,ts,tsx}"
-
-
# Verify v4 installation
-
npm list tailwindcss
-
-
# Check for conflicting PostCSS plugins
-
npm list | grep postcss
-
```
-
-
### VS Code Extensions
-
- Tailwind CSS IntelliSense (updated for v4)
-
- PostCSS Language Support
-
-
## v3 to v4 Migration Checklist
-
-
### Pre-Migration
-
- [ ] Backup your project
-
- [ ] Ensure Node.js 20+ is installed
-
- [ ] Check browser support requirements (Safari 16.4+, Chrome 111+, Firefox 128+)
-
-
### Automated Migration
-
```bash
-
npx @tailwindcss/upgrade@next
-
```
-
-
### Manual Verification
-
- [ ] Replace `@tailwind` directives with `@import "tailwindcss"`
-
- [ ] Move `tailwind.config.js` content to CSS `@theme`
-
- [ ] Update deprecated utility classes
-
- [ ] Test container queries functionality
-
- [ ] Verify custom component styles
-
- [ ] Check 3D transform support
-
- [ ] Test mask utilities if used
-
- [ ] Validate color consistency (OKLCH vs RGB)
-
-
### Testing
-
- [ ] Test in all target browsers
-
- [ ] Verify responsive design still works
-
- [ ] Check dark mode functionality
-
- [ ] Test custom animations
-
- [ ] Validate accessibility features
-
-
## Production-Ready Component Patterns
-
-
### Modern Card Component
-
```html
-
<div class="@container group">
-
<article class="
-
bg-white dark:bg-gray-900
-
rounded-xl shadow-sm border border-gray-200 dark:border-gray-800
-
overflow-hidden transition-all duration-200
-
hover:shadow-md hover:-translate-y-0.5
-
@sm:flex @sm:items-center
-
">
-
<div class="@sm:flex-shrink-0">
-
<img class="h-48 w-full object-cover @sm:h-full @sm:w-48" src="..." alt="...">
-
</div>
-
<div class="p-6 @sm:p-8">
-
<h3 class="text-lg font-semibold text-gray-900 dark:text-white @lg:text-xl">
-
Card Title
-
</h3>
-
<p class="mt-2 text-gray-600 dark:text-gray-300 @lg:text-lg">
-
Card description that adapts to container size.
-
</p>
-
</div>
-
</article>
-
</div>
-
```
-
-
### 3D Interactive Button
-
```html
-
<button class="
-
relative px-6 py-3 bg-blue-600 text-white font-medium rounded-lg
-
transform-3d perspective-1000
-
transition-all duration-200
-
hover:rotate-x-12 hover:scale-105 hover:shadow-xl
-
active:scale-95 active:rotate-x-6
-
focus:outline-none focus:ring-2 focus:ring-blue-500/50
-
">
-
3D Button
-
</button>
-
```
-
-
Remember: Tailwind CSS v4 is designed for modern browsers and modern development workflows. Embrace the new CSS-first approach and leverage the powerful new features for better performance and developer experience.
+6 -10
tailwind.opam
···
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
synopsis: "Type-safe Tailwind CSS generation for OCaml"
-
description:
-
"A comprehensive OCaml library for generating Tailwind CSS classes with full type safety"
-
maintainer: ["Your Name"]
-
authors: ["Your Name"]
-
license: "MIT"
-
homepage: "https://github.com/yourusername/tailwind-ocaml"
-
doc: "https://yourusername.github.io/tailwind-ocaml/"
-
bug-reports: "https://github.com/yourusername/tailwind-ocaml/issues"
+
description: "Library for generating Tailwind CSS classes"
+
maintainer: ["Anil Madhavapeddy"]
+
authors: ["Anil Madhavapeddy"]
+
license: "ISC"
depends: [
+
"dune" {>= "3.18"}
"ocaml"
-
"dune" {>= "3.0" & >= "3.0"}
"alcotest" {with-test}
"qcheck" {with-test}
"odoc" {with-doc}
···
"@doc" {with-doc}
]
]
-
dev-repo: "git+https://github.com/yourusername/tailwind-ocaml.git"
+
x-maintenance-intent: ["(latest)"]