react-native-paper icon indicating copy to clipboard operation
react-native-paper copied to clipboard

Allow styling of text in Button and modification of Icon size

Open Sam-Martin opened this issue 7 years ago • 14 comments

Describe the feature

At the moment the text styling in Button is hardcoded with a combination of styles. label and textStyle neither of which are accessible outside the component.

Also the size parameter passed to Icon is fixed to 16 and cannot be changed.

Motivation

I wish to use a button as a larger styling component and in order to make the appearance as I wish I would need to use a larger font and icon

Related Issues

N/A

Sam-Martin avatar Aug 30 '19 14:08 Sam-Martin

@Sam-Martin I added PR with labelStyle for button. I will notify you if we add it to paper

pan-pawel avatar Sep 01 '19 15:09 pan-pawel

That's awesome! Thanks! Any thoughts on icon size?

Sam-Martin avatar Sep 01 '19 16:09 Sam-Martin

@Sam-Martin we added labelStyle to master, so with next release you will be able to set custom font for button. We will also talk about icon size, I will keep you informed

pan-pawel avatar Sep 02 '19 08:09 pan-pawel

Any plan of new releasing?

futantan avatar Oct 14 '19 08:10 futantan

Any update on controlling size of icon in buttons?

tomchomiak avatar Nov 08 '19 06:11 tomchomiak

I'd be interested also - I need to leave icons off at the moment as I am designing an app for construction workers which need big buttons and the size 16 icons just get lost :(

GBGitUser avatar Nov 21 '19 09:11 GBGitUser

I've managed to find a workaround for the icon situation. I've used the React Native Vector Icons library, but you could probably change the <Icon /> for an <Image />.

Here is the code:

import { Button, Text } from 'react-native-paper';
import Icon from 'react-native-vector-icons/FontAwesome';

<Button
  style={buttonStyle}
  mode="contained"
  contentStyle={buttonContentStyle}
>
  <Icon name="warning" size={24} color="#fff" />
  <View style={{ width: 16, height: 1 }} />
  <Text style={buttonTextStyle}>Hello World</Text>
</Button>

Here is the result: Screenshot (Nov 24, 2019 13_10_40)

I've tried to add margin and padding to the Button contentStyle prop but it didn't work. That's why I've included the <View /> between the <Icon /> and the Text />. I've also tried to put a <View /> inside the <Button /> and then put the rest of the stuff inside the View but I get an error.

Hope it helps!

rodrigo98rm avatar Nov 24 '19 16:11 rodrigo98rm

+1 for a iconSize prop

chriswiesner avatar Dec 04 '19 08:12 chriswiesner

Hello 👋, this issue has been open for more than 2 months with no activity on it. If the issue is still present in the latest version, please leave a comment within 7 days to keep it open, otherwise it will be closed automatically. If you found a solution on workaround for the issue, please comment here for others to find. If this issue is critical for you, please consider sending a pull request to fix the issue.

github-actions[bot] avatar Feb 03 '20 00:02 github-actions[bot]

Commenting for needed feature.

CesarGomezTissini avatar Feb 07 '20 20:02 CesarGomezTissini

It could also support accessibilityRole="link" for app that use button styling for changing pages. See https://github.com/callstack/react-native-paper/issues/1666

kopax avatar Feb 11 '20 07:02 kopax

Why is closed? Neither news, nor core devs reaching us for at least say something about this.

CesarGomezTissini avatar Feb 19 '20 01:02 CesarGomezTissini

+1

fender avatar May 08 '20 07:05 fender

Hey I think you can also pass a function to the icon props:

<Button
    onPress={() => console.log('Clicked')}
    icon={() => <FontAwesomeIcon name='plus' size={24} />}
>    
    {'Add user'}
</Button>

The function returns any React component, so you can return an icon too.

AhmedKEpfl avatar Jul 12 '20 08:07 AhmedKEpfl