# 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](https://starwind.dev/docs/components/accordion) - [Alert](https://starwind.dev/docs/components/alert) - [Alert Dialog](https://starwind.dev/docs/components/alert-dialog) - [Aspect Ratio](https://starwind.dev/docs/components/aspect-ratio) - [Avatar](https://starwind.dev/docs/components/avatar) - [Badge](https://starwind.dev/docs/components/badge) - [Breadcrumb](https://starwind.dev/docs/components/breadcrumb) - [Button](https://starwind.dev/docs/components/button) - [Card](https://starwind.dev/docs/components/card) - [Carousel](https://starwind.dev/docs/components/carousel) - [Checkbox](https://starwind.dev/docs/components/checkbox) - [Dialog](https://starwind.dev/docs/components/dialog) - [Dropdown](https://starwind.dev/docs/components/dropdown) - [Dropzone](https://starwind.dev/docs/components/dropzone) - [Input](https://starwind.dev/docs/components/input) - [Item](https://starwind.dev/docs/components/item) - [Label](https://starwind.dev/docs/components/label) - [Pagination](https://starwind.dev/docs/components/pagination) - [Progress](https://starwind.dev/docs/components/progress) - [Radio Group](https://starwind.dev/docs/components/radio-group) - [Select](https://starwind.dev/docs/components/select) - [Separator](https://starwind.dev/docs/components/separator) - [Sheet](https://starwind.dev/docs/components/sheet) - [Skeleton](https://starwind.dev/docs/components/skeleton) - [Spinner](https://starwind.dev/docs/components/spinner) - [Switch](https://starwind.dev/docs/components/switch) - [Table](https://starwind.dev/docs/components/table) - [Tabs](https://starwind.dev/docs/components/tabs) - [Textarea](https://starwind.dev/docs/components/textarea) - [Tooltip](https://starwind.dev/docs/components/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". ``` ### Alert Dialog - **Documentation**: https://starwind.dev/docs/components/alert-dialog - **Import pattern**: `import { AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogHeader, AlertDialogFooter, AlertDialogTitle, AlertDialogDescription, AlertDialogCancel, AlertDialogAction } from "@/components/starwind/alert-dialog";` - **Key props**: - `for?: string` - Used on `AlertDialogTrigger`. Optional ID of the dialog to trigger - **Example usage**: ```astro --- import { AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogHeader, AlertDialogFooter, AlertDialogTitle, AlertDialogDescription, AlertDialogCancel, AlertDialogAction, } from "@/components/starwind/alert-dialog"; import { Button } from "@/components/starwind/button"; --- Are you absolutely sure? This action cannot be undone. This will permanently delete your account and remove your data from our servers. Cancel Continue ``` ### Aspect Ratio - **Documentation**: https://starwind.dev/docs/components/aspect-ratio - **Import pattern**: `import { AspectRatio } from "@/components/starwind/aspect-ratio";` - **Key props**: - `ratio`: number - The aspect ratio (e.g., 16/9, 4/3, 1) (default: 1) - `as`: HTMLTag - The HTML element to render as (default: "div") - All standard HTML attributes for the element specified by the `as` prop - **Example usage**: ```astro --- import { AspectRatio } from "@/components/starwind/aspect-ratio"; --- Photo by Drew Beamer ``` ### 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 ``` ### Breadcrumb - **Documentation**: https://starwind.dev/docs/components/breadcrumb - **Import pattern**: `import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, BreadcrumbEllipsis } from "@/components/starwind/breadcrumb";` - **Example usage**: ```astro --- import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, BreadcrumbEllipsis, } from "@/components/starwind/breadcrumb"; --- Home Categories Electronics ``` ### 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

``` ### Carousel - **Documentation**: https://starwind.dev/docs/components/carousel - **Import pattern**: `import { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious } from "@/components/starwind/carousel";` - **Key props**: - `orientation?: "horizontal" | "vertical"` - Carousel orientation (default: "horizontal") - `opts?: EmblaOptionsType` - Embla Carousel options object - `autoInit?: boolean` - Whether to automatically initialize the carousel (default: true) - **Example usage**: ```astro --- import { Card, CardContent } from "@/components/starwind/card"; import { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, } from "@/components/starwind/carousel"; --- { Array.from({ length: 5 }).map((_, index) => (
{index + 1}
)) }
``` ### 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"; --- Example Dialog This is a simple dialog example that demonstrates the basic functionality.
Your dialog content goes here.
``` ### Dropdown - **Documentation**: https://starwind.dev/docs/components/dropdown - **Import pattern**: `import { Dropdown, DropdownTrigger, DropdownContent, DropdownItem, DropdownLabel, DropdownSeparator } from "@/components/starwind/dropdown";` - **Key props**: - `Dropdown`: `openOnHover` (boolean), `closeDelay` (number) - `DropdownTrigger`: `asChild` (boolean) - `DropdownContent`: `side` ("top" | "bottom"), `align` ("start" | "center" | "end"), `sideOffset` (number) - `DropdownItem`: `as` (HTMLTag), `inset` (boolean), `disabled` (boolean) - `DropdownLabel`: `inset` (boolean) - **Example usage**: ```astro --- import { Dropdown, DropdownTrigger, DropdownContent, DropdownItem, DropdownLabel, DropdownSeparator, } from "@/components/starwind/dropdown"; import { Button } from "@/components/starwind/button"; --- My Account Profile Settings Help Sign out ``` ### Dropzone - **Documentation**: https://starwind.dev/docs/components/dropzone - **Import pattern**: `import { Dropzone, DropzoneFilesList, DropzoneLoadingIndicator, DropzoneUploadIndicator } from "@/components/starwind/dropzone";` - **Key props**: - `Dropzone`: `accept` (string), `multiple` (boolean), `disabled` (boolean), `required` (boolean), `name` (string), `isUploading` (boolean) - `DropzoneFilesList`: Standard HTML attributes for div elements - `DropzoneUploadIndicator`: Provides a slot for custom content - `DropzoneLoadingIndicator`: Provides a slot for custom content - **Example usage**: ```astro --- import { Dropzone, DropzoneFilesList, DropzoneLoadingIndicator, DropzoneUploadIndicator, } from "@/components/starwind/dropzone"; --- Drop files here or click to upload ``` ### 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"; --- ``` ### Item - **Documentation**: https://starwind.dev/docs/components/item - **Description**: A flexible item component with multiple sub-components for building rich content blocks. Commonly used for lists, notifications, and card-like content. - **Import pattern**: `import { Item, ItemContent, ItemTitle, ItemDescription, ItemActions, ItemMedia, ItemHeader, ItemFooter, ItemGroup, ItemSeparator } from "@/components/starwind/item";` - **Key props**: - `` (Root component) - `variant`: "default" | "outline" | "muted" (default: "default") - `size`: "default" | "sm" (default: "default") - `as`: HTMLTag - The HTML element to render as (default: "div") - All standard HTML attributes for the element specified by the `as` prop - `` - `variant`: "default" | "icon" | "image" (default: "default") - All standard HTML attributes for div elements - ``, ``, ``, ``, ``, ``: Standard HTML attributes for their respective elements - ``: Container for grouping multiple items with semantic list markup - ``: Separator for use within ItemGroup - `orientation`: "horizontal" | "vertical" (default: "horizontal") - **Example usage**: ```astro --- import { Item, ItemContent, ItemTitle, ItemDescription, ItemActions, ItemMedia, ItemGroup, ItemSeparator, } from "@/components/starwind/item"; import { Avatar, AvatarImage, AvatarFallback } from "@/components/starwind/avatar"; import { Button } from "@/components/starwind/button"; import Plus from "@tabler/icons/outline/plus.svg"; --- Basic Item A simple item with title and description. WR Web Reaper Creator of Starwind UI First Item Description for first item Second Item Description for second item ``` ### 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 ``` ### Progress - **Documentation**: https://starwind.dev/docs/components/progress - **Import pattern**: `import { Progress } from "@/components/starwind/progress";` - **Key props**: - `value`: number - Current progress value - `max`: number - Maximum value (default: 100) - `variant`: "default" | "primary" | "secondary" | "info" | "success" | "warning" | "error" (default: "default") - Standard HTML attributes for div elements - **Example usage**: ```astro --- import { Progress } from "@/components/starwind/progress"; --- ``` ### Radio Group - **Documentation**: https://starwind.dev/docs/components/radio-group - **Import pattern**: `import { RadioGroup, RadioGroupItem } from "@/components/starwind/radio-group";` - **Key props**: - `RadioGroup`: - `name`: string - Name for the radio group inputs (required) - `value`: string - Current value of the radio group - `defaultValue`: string - Default value if `value` not provided - `legend`: string - Screen reader label for the group - `orientation`: "vertical" | "horizontal" (default: "vertical") - `RadioGroupItem`: - `value`: string - Value of the radio item (required) - `id`: string - ID for the radio input - `size`: "sm" | "md" | "lg" (default: "md") - `variant`: "default" | "primary" | "secondary" | "info" | "success" | "warning" | "error" (default: "default") - **Example usage**: ```astro --- import { RadioGroup, RadioGroupItem } from "@/components/starwind/radio-group"; import { Label } from "@/components/starwind/label"; ---
``` ### 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"; --- ``` ### Separator - **Documentation**: https://starwind.dev/docs/components/separator - **Import pattern**: `import { Separator } from "@/components/starwind/separator";` - **Key props**: - `orientation`: "horizontal" | "vertical" (default: "horizontal") - All standard HTML attributes for div elements (excluding `role` and `aria-orientation` which are set automatically) - **Example usage**: ```astro --- import { Separator } from "@/components/starwind/separator"; ---

Starwind UI

A beautiful component library for Astro.

Components
Documentation
Examples
``` ### Sheet - **Documentation**: https://starwind.dev/docs/components/sheet - **Description**: A slide-out panel component that extends from any edge of the screen with smooth animations. Built on top of the Dialog component. - **Import pattern**: `import { Sheet, SheetTrigger, SheetContent, SheetHeader, SheetTitle, SheetDescription, SheetFooter, SheetClose } from "@/components/starwind/sheet";` - **Key props**: - `` (Root component) - Inherits all props from the Dialog component - `` (Button that opens the sheet) - `asChild?: boolean` - When true, renders the child element instead of a button - `for?: string` - Optional ID of the sheet to trigger - `` (The slide-out panel container) - `side?: "top" | "right" | "bottom" | "left"` - Side of the screen to slide out from (default: "right") - `` (Button that closes the sheet) - `asChild?: boolean` - When true, renders the child element instead of a button - **Example usage**: ```astro --- import { Button } from "@/components/starwind/button"; import { Input } from "@/components/starwind/input"; import { Label } from "@/components/starwind/label"; import { Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, } from "@/components/starwind/sheet"; --- Edit Profile Make changes to your profile here. Click save when you're done.
Top Sheet This sheet opens from the top of the screen. ``` ### Skeleton - **Documentation**: https://starwind.dev/docs/components/skeleton - **Import pattern**: `import { Skeleton } from "@/components/starwind/skeleton";` - **Key props**: - The Skeleton component accepts all standard HTML attributes for the `
` element - Use the `class` prop to control dimensions, shape, and appearance - **Example usage**: ```astro --- import { Skeleton } from "@/components/starwind/skeleton"; ---
``` ### Spinner - **Documentation**: https://starwind.dev/docs/components/spinner - **Import pattern**: `import { Spinner } from "@/components/starwind/spinner";` - **Key props**: - All standard HTML attributes for svg elements (excluding `role` and `aria-label` which are set automatically for accessibility) - Use the `class` prop to control size and color - **Example usage**: ```astro --- import { Spinner } from "@/components/starwind/spinner"; import { Button } from "@/components/starwind/button"; --- ``` ### 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"; --- ``` ### Table - **Documentation**: https://starwind.dev/docs/components/table - **Import pattern**: `import { Table, TableHeader, TableHead, TableBody, TableRow, TableCell, TableCaption, TableFoot } from "@/components/starwind/table";` - **Example usage**: ```astro --- import { Table, TableHeader, TableHead, TableBody, TableRow, TableCell, TableCaption, TableFoot, } from "@/components/starwind/table"; --- Example of a simple table Name Email Status Ada Lovelace ada@starwind.dev Active Grace Hopper grace@starwind.dev Inactive Total: 2 users
``` ### 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"; ---