React-native-ui-kitten: Customize card body

Created on 10 Apr 2020  Â·  8Comments  Â·  Source: akveo/react-native-ui-kitten

💬 Question

Hey guys,
Just a quick question, is it possible to remove the padding properties on the body of the card component?
Is this customizable?
Thanks a lot,
Antoine

UI Kitten and Eva version

| Package | Version |
| ----------- | ----------- |
| @eva-design/eva | 1.4.0 |
| @ui-kitten/components | 4.4.1 |

Help wanted Components

Most helpful comment

Hey @artyorsh! You're a genius, thanks so much for the quick answer :)

Applied the following on the child element:

marginHorizontal: -24,
marginVertical: -16,

All 8 comments

You can:

  • Do this with mapping customization
  • Use negative paddings like style={{ paddingHorizontal: -16 }} to override the actual value.

@AntoinedeChassey sorry, not padding. The option is to pass a negative margin to a child element.

Hey @artyorsh! You're a genius, thanks so much for the quick answer :)

Applied the following on the child element:

marginHorizontal: -24,
marginVertical: -16,

@AntoinedeChassey Hi sir! May i ask if you directly added to your component?

Such as,

<Item style={{marginHorizontal: -24, marginVertical: -16}} ... />

I'm trying to remove the spacing at the top and bottom of the image, but to no avail.
I tried custom mapping but i think i'm doing it wrongly..

// Mapping file
{
  "components": {
    "Card": {
      "appearance": {
        "outline": {
          "mapping": {
            "headerMarginHorizontal": -24, // Tried
            "headerMarginVertical": -16
            "headerPaddingHorizontal": 0, 
            "headerPaddingVertical": -100
          }
        }
      }
    }
  }
}

// Card
const Header = () => (
    <View style={styles.imageContainer}>
      {imageUrl ? (
        <ImageBackground style={styles.image} source={{ uri: imageUrl }} />
      ) : (
        <ImageBackground
          style={styles.image}
          source={require('../assets/images/1.jpg')}
        />
      )}
    </View>
  );

  return (
    <Card
      style={styles.container}
      header={Header}
    >
      <Text category='h6'>
        {name}
      </Text>
    </Card>
  );

image

And i'm still unsure why my text (test, test 2, ...) starts from the bottom, like a flex style of flex-end has been applied.

Thanks!

EDIT: Sorry @artyorsh wondering if you could please assist.. i looked through the docs but i'm still unable to do it.. ugh...

@domsterthebot

"headerMarginHorizontal": -24, // Tried

In mapping, what you've set is for header is not for the body, isn't it?

@domsterthebot try to put what is in your header inside the card component itself :
As:

<Card
  style={styles.container}
  header={Header}
>
    <View style={styles.imageContainer}>
      {imageUrl ? (
        <ImageBackground style={styles.image} source={{ uri: imageUrl }} />
      ) : (
        <ImageBackground
          style={styles.image}
          source={require('../assets/images/1.jpg')}
        />
      )}
    </View>
</Card>

Might be something with the header not accepting styling..

The correct key for mapping is

export const mapping = {
  components: {
    Card: {
      appearances: {
        outline: {
          mapping: {
            bodyPaddingHorizontal: 16,
          }
        }
      }
    }
  },
}

I have done multiple mapping for font-family and card

{
  "strict": {
    "text-font-family": "Ubuntu-Regular"
  },
  "components": {
    "Card": {
      "appearances": {
        "outline": {
          "mapping": {
            "bodyPaddingHorizontal": -16,
            "bodyPaddingVertical": -16
          }
        }
      }
    }
  }
}

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shiqian123 picture shiqian123  Â·  3Comments

MScMechatronics picture MScMechatronics  Â·  3Comments

sarmadkung picture sarmadkung  Â·  3Comments

Gitldx picture Gitldx  Â·  3Comments

RWOverdijk picture RWOverdijk  Â·  3Comments