NativeBase icon indicating copy to clipboard operation
NativeBase copied to clipboard

How to add a border-radius to card element

Open dmitryshelomanov opened this issue 8 years ago • 7 comments

To the shadow, and the container simultaneously add border-radius

dmitryshelomanov avatar Apr 28 '18 12:04 dmitryshelomanov

@userbq201 currently there is no any props to support this. But you can wrap the <Card/> in a View and set border to this View. You can also override the default margin provided to the <Card />

Sample code

import React, { Component } from "react";
import { Container, Header, Title, Content, Button, Icon, Card, CardItem, Text, Body, Left, Right, IconNB, View } from "native-base";
export default class App extends Component {
  render() {
    return (
      <Container>
        <Header>
          <Left>
            <Button transparent>
              <Icon name="arrow-back" />
            </Button>
          </Left>
          <Body>
            <Title>Header</Title>
          </Body>
          <Right />
        </Header>
        <Content padder>
          <View style={{ borderWidth: 1, borderColor: "grey" }}>
            <Card style={{ marginTop: 0, marginBottom: 0, marginLeft: 0, marginRight: 0 }}>
              <CardItem header bordered >
                <Text>NativeBase</Text>
              </CardItem>
              <CardItem bordered>
                <Body>
                  <Text>
                    NativeBase is a free and open source framework that enable
                    developers to build
                    high-quality mobile apps using React Native iOS and Android
                    apps
                    with a fusion of ES6.
                </Text>
                </Body>
              </CardItem>
              <CardItem bordered>
                <Body>
                  <Text>
                    NativeBase builds a layer on top of React Native that provides
                    you with
                    basic set of components for mobile application development.
                </Text>
                </Body>
              </CardItem>
              <CardItem bordered>
                <Body>
                  <Text>
                    Get on the mobile fast track with NativeBase, the
                    fastest-growing platform
                    and tool set for iOS and Android development.
                </Text>
                </Body>
              </CardItem>
              <CardItem footer bordered>
                <Text>GeekyAnts</Text>
              </CardItem>
            </Card>
          </View>
        </Content>
      </Container>
    );
  }
}

akhil-ga avatar May 02 '18 07:05 akhil-ga

@akhil-geekyants border-radius

dmitryshelomanov avatar May 02 '18 14:05 dmitryshelomanov

@userbq201 try setting borderRadius to both Card and the top borders of top cardItem and bottom borders of bottom CardItem

Code

import React, { Component } from "react";
import { Container, Header, Title, Content, Button, Icon, Card, CardItem, Text, Body, Left, Right, IconNB, View } from "native-base";
export default class App extends Component {
  render() {
    return (
      <Container>
        <Header>
          <Left>
            <Button transparent>
              <Icon name="arrow-back" />
            </Button>
          </Left>
          <Body>
            <Title>Header</Title>
          </Body>
          <Right />
        </Header>
        <Content padder>
          <Card style={{ borderRadius: 8 }}>
            <CardItem header bordered style={{ borderTopLeftRadius: 8, borderTopRightRadius: 8 }}>
              <Text>NativeBase</Text>
            </CardItem>
            <CardItem bordered>
              <Body>
                <Text>
                  NativeBase is a free and open source framework that enable
                  developers to build
                  high-quality mobile apps using React Native iOS and Android
                  apps
                  with a fusion of ES6.
                </Text>
              </Body>
            </CardItem>
            <CardItem bordered>
              <Body>
                <Text>
                  NativeBase builds a layer on top of React Native that provides
                  you with
                  basic set of components for mobile application development.
                </Text>
              </Body>
            </CardItem>
            <CardItem bordered>
              <Body>
                <Text>
                  Get on the mobile fast track with NativeBase, the
                  fastest-growing platform
                  and tool set for iOS and Android development.
                </Text>
              </Body>
            </CardItem>
            <CardItem footer bordered style={{ borderBottomLeftRadius: 8, borderBottomRightRadius: 8 }}>
              <Text>GeekyAnts</Text>
            </CardItem>
          </Card>
        </Content>
      </Container >
    );
  }
}

akhil-ga avatar May 04 '18 07:05 akhil-ga

@akhil-geekyants that's a work-around, but it would still be nice to have an official property on Card that can override the default radius, propagating the values to sub-components. I would suggest reopening this ticket.

paour avatar May 30 '18 12:05 paour

Released with v2.5.2

SupriyaKalghatgi avatar Jun 15 '18 05:06 SupriyaKalghatgi

I have added the border radius as given below.

<Card cardBorderRadius={5}>

But did not work for me. I use version 2.6.0. Is this mentioned in the official doc.

mirzavu avatar Jul 31 '18 11:07 mirzavu

@mirzavu The correct way is:

<Card borderRadius={5}>

brkastner avatar Aug 01 '18 15:08 brkastner