Install
npm install @vinsa/towerspnpm add @vinsa/towersyarn add @vinsa/towersRequirements
Section titled “Requirements”- React 18 or later. It is the package’s only peer dependency.
- Any bundler that can import a CSS file: Vite, Next.js, webpack and the rest.
Import the styles once
Section titled “Import the styles once”The chart needs its stylesheet. Import it once, near the root of your app:
import '@vinsa/towers/styles.css';The file is about 5 kB of plain CSS. Every class starts with rt-, so it will not collide with yours, and it does not need Tailwind or any other framework.
What the package exports
Section titled “What the package exports”| Export | |
|---|---|
Towers |
Draws a whole response. Start here. |
TowerChart |
Draws one tower, for building your own layout. |
| Helpers | layerKey, formatAmount, assignFills and others. |
| Types | TowersResponse, RiskTowers, Tower, HorizontalBand, VerticalBlock. |
The package ships ES modules and CommonJS, with TypeScript types included.
Server components
Section titled “Server components”The components are marked as client components, so in Next.js you can render <Towers /> straight from a server component and pass it the response you fetched there. See the Next.js guide.