React-native-ui-kitten: ButtonGroup appearance missing option 'ghost'

Created on 21 Jun 2020  路  4Comments  路  Source: akveo/react-native-ui-kitten

As the title says, ButtonGroup prop appearance only allows filled and outline, but not ghost. This should be fixed as there's no reason to not allow ghost appearance in buttongroup.

Most helpful comment

@artyorsh It feels inconsistent, as filled and outline options work, but not ghost. I wanted to create a rating buttongroup like this.

<ButtonGroup  
    style={styles.reviewButtons}
    appearance="ghost"
    status="warning"
>
    {steps.map((v, i) => (
        <Button
            key={i}
            icon={
                ratingReview > i ? StarIconFill : StarIcon
            }
            onPress={() => setRatingReview(v)}
        />
    ))}
</ButtonGroup>

ended up doing what you suggested:

<View style={styles.reviewButtons}>
    {steps.map((v, i) => (
        <Button
            key={i}
            appearance="ghost"
            status="warning"
            icon={
                ratingReview > i ? StarIconFill : StarIcon
            }
            onPress={() => setRatingReview(v)}
        />
    ))}
</View>

I reported the issue because I thought it's kind of inconsistent how filled and outlined works but ghost doesn't. It's up to you.

Thanks.

All 4 comments

@arafatzahan

no reason to not allow

This would be the same as using multiple Buttons without wrapping it into a Group. Any reason to allow it?

@artyorsh It feels inconsistent, as filled and outline options work, but not ghost. I wanted to create a rating buttongroup like this.

<ButtonGroup  
    style={styles.reviewButtons}
    appearance="ghost"
    status="warning"
>
    {steps.map((v, i) => (
        <Button
            key={i}
            icon={
                ratingReview > i ? StarIconFill : StarIcon
            }
            onPress={() => setRatingReview(v)}
        />
    ))}
</ButtonGroup>

ended up doing what you suggested:

<View style={styles.reviewButtons}>
    {steps.map((v, i) => (
        <Button
            key={i}
            appearance="ghost"
            status="warning"
            icon={
                ratingReview > i ? StarIconFill : StarIcon
            }
            onPress={() => setRatingReview(v)}
        />
    ))}
</View>

I reported the issue because I thought it's kind of inconsistent how filled and outlined works but ghost doesn't. It's up to you.

Thanks.

I'm in the same boat here.

It would be best to not discriminate the "ghost" appearance option for a ButtonGroup as it is ultimately passed into its child Button elements.

@artyorsh

Any reason to allow it?

I still want to maintain the rounded corners for the pressed highlight when you have many ghost buttons in a group.

Quick fix: You can eliminate the warning message by patching in a functional appearance mapping for ButtonGroup via ApplicationProvider, hence making the "ghost" appearance a valid option.

import * as eva from "@eva-design/eva";

...

const { outline } = eva.mapping.components.ButtonGroup.appearances;
const ghostStatusKeys = Object.keys(outline);
const ghostStatusGeneric = {
  borderColor: "transparent",
  dividerBackgroundColor: "transparent",
};

eva.mapping.components.ButtonGroup.appearances.ghost = {
  mapping: {},
  variantGroups: {
    status: ghostStatusKeys.reduce(
      (acc, key) => Object.assign(acc, { [key]: ghostStatusGeneric }),
      {}
    ),
  },
};

...

<ApplicationProvider {...eva} theme={eva.light}>
Was this page helpful?
0 / 5 - 0 ratings

Related issues

jeloagnasin picture jeloagnasin  路  3Comments

MScMechatronics picture MScMechatronics  路  3Comments

sarmadkung picture sarmadkung  路  3Comments

nonameolsson picture nonameolsson  路  3Comments

RWOverdijk picture RWOverdijk  路  3Comments