Skip to content

Commit 1deb089

Browse files
committed
docs: update Lucide icons docs guidelines
1 parent 38d7539 commit 1deb089

File tree

1 file changed

+63
-4
lines changed

1 file changed

+63
-4
lines changed

docs/best-practices.md

Lines changed: 63 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,74 @@ import Emoji from "./Emoji"
166166
;<Emoji text=":star:" fontSize="xl" /> // the base fontSize is `md`
167167
```
168168

169-
- **Icons**: We use [Lucide](https://lucide.dev/icons/) for icons
169+
## Icons: Lucide
170+
171+
We use [Lucide](https://lucide.dev/icons/) for icons, imported via the [lucide-react](https://www.npmjs.com/package/lucide-react) package.
172+
173+
Lucide icons by default use strokes only, with default 2px stroke width, rounded line-caps and line-joins, and follow `currentColor`.
174+
175+
### Basic Usage
176+
177+
```tsx
178+
import { Heart } from "lucide-react"
179+
;<Heart />
180+
```
181+
182+
### Sizing
183+
184+
Use tailwind classes to size icons:
185+
186+
- **Static**: example: `size-6` (24px), `size-4` (16px), etc.
187+
- **Mirror `fontSize`**: `size-[1em]`, `size-[0.875em]` to match surrounding text
188+
- **Custom (avoid)**: `size-[50px]` for specific dimensions
189+
190+
```tsx
191+
<Heart className="size-6" />
192+
```
193+
194+
### Coloring
195+
196+
- **Stroke color**: Follows `currentColor`, use `text-*` classes (e.g., `text-primary`, `text-accent-a`)
197+
- **Fill**: Avoid using in most cases to maintain consistent theming
170198

171199
```tsx
172-
import { CircleHelp } from "lucide-react"
200+
<Heart className="text-primary" />
201+
```
202+
203+
### Stroke Properties
204+
205+
- **`strokeWidth`**: example: `stroke-[3]` (use Tailwind classes),
206+
- **`strokeLinecap`/`strokeLinejoin`**: Use props directly on the icon component
207+
208+
```tsx
209+
import { Check } from "lucide-react"
210+
;<Check
211+
className="stroke-[4.5]"
212+
strokeLinecap="square"
213+
strokeLinejoin="miter"
214+
/>
215+
```
173216

174-
// Use tailwind classes to style, using fontSize for sizing
175-
;<CircleHelp className="text-2xl" /> // 24px size
217+
Options:
218+
- `strokeLinecap`: `butt`, `round`, `square`
219+
- `strokeLinejoin`: `round`, `bevel`, `miter`, `
220+
221+
### Background Circles
222+
223+
Wrap icon in a div for circular backgrounds, and color using background:
224+
225+
```tsx
226+
<div className="bg-primary/10 grid size-10 place-items-center rounded-full">
227+
<Heart className="text-primary size-5" />
228+
</div>
176229
```
177230
231+
### Repository Preferences
232+
233+
1. **Preferred**: Lucide out-of-box with color styling
234+
2. **Acceptable**: Lucide with stroke property adjustments
235+
3. **Last resort**: Custom `.svg` imports
236+
178237
## Using custom `Image` component
179238
180239
[Next Image](https://nextjs.org/docs/pages/api-reference/components/image) is the component of choice to handle responsive images. However, we use a custom version of this component that is properly optimized with Chakra. This way we can use style props from Chakra but still be able to forward common or Next Image-specific props to the component for correct usage and rendering.

0 commit comments

Comments
 (0)