Icon
The Icon
component can used to add Expo Icons to your app and customize them using style props.
#
Importimport { Icon } from "pearl-ui";
#
Usage<Icon iconFamily="AntDesign" iconName="stepforward" />
#
Icon sizesUse the size
prop to change the size of icon. You can set the value to the keys available in
// size="l" refers to the value of `theme.components.Icon["sizes"]["l"]`<Icon iconFamily="AntDesign" iconName="stepforward" size="l" />
#
Override StyleThe Icon component also supports a variety of style props which can be used to override the pre-defined variant style in the theme. Manual style props passed into the component have a higher precedance than the default component style.
// passing style prop color="primary.500" overrides the default component style value of color="neutral.900"<Icon iconFamily="AntDesign" iconName="stepforward" size="l" color="primary.500" margin="xl"/>
#
Example#
Accessibility- Icon has the
role
oftext
. - Icon has the default label set as
{iconName} Icon
. A custom label can be specified using theaccessibilityLabel
prop.
#
Props#
Supported style propsThe Icon
component supports the following style props:
#
Additional propsName | Required | Type | Default | Description |
---|---|---|---|---|
iconFamily | true | Icon family that contains the icon you want to use | ||
iconName | true | Name of the icon as given in it's respective icon family | ||
size | false | "m" | The size of the icon | |
variant | false | The variant of the icon | ||
accessibilityLabel | false | The accessibility label of the icon |
#
Default Component Styleexport default { baseStyle: { color: { light: "neutral.900", dark: "neutral.50", }, }, sizes: { s: { size: 10, }, m: { size: 15, }, l: { size: 20, }, xl: { size: 30, }, }, defaults: { size: "m", },};