SquareX UI Component Library - Modern React components for charts and UI elements
npm install squarex-ui-component-libbash
npm install squarex-ui-component-lib
`
or
`bash
yarn add squarex-ui-component-lib
`
Quick Start
$3
To use the component library, you must import the global CSS in your application's entry point (e.g., main.tsx or App.tsx):
`tsx
import 'squarex-ui-component-lib/dist/index.esm.css';
`
$3
`jsx
import React from 'react';
import { Button, Card, BarChart, PieChart } from 'squarex-ui-component-lib';
function App() {
const chartData = [
{ category: 'Q1', value: 120, color: '#0ea5e9' },
{ category: 'Q2', value: 190, color: '#0284c7' },
{ category: 'Q3', value: 300, color: '#0369a1' },
{ category: 'Q4', value: 280, color: '#075985' },
];
return (
Dashboard
data={chartData}
title="Quarterly Sales"
width={600}
height={400}
/>
);
}
`
#### Icon
A flexible icon component that supports over 300+ vectors.
`jsx
import { Icon } from 'squarex-ui-component-lib';
// Basic usage
// With variant and custom size
name="arrow-right"
variant="primary"
size={24}
/>
// All icons list can be found in src/components/data/iconList.ts
`
$3
Icons are automatically loaded from a CDN (JSDelivr) as a fallback, so they will work out of the box in projects like Vite, Create React App, or Codesandbox.
$3
`jsx
// Import only what you need
import { Button } from 'squarex-ui-component-lib/ui';
import { BarChart } from 'squarex-ui-component-lib/charts';
`
Components
$3
#### Button
A versatile button component with multiple variants and states.
`jsx
import { Button } from 'squarex-ui-component-lib';
`
#### Card
A flexible container component for grouping related content.
`jsx
import { Card } from 'squarex-ui-component-lib';
Card Title
Card content goes here
`
$3
#### BarChart
Interactive bar charts with customizable styling and animations.
`jsx
import { BarChart } from 'squarex-ui-component-lib';
const data = [
{ category: 'Q1', value: 120, color: '#0ea5e9' },
{ category: 'Q2', value: 190, color: '#0284c7' },
];
data={data}
title="Quarterly Sales"
width={600}
height={400}
showTooltip={true}
animate={true}
/>
`
#### PieChart
Beautiful pie charts with interactive tooltips and legends.
`jsx
import { PieChart } from 'squarex-ui-component-lib';
const data = [
{ label: 'Desktop', value: 45, color: '#0ea5e9' },
{ label: 'Mobile', value: 35, color: '#0284c7' },
{ label: 'Tablet', value: 20, color: '#0369a1' },
];
data={data}
title="Device Usage"
showLegend={true}
showTooltip={true}
/>
`
Configuration
$3
Add the SquareX design system to your Tailwind config:
`javascript
// tailwind.config.js
module.exports = {
content: [
"./src/*/.{js,ts,jsx,tsx}",
"./node_modules/squarex-ui-component-lib/*/.{js,ts,jsx,tsx}",
],
theme: {
extend: {
colors: {
squarex: {
primary: {
50: '#f0f9ff',
500: '#0ea5e9',
900: '#0c4a6e',
},
// ... more colors
},
},
},
},
plugins: [
require('@tailwindcss/forms'),
require('@tailwindcss/typography'),
],
}
`
$3
Import the global styles in your main entry file:
`tsx
import 'squarex-ui-component-lib/dist/index.esm.css';
`
Development
$3
- Node.js 16+
- npm or yarn
- Git
$3
`bash
Clone the repository
git clone https://github.com/SquareX/SquareXUIComponentLib.git
cd SquareXUIComponentLib
Install dependencies
npm install
Start development server
npm run dev
Run Storybook
npm run storybook
Run tests
npm test
Build the library
npm run build
`
$3
`
src/
āāā components/ # React components
ā āāā charts/ # Chart components (BarChart, PieChart, etc.)
ā āāā ui/ # UI components (Button, Card, etc.)
āāā types/ # TypeScript type definitions
āāā utils/ # Utility functions
āāā styles/ # Global styles and CSS
āāā index.ts # Main export file
`
$3
1. Create component directory: src/components/ui/NewComponent/
2. Add component files: NewComponent.tsx, NewComponent.types.ts, index.ts
3. Create Storybook story: NewComponent.stories.tsx
4. Add tests: NewComponent.test.tsx
5. Export from main index files
$3
`bash
Run all tests
npm test
Run tests in watch mode
npm run test:watch
Run tests with coverage
npm run test:coverage
`
$3
`bash
Start Storybook development server
npm run storybook
Build Storybook for production
npm run build-storybook
`
Contributing
We welcome contributions! Please see our Contributing Guide for details.
1. Fork the repository
2. Create your feature branch (git checkout -b feature/amazing-feature)
3. Commit your changes (git commit -m 'Add some amazing feature')
4. Push to the branch (git push origin feature/amazing-feature`)