Build reusable, accessible UI components with Tailwind CSS for Google Antigravity projects.
# Tailwind UI Component Library for Google Antigravity
Tailwind CSS enables rapid UI development with utility-first styling. Google Antigravity's Gemini 3 helps you create consistent, accessible components with intelligent class suggestions and design system integration.
## Design Token Configuration
Start with a well-structured Tailwind configuration:
```typescript
// tailwind.config.ts
import type { Config } from "tailwindcss";
const config: Config = {
content: [
"./src/**/*.{js,ts,jsx,tsx,mdx}",
],
theme: {
extend: {
colors: {
primary: {
50: "#f0f9ff",
100: "#e0f2fe",
200: "#bae6fd",
300: "#7dd3fc",
400: "#38bdf8",
500: "#0ea5e9",
600: "#0284c7",
700: "#0369a1",
800: "#075985",
900: "#0c4a6e",
950: "#082f49",
},
neutral: {
50: "#fafafa",
100: "#f5f5f5",
200: "#e5e5e5",
300: "#d4d4d4",
400: "#a3a3a3",
500: "#737373",
600: "#525252",
700: "#404040",
800: "#262626",
900: "#171717",
950: "#0a0a0a",
},
},
fontFamily: {
sans: ["var(--font-inter)", "system-ui", "sans-serif"],
mono: ["var(--font-mono)", "Consolas", "monospace"],
},
spacing: {
"4.5": "1.125rem",
"5.5": "1.375rem",
},
borderRadius: {
"4xl": "2rem",
},
animation: {
"fade-in": "fadeIn 0.2s ease-out",
"slide-up": "slideUp 0.3s ease-out",
"spin-slow": "spin 3s linear infinite",
},
keyframes: {
fadeIn: {
"0%": { opacity: "0" },
"100%": { opacity: "1" },
},
slideUp: {
"0%": { transform: "translateY(10px)", opacity: "0" },
"100%": { transform: "translateY(0)", opacity: "1" },
},
},
},
},
plugins: [
require("@tailwindcss/forms"),
require("@tailwindcss/typography"),
],
};
export default config;
```
## Button Component
Create a flexible, accessible button:
```typescript
// components/ui/Button.tsx
import { forwardRef, ButtonHTMLAttributes } from "react";
import { cn } from "@/lib/utils";
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
variant?: "primary" | "secondary" | "outline" | "ghost" | "danger";
size?: "sm" | "md" | "lg";
isLoading?: boolean;
}
const Button = forwardRef<HTMLButtonElement, ButtonProps>(
(
{
className,
variant = "primary",
size = "md",
isLoading = false,
disabled,
children,
...props
},
ref
) => {
const baseStyles = "inline-flex items-center justify-center font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50";
const variants = {
primary: "bg-primary-600 text-white hover:bg-primary-700 focus-visible:ring-primary-500",
secondary: "bg-neutral-100 text-neutral-900 hover:bg-neutral-200 focus-visible:ring-neutral-500",
outline: "border border-neutral-300 bg-transparent hover:bg-neutral-100 focus-visible:ring-neutral-500",
ghost: "bg-transparent hover:bg-neutral-100 focus-visible:ring-neutral-500",
danger: "bg-red-600 text-white hover:bg-red-700 focus-visible:ring-red-500",
};
const sizes = {
sm: "h-8 px-3 text-sm rounded-md",
md: "h-10 px-4 text-sm rounded-lg",
lg: "h-12 px-6 text-base rounded-lg",
};
return (
<button
ref={ref}
className={cn(baseStyles, variants[variant], sizes[size], className)}
disabled={disabled || isLoading}
{...props}
>
{isLoading && (
<svg
className="mr-2 h-4 w-4 animate-spin"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
>
<circle
className="opacity-25"
cx="12"
cy="12"
r="10"
stroke="currentColor"
strokeWidth="4"
/>
<path
className="opacity-75"
fill="currentColor"
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"
/>
</svg>
)}
{children}
</button>
);
}
);
Button.displayName = "Button";
export { Button };
```
## Input Component
Build accessible form inputs:
```typescript
// components/ui/Input.tsx
import { forwardRef, InputHTMLAttributes } from "react";
import { cn } from "@/lib/utils";
interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
label?: string;
error?: string;
hint?: string;
}
const Input = forwardRef<HTMLInputElement, InputProps>(
({ className, label, error, hint, id, ...props }, ref) => {
const inputId = id || props.name;
return (
<div className="space-y-1.5">
{label && (
<label
htmlFor={inputId}
className="block text-sm font-medium text-neutral-700"
>
{label}
{props.required && <span className="text-red-500 ml-1">*</span>}
</label>
)}
<input
ref={ref}
id={inputId}
className={cn(
"block w-full rounded-lg border px-3 py-2 text-sm",
"placeholder:text-neutral-400",
"focus:outline-none focus:ring-2 focus:ring-offset-0",
"disabled:cursor-not-allowed disabled:bg-neutral-50 disabled:text-neutral-500",
error
? "border-red-500 focus:border-red-500 focus:ring-red-200"
: "border-neutral-300 focus:border-primary-500 focus:ring-primary-200",
className
)}
aria-invalid={error ? "true" : "false"}
aria-describedby={
error ? `${inputId}-error` : hint ? `${inputId}-hint` : undefined
}
{...props}
/>
{error && (
<p id={`${inputId}-error`} className="text-sm text-red-600">
{error}
</p>
)}
{hint && !error && (
<p id={`${inputId}-hint`} className="text-sm text-neutral-500">
{hint}
</p>
)}
</div>
);
}
);
Input.displayName = "Input";
export { Input };
```
## Card Component
Create flexible card layouts:
```typescript
// components/ui/Card.tsx
import { HTMLAttributes, forwardRef } from "react";
import { cn } from "@/lib/utils";
interface CardProps extends HTMLAttributes<HTMLDivElement> {
variant?: "default" | "outlined" | "elevated";
padding?: "none" | "sm" | "md" | "lg";
}
const Card = forwardRef<HTMLDivElement, CardProps>(
({ className, variant = "default", padding = "md", children, ...props }, ref) => {
const variants = {
default: "bg-white border border-neutral-200",
outlined: "bg-transparent border-2 border-neutral-300",
elevated: "bg-white shadow-lg border-0",
};
const paddings = {
none: "",
sm: "p-3",
md: "p-4 sm:p-6",
lg: "p-6 sm:p-8",
};
return (
<div
ref={ref}
className={cn(
"rounded-xl",
variants[variant],
paddings[padding],
className
)}
{...props}
>
{children}
</div>
);
}
);
Card.displayName = "Card";
const CardHeader = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => (
<div
ref={ref}
className={cn("flex flex-col space-y-1.5", className)}
{...props}
/>
)
);
CardHeader.displayName = "CardHeader";
const CardTitle = forwardRef<HTMLHeadingElement, HTMLAttributes<HTMLHeadingElement>>(
({ className, ...props }, ref) => (
<h3
ref={ref}
className={cn("text-lg font-semibold text-neutral-900", className)}
{...props}
/>
)
);
CardTitle.displayName = "CardTitle";
const CardContent = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => (
<div ref={ref} className={cn("text-neutral-600", className)} {...props} />
)
);
CardContent.displayName = "CardContent";
export { Card, CardHeader, CardTitle, CardContent };
```
## Modal Component
Build accessible modals with focus trap:
```typescript
// components/ui/Modal.tsx
"use client";
import { useEffect, useRef } from "react";
import { createPortal } from "react-dom";
import { cn } from "@/lib/utils";
interface ModalProps {
isOpen: boolean;
onClose: () => void;
title?: string;
children: React.ReactNode;
size?: "sm" | "md" | "lg" | "xl";
}
export function Modal({ isOpen, onClose, title, children, size = "md" }: ModalProps) {
const overlayRef = useRef<HTMLDivElement>(null);
const contentRef = useRef<HTMLDivElement>(null);
useEffect(() => {
if (isOpen) {
document.body.style.overflow = "hidden";
contentRef.current?.focus();
}
return () => {
document.body.style.overflow = "";
};
}, [isOpen]);
useEffect(() => {
const handleEscape = (e: KeyboardEvent) => {
if (e.key === "Escape") onClose();
};
document.addEventListener("keydown", handleEscape);
return () => document.removeEventListener("keydown", handleEscape);
}, [onClose]);
if (!isOpen) return null;
const sizes = {
sm: "max-w-sm",
md: "max-w-md",
lg: "max-w-lg",
xl: "max-w-xl",
};
return createPortal(
<div
ref={overlayRef}
className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 animate-fade-in"
onClick={(e) => e.target === overlayRef.current && onClose()}
>
<div
ref={contentRef}
role="dialog"
aria-modal="true"
aria-labelledby={title ? "modal-title" : undefined}
tabIndex={-1}
className={cn(
"w-full bg-white rounded-xl shadow-xl animate-slide-up",
sizes[size]
)}
>
{title && (
<div className="flex items-center justify-between p-4 border-b">
<h2 id="modal-title" className="text-lg font-semibold">
{title}
</h2>
<button
onClick={onClose}
className="p-1 rounded-lg hover:bg-neutral-100"
aria-label="Close modal"
>
X
</button>
</div>
)}
<div className="p-4">{children}</div>
</div>
</div>,
document.body
);
}
```
## Best Practices
1. **Use design tokens** - Define colors, spacing, and typography in config
2. **Create compound components** - Build flexible, composable UI pieces
3. **Implement accessibility** - Add ARIA attributes and keyboard navigation
4. **Use cn utility** - Merge Tailwind classes conditionally
5. **Add animation states** - Include loading, hover, and focus states
Tailwind with Google Antigravity enables rapid UI development with intelligent styling suggestions and accessibility patterns.This tailwind prompt is ideal for developers working on:
By using this prompt, you can save hours of manual coding and ensure best practices are followed from the start. It's particularly valuable for teams looking to maintain consistency across their tailwind implementations.
Yes! All prompts on Antigravity AI Directory are free to use for both personal and commercial projects. No attribution required, though it's always appreciated.
This prompt works excellently with Claude, ChatGPT, Cursor, GitHub Copilot, and other modern AI coding assistants. For best results, use models with large context windows.
You can modify the prompt by adding specific requirements, constraints, or preferences. For tailwind projects, consider mentioning your framework version, coding style, and any specific libraries you're using.