Skip to main content
Tw Twintrinsic
  • Getting Started
  • Components
  • Theming
  • Completion
Examples
Data Dashboard Game Map
Core
App
Layout
Accordion AccordionItem Card Container Panel Separator Sidebar Splitter
Navigation
AppHeader BottomBar Breadcrumb BreadcrumbItem Menu MenuItem Tabs Tab TabList TabPanel TreeMenu
Data Display
Avatar AvatarGroup Badge Carousel CarouselItem Chip ChipGroup CodeBlock CodeBlockSpeed CodeEditor DataTable Map Progress Skeleton Table TableBody TableCell TableHead TableHeader TableRow Tag TagGroup Timeline TimelineItem Tooltip Tree TreeNode
Metrics
DonutChart PieChart LineChart BarChart HorizontalBarChart AreaChart StatsCard MetricGrid KPICard GaugeChart ProgressMetric MetricTrend
Form
AutoComplete Button ButtonGroup Calendar Checkbox ColorPicker Combobox Dropdown FileUpload FloatLabel Form FormField Input InputSwitch InvalidState Knob ListInput Listbox NumberInput Radio RadioGroup Rating Select SelectGroup Slider Switch TextInput Textarea
Feedback
Modal Stepper StepperStep Toast
Utility
Icon Lazy LazyPanel Masonry ThemeToggle

HorizontalBarChart

A horizontal bar chart for displaying and comparing values. Ideal for long category names or when space is limited vertically.

Features

  • Horizontal bar layout
  • Grid lines for reference
  • Axis labels and title
  • Interactive bars with click events
  • Responsive sizing
  • Accessible with ARIA labels

Examples

Basic HorizontalBarChart

Browser Usage

013263952Chrome45Firefox38Safari52Edge41Other35
<script>
  import { HorizontalBarChart } from '$lib';

  const data = [45, 38, 52, 41, 35];
  const labels = ['Chrome', 'Firefox', 'Safari', 'Edge', 'Other'];
</script>

<HorizontalBarChart {data} {labels} title="Browser Usage" width={600} height={250} />

Props

PropTypeDefaultDescription
datanumber[]RequiredArray of numeric values
labelsstring[]RequiredArray of category labels
colorsstring[]Default paletteArray of colors
titlestringundefinedChart title
xAxisLabelstringundefinedX-axis label
showGridbooleantrueShow grid lines
widthnumber500Chart width in pixels
heightnumber300Chart height in pixels

Events

EventDetailDescription
onbarclick{ index: number; label: string; value: number }Fired when a bar is clicked

Best Practices

  • Use for categories with long names
  • Include axis labels for context
  • Enable grid lines for easier value reading