Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Add, manage, and compose shadcn/ui components with correct patterns, styling, and CLI workflows.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
rules/icons.md
1# Icons23**Always use the project's configured `iconLibrary` for imports.** Check the `iconLibrary` field from project context: `lucide` → `lucide-react`, `tabler` → `@tabler/icons-react`, etc. Never assume `lucide-react`.45---67## Icons in Button use data-icon attribute89Add `data-icon="inline-start"` (prefix) or `data-icon="inline-end"` (suffix) to the icon. No sizing classes on the icon.1011**Incorrect:**1213```tsx14<Button>15<SearchIcon className="mr-2 size-4" />16Search17</Button>18```1920**Correct:**2122```tsx23<Button>24<SearchIcon data-icon="inline-start"/>25Search26</Button>2728<Button>29Next30<ArrowRightIcon data-icon="inline-end"/>31</Button>32```3334---3536## No sizing classes on icons inside components3738Components handle icon sizing via CSS. Don't add `size-4`, `w-4 h-4`, or other sizing classes to icons inside `Button`, `DropdownMenuItem`, `Alert`, `Sidebar*`, or other shadcn components. Unless the user explicitly asks for custom icon sizes.3940**Incorrect:**4142```tsx43<Button>44<SearchIcon className="size-4" data-icon="inline-start" />45Search46</Button>4748<DropdownMenuItem>49<SettingsIcon className="mr-2 size-4" />50Settings51</DropdownMenuItem>52```5354**Correct:**5556```tsx57<Button>58<SearchIcon data-icon="inline-start" />59Search60</Button>6162<DropdownMenuItem>63<SettingsIcon />64Settings65</DropdownMenuItem>66```6768---6970## Pass icons as component objects, not string keys7172Use `icon={CheckIcon}`, not a string key to a lookup map.7374**Incorrect:**7576```tsx77const iconMap = {78check: CheckIcon,79alert: AlertIcon,80}8182function StatusBadge({ icon }: { icon: string }) {83const Icon = iconMap[icon]84return <Icon />85}8687<StatusBadge icon="check" />88```8990**Correct:**9192```tsx93// Import from the project's configured iconLibrary (e.g. lucide-react, @tabler/icons-react).94import { CheckIcon } from "lucide-react"9596function StatusBadge({ icon: Icon }: { icon: React.ComponentType }) {97return <Icon />98}99100<StatusBadge icon={CheckIcon} />101```102