azir-icon
v1.0.5
Published
A great component that give you the ability you to create your own custom icons
Downloads
99
Maintainers
Readme
Azir Framwork list : https://azir.io/docs
Icon
A great component that give you the ability you to create your own custom icons .
We give you a tool to generate and search for fontawsome icons directly. Icons List
Benefits
Create you own custome icons which you can control the size of the font icon file.
No bloatware, one package with one iconset, nothing more nothing less
Full set of FontAwesome Icons properly updated
Insanely fast with minimal memory footprint
Installation
to install the latest version of azir-icon
you only need to run:
npm install azir-icon --save
or
yarn add azir-icon
Installation process
Azir Theme using azir-font as a default font icons for all azir components Icons like (Spinner,Radio, Switch, CheckBox, RadioGroup, CheckboxGroup ), its required to load at least azir font into your app
async function loadResourcesAsync() {
await Promise.all([
Font.loadAsync({
"azir-font": require("./assets/fonts/azir-font.ttf")
})
]);
}
Font Awesome Icons provide also three types of free icons set . you can download which type you want or even you can download them all if you want ;) in addtion You can create your own custom font..
Create Custom Font Icons
you can use one of the online font icons generator like Fontello which we are using in our custom font example.
| Type | Font Name(Required) | Download | Size | | ------------------------ | ------------------- | -------------------------------------------------------------- | ------ | | AzirIcons (REQUIRED) | azir-font | azir-font | 14 KB | | RegularIcons | fa-regular-400 | fa-regular-400 | 34 KB | | SolidIcons | fa-solid-900 | fa-solid-900 | 188 KB | | BrandIcons | fa-brands-400 | fa-brands-400 | 127KB | | Custom Font | custom-font-icon | custom-font-icon | 10 KB |
next step is to load these fonts into your app , check below example if you are using expo .
async function loadResourcesAsync() {
await Promise.all([
Font.loadAsync({
"azir-font": require("./assets/fonts/azir-font.ttf"),
"fa-solid-900": require("./assets/fonts/fa-solid-900.ttf"),
"fa-regular-400": require("./assets/fonts/fa-solid-900.ttf"),
"fa-brands-400": require("./assets/fonts/fa-brands-400.ttf"),
"custom-font-icon": require("./assets/fonts/custom-font-icon.ttf") // if you want to use Custom font. you can change the name of the font and the file as you want ( only for custom font icon)
})
]);
}
if you want to use your custom font icons, you need to do one extra step to map your fonts icons and inject them to our Dictionary . which is an easy step .
Create new javascript file ( for example CustomIcons.js)
Export your icons object and make sure that you include in the first element : _fontFamily: "custom-font-icon" the same name as you used in Font.loadAsync.
dont forget to add \u before each icon code. also icons name should be camel case.
export default CustomIcons = {
_fontFamily: "custom-font-icon",
unHappy: "\uE802",
wink: "\uE813",
fireStation: "\uE817",
rss: "\uE800",
githubCircled: "\uE801",
sound: "\uE804",
jabber: "\uF317"
};
That's it!
Examples
Font Awesome Icons :
import Icon, { SolidIcons, RegularIcons, BrandIcons } from "azir-icon";
---
<Icon icon={SolidIcons.appleAlt} color="#ff9900" style={ {
padding: 15, textShadowColor: "#ff0000",
textShadowOffset: { width: -1, height: -1 },
textShadowRadius: 2
} } />
<Icon icon={RegularIcons.bellSlash} style={ { padding: 15, fontSize: 30 } } />
<Icon icon={BrandIcons.amazonPay} color="success" size={100} shadow style={ { padding: 15 } } />
Custom Font icons :
import Icon from "azir-icon";
import CustomIcons from "./CustomIcons";//check above code of this object
---
<Icon icon={CustomIcons.unHappy} style={ { padding: 15, fontSize: 30 } } />
<Icon icon={CustomIcons.fireStation} style={ { padding: 15, fontSize: 30 } } />
<Icon icon={CustomIcons.sound} style={ { padding: 15, fontSize: 30 } } />
<Icon icon={CustomIcons.jabber} style={ { padding: 15, fontSize: 30 } } />
Props
Reference
icon
set the Icon using one of the fontawsome free icons set.
| Type | Required | Default | | -------------------------------------------------- | -------- | ---------------- | | SolidIcons, RegularIcons, BrandIcons , CustomIcons | YES | SolidIcons.smile |
color
color of the Icon
| Type | Required | Default | | ------------------------------------------ | -------- | ------- | | azir-color | No | theme |
size
set the size of the icon , you can instead of using the size prop, you just override the style prop.
| Type | Required | Default | | ------ | -------- | ------------------------- | | Number | No | AzirTheme.SIZES.ICON_SIZE |
shadow
If true, show shadow effect for this component.
| Type | Required | Default | | ---- | -------- | ------- | | bool | No | false |
style
override Icon style,since we are using text to render icon then you can use all react native text props
| Type | Required | | ----- | -------- | | style | No |