Icon
A versatile icon component that supports Lucide icons with multiple variants and sizes.
Icon
The Icon component is a flexible wrapper around Lucide icons, providing consistent styling and extended functionality such as bordered and contained variants, interactive behaviors, and navigation links.
Features
- Lucide Icons Integration: Access to the complete set of Lucide icons
- Multiple Variants: Plain, bordered, and contained styling options
- Flexible Sizing: Predefined sizes or custom numerical values
- Interactive: Optional press handlers and link navigation
- Customizable: Control for color, stroke width, and fill properties
- Accessibility: Support for disabled states
- Dark Mode Support: Automatic light/dark mode styles
Import
Props
Core Props
Prop | Type | Default | Description |
---|---|---|---|
name | IconName | — | The name of the Lucide icon to display |
onPress | () => void | — | Function called when the icon is pressed |
disabled | boolean | false | Whether the icon is interactive |
href | string | — | If provided, icon acts as a navigation link |
Styling Props
Prop | Type | Default | Description |
---|---|---|---|
variant | 'plain' | 'bordered' | 'contained' | 'plain' | The visual style of the icon |
size | number | 24 | Custom size for the icon in pixels |
iconSize | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl' | — | Predefined size options |
color | string | Theme text color | The color of the icon |
strokeWidth | number | 2 | Width of the icon stroke |
fill | string | 'none' | Fill color for the icon |
className | string | — | Additional Tailwind classes for the container |
style | ViewStyle | — | React Native style object for the container |
Sizes
The iconSize
prop maps to the following dimensions:
iconSize | Container Size | Icon Size |
---|---|---|
'xs' | 32x32 | 16px |
's' | 40x40 | 20px |
'm' | 48x48 | 24px |
'l' | 64x64 | 32px |
'xl' | 80x80 | 40px |
'xxl' | 96x96 | 48px |
Usage Examples
Basic Icon
Different Variants
Custom Sizes
Interactive Icon
Navigation Icon
Customized Icon
Disabled State
Best Practices
Consistent Sizing
Choose a consistent approach to sizing icons throughout your application:
Semantic Color Usage
Use colors that reflect the icon's purpose:
Appropriate Variants
Choose variants that match the context:
- Use
plain
for inline icons or when space is limited - Use
bordered
to add subtle emphasis or for toggle controls - Use
contained
for important actions or primary navigation
Implementation Details
The Icon component uses React Native's View
and Pressable
components for rendering. When the href
prop is provided, it wraps the icon in an Expo Router Link
component for navigation.
The component automatically handles theme colors and applies the correct styles based on the active theme. It supports both light and dark mode through the useThemeColors
hook.
Notes
- The component imports Lucide icons from
lucide-react-native
- When both
size
andiconSize
are provided,iconSize
takes precedence - Container sizes are only applied when using variants other than
plain
- The
IconName
type represents all available Lucide icons, excluding utility properties - When using the
href
prop, the component becomes a navigation link using Expo Router