New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

@litemetrics/ui

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@litemetrics/ui

Pre-built React dashboard components for Litemetrics analytics

latest
Source
npmnpm
Version
0.1.1
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

@litemetrics/ui

Pre-built, themeable React dashboard components for Litemetrics analytics.

Chart Cards

Installation

bun add @litemetrics/ui @litemetrics/client @litemetrics/core
# peer dependencies
bun add react react-dom recharts @tanstack/react-query
# optional — for WorldMap widget
bun add react-simple-maps

Quick Start

import { LitemetricsProvider, AnalyticsDashboard } from '@litemetrics/ui';

function App() {
  return (
    <LitemetricsProvider
      baseUrl="https://your-server.com"
      siteId="your-site-id"
      secretKey="sk_..."
    >
      <AnalyticsDashboard />
    </LitemetricsProvider>
  );
}

Theming

All colors use CSS custom properties (--lm-*). The provider injects default light/dark theme variables automatically.

Custom Accent Color

<LitemetricsProvider
  baseUrl="..."
  siteId="..."
  theme={{ accent: '59 130 246' }}  // blue-500
>

Full Custom Theme

import type { LitemetricsTheme } from '@litemetrics/ui';

const myTheme: Partial<LitemetricsTheme> = {
  accent: '59 130 246',
  accentLight: '219 234 254',
  accentText: '29 78 216',
  bg: '255 255 255',
  text: '15 23 42',
};

<LitemetricsProvider theme={myTheme} darkTheme={{ accent: '96 165 250' }}>

Dark Mode

Add dark class to <html> or any parent element:

document.documentElement.classList.toggle('dark');

The components automatically switch to dark theme colors. You can also use .litemetrics-light and .litemetrics-dark classes for scoped theming.

CSS Variable Reference

All values are RGB triplets (e.g. 99 102 241). Use in your CSS as rgb(var(--lm-accent)).

VariableLight DefaultDescription
--lm-bg255 255 255Primary background
--lm-bg-secondary250 250 250Secondary background
--lm-bg-tertiary244 244 245Tertiary background
--lm-border228 228 231Border color
--lm-border-hover212 212 216Border hover color
--lm-text24 24 27Primary text
--lm-text-secondary113 113 122Secondary text
--lm-text-tertiary161 161 170Tertiary text
--lm-text-muted212 212 216Muted text
--lm-accent99 102 241Accent color (indigo)
--lm-accent-light238 242 255Accent background
--lm-accent-text67 56 202Accent text
--lm-accent-hover129 140 248Accent hover
--lm-positive5 150 105Positive change
--lm-negative239 68 68Negative change
--lm-chart-stroke99 102 241Chart line color
--lm-chart-fill99 102 241Chart fill color
--lm-chart-grid244 244 245Chart grid lines
--lm-chart-axis161 161 170Chart axis text
--lm-tooltip-bg24 24 27Tooltip background
--lm-tooltip-text255 255 255Tooltip text
--lm-tooltip-muted161 161 170Tooltip secondary text
--lm-bar238 242 255Top list bar fill
--lm-bar-hover224 231 255Top list bar hover
--lm-pie-1..8VariousPie chart colors
--lm-map-empty244 244 245Map empty country
--lm-map-stroke228 228 231Map border
--lm-map-hover129 140 248Map hover color

Components

Provider

PropTypeDefaultDescription
baseUrlstringrequiredLitemetrics server URL
siteIdstringrequiredSite ID
secretKeystring—Secret key for auth
defaultPeriodPeriod'7d'Initial time period
queryClientQueryClient—External React Query client
staleTimenumber30000Query stale time (ms)
themePartial<LitemetricsTheme>—Light theme overrides
darkThemePartial<LitemetricsTheme>—Dark theme overrides

Display Components

  • StatCard — Single metric card with comparison percentage
  • TopList — Ranked list with icons, bar fills, and tooltips
  • PieChartCard — Donut chart with legend
  • PeriodSelector — Time period toggle (1H, 24H, 7D, 30D, 90D, Custom)
  • DateRangePicker — Date range inputs
  • ExportButton — CSV / JSON / Markdown export

Smart Widgets

Pre-wired to fetch data via the provider context:

  • StatCards — Grid of 4 overview cards
  • TimeSeriesChart — Area chart with metric selector
  • TopPages, TopReferrers, TopCountries, TopEvents, TopBrowsers, TopDevices
  • BrowsersChart, DevicesChart — Pie chart variants
  • WorldMap — Interactive choropleth map (requires react-simple-maps)
  • AnalyticsDashboard — Complete dashboard combining all widgets

Hooks

HookDescription
useLitemetricsUI()Access provider context (client, period, etc.)
useStats(metric, opts?)Query stats for a specific metric
useTimeSeries(metric, opts?)Query time series data
useOverview(opts?)Query overview with period comparison
useThemeColors()Get theme colors for SVG/Recharts (auto-updates on dark mode toggle)

Peer Dependencies

PackageVersion
react>=18
react-dom>=18
recharts>=2
@tanstack/react-query>=5
tailwindcss>=3 (optional)
react-simple-maps>=3 (optional, for WorldMap)

License

MIT

Keywords

analytics

FAQs

Package last updated on 07 Feb 2026

Related posts