How to add a border-radius to card element
To the shadow, and the container simultaneously add border-radius
@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-geekyants border-radius
@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-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.
Released with v2.5.2
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 The correct way is:
<Card borderRadius={5}>