Skip to main content

DataTable

Data tables allow displaying sets of data.

How to use

import React from "react";
import { DataTable } from "@gyri/native-ui-components";

const MyComponent = () => {
const [items] = React.useState([
{
key: 1,
name: 'Cupcake',
calories: 356,
fat: 16,
},
{
key: 2,
name: 'Eclair',
calories: 262,
fat: 16,
},
{
key: 3,
name: 'Frozen yogurt',
calories: 159,
fat: 6,
},
{
key: 4,
name: 'Gingerbread',
calories: 305,
fat: 3.7,
},
]);

return (
<DataTable>
<DataTable.Header>
<DataTable.Title>Dessert</DataTable.Title>
<DataTable.Title numeric>Calories</DataTable.Title>
<DataTable.Title numeric>Fat</DataTable.Title>
</DataTable.Header>

{items.map((item) => (
<DataTable.Row key={item.key}>
<DataTable.Cell>{item.name}</DataTable.Cell>
<DataTable.Cell numeric>{item.calories}</DataTable.Cell>
<DataTable.Cell numeric>{item.fat}</DataTable.Cell>
</DataTable.Row>
))}
</DataTable>
);
};

export default MyComponent;
#NameData typeDefault valueValuesDescription
1numericbooleanAlign the text to the right.
2onPressfunction"Function to execute on press.
3textStyleText content style of the DataTableTitle.
4classNamestring"It defined external CSS stylesheet.
5styleobjectCustom style object

For more details https://callstack.github.io/react-native-paper/docs/components/DataTable