Reputation: 3046
I'm trying to render a very simple table with React and the Blueprint UI toolkit.
The documentation relative to the Table
component is quite simple, but it seems like my code doesn't work.
import React from 'react';
import ReactDOM from 'react-dom';
import * as Blueprint from '@blueprintjs/core';
import { Cell, Column, Table } from '@blueprintjs/table';
const renderCell = (rowIndex: number) => {
return <Cell>{`$${(rowIndex * 10).toFixed(2)}`}</Cell>
};
var myTable = (
<Table numRows={10}>
<Column name="Dollars" renderCell={renderCell}/>
</Table>
);
ReactDOM.render(
myTable,
document.getElementById('myTable')
);
The image below shows what I get. How do I fix it?
Upvotes: 2
Views: 4532
Reputation: 31
For me,
yarn add @blueprintjs/core @blueprintjs/table
Then using a relative path from my react component file
import { Cell, Column, Table } from '@blueprintjs/table'
import '../../node_modules/@blueprintjs/table/lib/css/table.css'
Upvotes: 3
Reputation: 31
I had to include this line in my css file (using webpack setup by create-react-app):
@import '~@blueprintjs/table/dist/table.css';
Upvotes: 3
Reputation: 451
Are you including blueprint.css
and blueprint-table.css
on your page? The Table won't render correctly without its stylesheets!
Upvotes: 8