# Starwind UI - AI Reference Guide
> Starwind UI is an open-source component library for Astro projects, styled with Tailwind CSS v4. It provides accessible, customizable components that can be added directly to your projects. The library follows a modular approach where components are added individually to your project via a CLI rather than imported from a package.
## Installation
### Prerequisites
- Astro project
- Tailwind CSS v4
- Node.js
### Setup with CLI (Recommended)
1. Create or use an existing Astro project
2. Configure path aliases in tsconfig.json:
```json
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
}
}
}
```
3. If using pnpm, create a .npmrc file:
```
auto-install-peers=true
node-linker=hoisted
lockfile=true
```
4. Run the CLI to initialize:
```bash
pnpx starwind@latest init
# or
npx starwind@latest init
# or
yarn dlx starwind@latest init
```
5. Import the CSS in your layout:
```astro
---
import "@/styles/starwind.css";
---
```
6. Add components as needed:
```bash
npx starwind@latest add button
```
## Component Usage Pattern
All Starwind components follow a consistent pattern:
1. **Import the components**:
```astro
---
import { ComponentName } from "@/components/starwind/component-name";
---
```
2. **Use the components in your templates**:
```astro
Content
```
## Available Components
Starwind UI includes the following components:
- Accordion
- Alert
- Avatar
- Badge
- Button
- Card
- Checkbox
- Dialog
- Input
- Label
- Pagination
- Select
- Switch
- Tabs
- Textarea
- Tooltip
## Component Architecture Patterns
Most components follow a compound component pattern, where a parent component provides context to specialized child components:
### Example: Tooltip
```astro
Add to library
```
### Example: Pagination
```astro
Prev
1
2
3
Next
```
## Common Props and Patterns
### Variant Props
Many components support variant props that change their visual appearance:
- `variant="default"` (usually the default)
- `variant="primary"`
- `variant="secondary"`
- `variant="outline"`
- `variant="ghost"`
- `variant="info"`
- `variant="success"`
- `variant="warning"`
- `variant="error"`
### Size Props
Many components support size props:
- `size="sm"`
- `size="md"` (usually the default)
- `size="lg"`
### CSS Variables
Starwind UI uses CSS variables for theming. Key variables include:
**Base**
- `--background`: Default background color
- `--foreground`: Default text color
**Component Colors**
- `--primary` / `--primary-foreground`: Primary action colors
- `--secondary` / `--secondary-foreground`: Secondary action colors
- `--muted` / `--muted-foreground`: Muted UI elements
- `--accent` / `--accent-foreground`: Accent elements like hover states
- `--card` / `--card-foreground`: Card component colors
- `--popover` / `--popover-foreground`: Popover component colors
- `--info` / `--info-foreground`: Information messaging colors
- `--success` / `--success-foreground`: Success messaging colors
- `--warning` / `--warning-foreground`: Warning messaging colors
- `--error` / `--error-foreground`: Error messaging colors
**Utilities**
- `--border`: Border color
- `--input`: Input component border color
- `--outline`: Focus outline color
- `--radius`: Base border radius
### Dark Mode Support
Starwind supports dark mode via a `.dark` class, which changes the CSS variables.
## Command Line Interface
### Initialize Project
```bash
npx starwind@latest init
```
### Add Components
```bash
npx starwind@latest add button card dialog
```
### Update Components
```bash
npx starwind@latest update button
```
### Remove Components
```bash
npx starwind@latest remove button
```
## Best Practices
1. **Accessibility**: Starwind components are built with accessibility in mind. Maintain ARIA attributes and keyboard navigation when customizing.
2. **Compound Components**: Use the compound component pattern (parent + specialized children) when appropriate.
3. **Consistent Importing**: Always import from `@/components/starwind/component-name` to maintain consistency.
4. **Tailwind Integration**: Starwind is designed to work with Tailwind CSS v4, leveraging its utility classes and design tokens.
5. **Theming**: Use the CSS variables system for consistent theming rather than direct color references.
## Detailed Component Reference
### Accordion
- **Documentation**: https://starwind.dev/docs/components
- **Import pattern**: `import { Accordion, AccordionItem, AccordionTrigger, AccordionContent } from "@/components/starwind/accordion";`
- **Key props**:
- `type`: "single" | "multiple" (default: "single")
- `defaultValue`: string - Value of the item that should be open by default
- **Example usage**:
```astro
---
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "@/components/starwind/accordion";
---
What is Astro?
Astro is an web framework for building fast, scalable, and secure websites.
Why should I use Astro?
Astro provides a set of features that make it an ideal choice for building fast,
scalable, and secure websites.
How do I get started with Astro?
To get started with Astro, follow the instructions in the documentation.
```
### Alert
- **Documentation**: https://starwind.dev/docs/components/alert
- **Import pattern**: `import { Alert, AlertTitle, AlertDescription } from "@/components/starwind/alert";`
- **Key props**:
- `variant`: "default" | "primary" | "secondary" | "info" | "success" | "warning" | "error" (default: "default")
- **Example usage**:
```astro
---
import { Alert, AlertDescription, AlertTitle } from "@/components/starwind/alert";
---
Heads up!
A simple alert with an "AlertTitle" and an
"AlertDescription".
```
### Avatar
- **Documentation**: https://starwind.dev/docs/components/avatar
- **Import pattern**: `import { Avatar, AvatarImage, AvatarFallback } from "@/components/starwind/avatar";`
- **Key props**:
- `variant`: "default" | "primary" | "secondary" | "info" | "success" | "warning" | "error" (default: "default")
- `size`: "sm" | "md" | "lg" (default: "md")
- **Example usage**:
```astro
---
import { Avatar, AvatarImage, AvatarFallback } from "@/components/starwind/avatar";
---
JD
```
### Badge
- **Documentation**: https://starwind.dev/docs/components/badge
- **Import pattern**: `import { Badge } from "@/components/starwind/badge";`
- **Key props**:
- `variant`: "default" | "primary" | "secondary" | "outline" | "ghost" | "info" | "success" | "warning" | "error" (default: "default")
- `size`: "sm" | "md" | "lg" (default: "md")
- **Example usage**:
```astro
---
import { Badge } from "@/components/starwind/badge";
---
New
```
### Button
- **Documentation**: https://starwind.dev/docs/components/button
- **Import pattern**: `import { Button } from "@/components/starwind/button";`
- **Key props**:
- `variant`: "default" | "primary" | "secondary" | "outline" | "ghost" | "info" | "success" | "warning" | "error" (default: "default")
- `size`: "sm" | "md" | "lg" | "icon" (default: "md")
- **Example usage**:
```astro
```
### Card
- **Documentation**: https://starwind.dev/docs/components/card
- **Import pattern**: `import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from "@/components/starwind/card";`
- **Key props**:
- Standard HTML attributes for `
` elements
- **Example usage**:
```astro
---
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/starwind/card";
import { Button } from "@/components/starwind/button";
---
Card Title
Card Description
Card Content
```
### Checkbox
- **Documentation**: https://starwind.dev/docs/components/checkbox
- **Import pattern**: `import { Checkbox } from "@/components/starwind/checkbox";`
- **Key props**:
- `id`: string - The required ID attribute
- `variant`: "default" | "primary" | "secondary" | "info" | "success" | "warning" | "error" (default: "default")
- `size`: "sm" | "md" | "lg" (default: "md")
- All standard HTML attributes for
are supported
- **Example usage**:
```astro
---
import { Checkbox } from "@/components/starwind/checkbox";
---
```
### Dialog
- **Documentation**: https://starwind.dev/docs/components/dialog
- **Import pattern**: `import { Dialog, DialogTrigger, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter, DialogClose } from "@/components/starwind/dialog";`
- **Key props**:
- See the documentation for the props for each component
- **Example usage**:
```astro
---
import { Dialog, DialogTrigger, DialogContent, DialogHeader, DialogFooter, DialogTitle, DialogDescription, DialogClose } from "@/components/starwind/dialog";
import { Button } from "@/components/starwind/button";
---
```
### Input
- **Documentation**: https://starwind.dev/docs/components/input
- **Import pattern**: `import { Input } from "@/components/starwind/input";`
- **Key props**:
- `size`: "sm" | "md" | "lg" (default: "md")
- All standard HTML input attributes
- **Example usage**:
```astro
---
import { Input } from "@/components/starwind/input";
---
```
### Label
- **Documentation**: https://starwind.dev/docs/components/label
- **Import pattern**: `import { Label } from "@/components/starwind/label";`
- **Key props**:
- `size`: "sm" | "md" | "lg" (default: "md")
- All standard HTML label attributes
- **Example usage**:
```astro
---
import { Label } from "@/components/starwind/label";
import { Input } from "@/components/starwind/input";
---
```
### Pagination
- **Documentation**: https://starwind.dev/docs/components/pagination
- **Import pattern**: `import { Pagination, PaginationContent, PaginationItem, PaginationLink, PaginationPrevious, PaginationNext, PaginationEllipsis } from "@/components/starwind/pagination";`
- **Key props**:
- `
`
- `isActive`: boolean - Highlights the current page
- `href`: string - Link target
- `size`: `"sm" \| "md" \| "lg"` - element size
- ``
- `href`: string - Link target
- `size`: `"sm" \| "md" \| "lg"` - element size
- ``
- `href`: string - Link target
- `size`: `"sm" \| "md" \| "lg"` - element size
- **Example usage**:
```astro
---
import { Pagination, PaginationEllipsis, PaginationContent, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious } from "@/components/starwind/pagination";
---
Prev
1
2
3
Next
```
### Select
- **Documentation**: https://starwind.dev/docs/components/select
- **Import pattern**: `import { Select, SelectTrigger, SelectValue, SelectContent, SelectItem, SelectGroup, SelectLabel, SelectSeparator } from "@/components/starwind/select";`
- **Key props**:
- ``
- `animationDuration`: number - Duration of the content animation (in ms) (default: 200)
- `side`: "top" | "bottom" (default: "bottom")
- `sideOffset`: number - Offset distance in pixels (default: 4)
- ``
- `disabled`: boolean - Disables the item
- `value`: string - Value of the item
- **Example usage**:
```astro
---
import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue } from "@/components/starwind/select";
---
```
### Switch
- **Documentation**: https://starwind.dev/docs/components/switch
- **Import pattern**: `import { Switch } from "@/components/starwind/switch";`
- **Key props**:
- `id`: string - The required ID attribute
- `variant`: "default" | "primary" | "secondary" | "info" | "success" | "warning" | "error" (default: "default")
- `size`: "sm" | "md" | "lg" (default: "md")
- `checked`: boolean - Controls the checked state
- `disabled`: boolean - Disables the switch
- **Example usage**:
```astro
---
import { Switch } from "@/components/starwind/switch";
---
```
### Tabs
- **Documentation**: https://starwind.dev/docs/components/tabs
- **Import pattern**: `import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/starwind/tabs";`
- **Key props**:
- ``
- `defaultValue`: string - The value of the tab that should be active by default
- `syncKey`: string - The key to sync the active tab with another component
- ``
- `value`: string - The value of the tab
- ``
- `value`: string - The value of the tab
- **Example usage**:
```astro
---
import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/starwind/tabs";
---
Astro
Next.js
Build fast websites, faster with Astro's next-gen island architecture.
The React framework for production-grade applications that scale.
```
### Textarea
- **Documentation**: https://starwind.dev/docs/components/textarea
- **Import pattern**: `import { Textarea } from "@/components/starwind/textarea";`
- **Key props**:
- `size`: "sm" | "md" | "lg" (default: "md")
- All standard HTML textarea attributes
- **Example usage**:
```astro
---
import { Textarea } from "@/components/starwind/textarea";
---
```
### Tooltip
- **Documentation**: https://starwind.dev/docs/components/tooltip
- **Import pattern**: `import { Tooltip, TooltipTrigger, TooltipContent } from "@/components/starwind/tooltip";`
- **Key props**:
- ``
- `openDelay`: number - Delay in ms before showing the tooltip (default: 200)
- `closeDelay`: number - Delay in ms before hiding the tooltip (default: 200)
- `disableHoverableContent`: boolean - When true, prevents the tooltip from staying open when hovering over its content (default: false)
- ``
- `side`: "top" | "right" | "bottom" | "left" (default: "top")
- `align`: "start" | "center" | "end" (default: "center")
- `animationDuration`: number - Duration in ms of the open/close animation (default: 150)
- **Example usage**:
```astro
---
import { Tooltip, TooltipTrigger, TooltipContent } from "@/components/starwind/tooltip";
import { Button } from "@/components/starwind/button";
---
Add to library
```
## Examples
### Form Card
A complete implementation example of a form with Starwind components:
```astro
---
import { Card, CardContent, CardFooter, CardHeader, CardTitle } from "@/components/starwind/card";
import { Button } from "@/components/starwind/button";
import { Input } from "@/components/starwind/input";
import { Label } from "@/components/starwind/label";
import { Checkbox } from "@/components/starwind/checkbox";
---
Create Account
```
## Resources
- Official Website: [starwind.dev](https://starwind.dev)
- Documentation: [starwind.dev/docs](https://starwind.dev/docs/getting-started)
- Components: [starwind.dev/docs/components](https://starwind.dev/docs/components)
- Premium Templates: [cosmicthemes.com/themes](https://cosmicthemes.com/themes)