@cdc/data-table
v4.26.4
Published
React standalone data table component
Readme
@cdc/data-table
<CdcDataTable /> is the CDC data table component for displaying a dataset in a table layout with optional filters and downloads.
Installation
npm install @cdc/data-tableQuick Start
Use the package by passing a config object directly:
import CdcDataTable from '@cdc/data-table'
const config = {
type: 'table',
version: '4.26.4',
visualizationType: 'Table',
locale: 'en-US',
data: [
{ year: '2020', value: 77.3 },
{ year: '2021', value: 76.4 }
]
}
function App() {
return (
<div className='App'>
<CdcDataTable config={config} />
</div>
)
}
export default AppYou can also load configuration from a URL with <CdcDataTable configUrl='/path/to/config.json' />.
Configuration
The primary reference for authoring configs is CONFIG.md.
If you are reading this in a context where relative Markdown links do not open correctly, use the GitHub copy of the data table config reference.
Properties
| Property | Type | Description |
| --- | --- | --- |
| config | object | Configuration object for the data table. This is the primary integration path for React consumers. |
| configUrl | string | Optional URL to a JSON config file. Use this when you want the component to fetch its config at runtime. |
