question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ButtonGroup never renders last button as final button

See original GitHub issue

Issue type

I’m submitting a … (check one with “x”)

  • bug report
  • feature request

Issue description

Current behavior:

I want to use a ButtonGroup like

<ButtonGroup>
    <Button>Btn1</Button>
    <Button>Btn2</Button>
</ButtonGroup>

and I followed the documentation. But I also tried

<ButtonGroup>
    <Button>Btn1</Button>
    <Button>Btn2</Button>
    <Button>Btn3</Button>
</ButtonGroup>

with a third button but same thing. The last button is not rounded and the button group does not take up 100% of the width of the container.

Expected behavior:

The ButtonGroup takes up the full width of the container and rounds the last button.

Steps to reproduce:

Related code:

import {Layout, Text, Input, Button, ButtonGroup, ButtonGroupProps} from 'react-native-ui-kitten'

import styles from './styles/layout';

export default class Auth extends React.Component {
	state = {
		login: '',
		password: '',
	};

	change(text, value) {
		this.setState({
			[value]: text,
		});
	}

	render() {
		return <Layout style={styles.layout}>
			<Text category={"h2"} appearance={"hint"} style={styles.heading}>Sign In</Text>

			<Input onChangeText={text => this.change(text, 'login')} value={this.state.login} label={"Email"}/>
			<Input onChangeText={text => this.change(text, 'password')} value={this.state.password} label={"Password"} secureTextEntry={true}/>

			<Methods/>

			<Button>Log In</Button>
			<Button appearance={"ghost"}>Forgot Password</Button>
		</Layout>;
	}
}

const Methods = props => <ButtonGroup>
	<Button>Google</Button>
	<Button>Facebook</Button>
</ButtonGroup>;

Other information:

OS, device, package version

Android 9.0, Galaxy S8, UI Kitten v4.1.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10

github_iconTop GitHub Comments

2reactions
artyorshcommented, Jul 11, 2019

Here is an idea of how you can quickly solve this - View it on Snack

<ButtonGroup style={{ width: '100%' }}>
  <Button style={{ flex: 1 }}>L</Button>
  <Button style={{ flex: 1 }}>M</Button>
  <Button style={{ flex: 1 }}>R</Button>
</ButtonGroup>

The code above makes ButtonGroup have a width of a container, also it makes it children to have equal width. So it can render as expected and can be only controlled by width property.

I don’t think that by default ButtonGroup should take the full width of a container, but we will work on it to get rid of this workaround. Thanks

1reaction
J-Cakecommented, Oct 18, 2019

sweeet, worked to perfection. Thanks everyone!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Empty button at end button group after iterating through array ...
I have this empty button being generated at the end of a button group. Not sure why and attempts to prevent it from...
Read more >
How to Create a ButtonGroup Component with React and ...
We use last:rounded-r-md to make the last button in the group has rounded borders on the right. If we remove <Button /> 's...
Read more >
LWC - how to refresh radio button group after handleEvent ...
I have an LWC component that displays a radio button group - on selecting an option it displays a message as to ...
Read more >
React: How to create a custom Button Group component in 5 ...
Render Button group component in the app. Create a new file for the Button group component. ButtonGroup.js. import React from "react"; ...
Read more >
Button | Mantine
Render button or link with button styles from mantine theme. ... White is a variant in which button background color is always white...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found