Open jadar opened 2 years ago
If you set size={null}
, the icon will avoid applying the default fontSize. If you wrap that icon in a Text
component, the icon should inherit its size.
<Text style={{fontSize: 24}}>
<Icon name="alert" size={null} />
</Text>
Note: If you're enforcing types with Typescript, the style prop will complain because null
isn't a number
. Possible solutions:
null
as a valid size prop valuestyle={{fontSize: undefined}}
instead of size={null}
. undefined
is a valid fontSize style value and works on RN iOS and Android, but not when using React Native Web; RNW must handle undefined style values differently.
Is your feature request related to a problem? Please describe. I've noticed that I am repeating text sizes all over the place when I am placing an icon next to another Text element. I'm working on setting up common text style variants, and it would be really convenient if that worked to specify the icon size, too.
Describe the solution you'd like I'd like Icons to inherit the parent text size if it's nested in a Text component, and no size prop is passed to the Icon element.
Describe alternatives you've considered I considered using styles, but that seems error-prone if the user forgets to use them.
Additional context None