Icon
The Icon component provides access to 117+ built-in SVG icons with support for custom colors, sizes, and stroke/fill modes.
Prerequisites
The Icon component renders SVG files as React components. This requires react-native-svg and react-native-svg-transformer to be installed, and your Metro config to include the SVG setup. If icons are not rendering, see Installation - SVG Icon Support.
Featuresβ
- π¨ 117+ built-in icons
- π Customizable size
- ποΈ Stroke and fill modes
- π― Theme color variants
- π§ Stroke width control
Basic Usageβ
import {Icon} from '@tansuk/rott-ui'
;<Icon name='MENU' width={24} height={24} />
Icon Sizesβ
<Icon name="STAR" width={16} height={16} />
<Icon name="STAR" width={24} height={24} />
<Icon name="STAR" width={32} height={32} />
<Icon name="STAR" width={48} height={48} />
Color Variantsβ
<Icon name="HEART" width={24} height={24} variant="primary" />
<Icon name="HEART" width={24} height={24} variant="danger" />
<Icon name="HEART" width={24} height={24} variant="success" />
Stroke vs Fillβ
{
/* Stroke mode (outline) */
}
;<Icon name='HEART' width={24} height={24} mode='stroke' />
{
/* Fill mode (solid) */
}
;<Icon name='HEART' width={24} height={24} mode='fill' />
Available Iconsβ
Interface Iconsβ
- MENU, CLOSE, REMOVE, PLUS, MINUS
- ARROW_LEFT, ARROW_RIGHT, CHEVRON_LEFT, CHEVRON_RIGHT
- CHECK, CHECK_CIRCLE, REMOVE_CIRCLE
- SEARCH, FILTER, SETTINGS
- USER, NOTIFICATION, MAIL
- STAR, HEART, EYE
- LOCK, LOCATION, CALENDAR
- CAMERA, GALLERY, QR
- And 90+ more...
Currency Iconsβ
- MONEY_ADD, MONEY_REMOVE, MONEY_TRANSFER
- CREDIT_CARD, WALLET
Propsβ
| Prop | Type | Default | Description |
|---|---|---|---|
name | IconKeys | Required | Icon name |
width | number | 24 | Icon width |
height | number | 24 | Icon height |
variant | Variant | 'grey-900' | Color variant |
mode | 'stroke' | 'fill' | 'stroke' | Render mode |
strokeWidth | number | 2 | Stroke width |
Examplesβ
Navigationβ
<Icon name="ARROW_LEFT" width={24} height={24} />
<Icon name="MENU" width={24} height={24} />
<Icon name="CLOSE" width={24} height={24} />
Actionsβ
<Icon name="PLUS" width={20} height={20} variant="primary" />
<Icon name="REMOVE" width={20} height={20} variant="danger" />
<Icon name="CHECK" width={20} height={20} variant="success" />
In Buttonsβ
<Button variant='primary' leftIcon={{name: 'PLUS', width: 20, height: 20}}>
Add Item
</Button>
In Headersβ
<Header
title='Settings'
leftIcon={[{name: 'ARROW_LEFT', onPress: () => navigation.goBack()}]}
rightIcon={[{name: 'SEARCH', onPress: () => {}}]}
/>
Custom Icons (Auto-Discovery)β
With withRottAssets in your Metro config, SVG files in src/assets/icons/svg/ are automatically available by filename (without extension):
// src/assets/icons/svg/my-logo.svg β name="my-logo"
<Icon name="my-logo" width={48} height={48} />