# Ambar UI — Component Library Reference for LLMs
Ambar UI is a copy-paste component library for **Svelte 5** + **Tailwind CSS v4**.
All components are single `.svelte` files with no runtime npm dependencies.
Import from `$lib/components/ComponentName.svelte`.
---
## Setup
```svelte
@theme inline {
--color-accent: oklch(0.6 0.2 265);
}
```
---
## Components
### Button
```svelte
import Button from '$lib/components/Button.svelte';
```
Props: `variant` (primary|secondary|outline|ghost|danger|icon), `size` (sm|md|lg|icon), `href`, `external`, `disabled`, `loading`, `fullWidth`, `ariaLabel`, `onclick`, `class`
---
### Input
```svelte
import Input from '$lib/components/Input.svelte';
```
Props: `value` ($bindable), `type` (text|email|password|search|url|tel|number), `label`, `placeholder`, `hint`, `error`, `disabled`, `clearable`, `prefix`, `suffix`, `start` (Snippet), `end` (Snippet), `onvalue`
---
### Textarea
```svelte
import Textarea from '$lib/components/Textarea.svelte';
```
Props: `value` ($bindable), `label`, `placeholder`, `hint`, `error`, `rows`, `maxLength`, `showCount`, `autoResize`, `disabled`
---
### Select
```svelte
import Select from '$lib/components/Select.svelte';
const options = [
{ value: 'admin', label: 'Admin' },
{ value: 'user', label: 'User' },
];
// With groups:
const grouped = [
{ group: 'Entertainment', options: [{ value: 'music', label: 'Music', icon: '🎵' }] },
];
```
Props: `value` ($bindable), `options` (Option[]|OptionGroup[]), `label`, `placeholder`, `hint`, `error`, `disabled`, `searchable`, `animation` (slide|scale|elastic|fade|flip)
---
### Checkbox
```svelte
import Checkbox from '$lib/components/Checkbox.svelte';
```
Props: `checked` ($bindable), `label`, `hint`, `disabled`, `indeterminate`, `onchange`
---
### Switch
```svelte
import Switch from '$lib/components/Switch.svelte';
```
Props: `checked` ($bindable), `label`, `hint`, `size` (sm|md|lg), `disabled`, `onchange`
---
### Radio / RadioGroup
```svelte
import Radio from '$lib/components/Radio.svelte';
let plan = $state('free');
```
Props: `value`, `group` ($bindable), `label`, `hint`, `disabled`, `onchange`
---
### Slider
```svelte
import Slider from '$lib/components/Slider.svelte';
```
Props: `value` ($bindable), `min`, `max`, `step`, `label`, `hint`, `showValue`, `disabled`, `animation` (none|smooth|spring|elastic|bounce|snappy), `onchange`
---
### OTP Input
```svelte
import OtpInput from '$lib/components/OtpInput.svelte';
verify(v)} />
```
Props: `value` ($bindable), `length` (default 6), `error`, `disabled`, `onComplete`
---
### Search
```svelte
import Search from '$lib/components/Search.svelte';
const items = [
{ id: 1, label: 'Dashboard', category: 'Pages' },
{ id: 2, label: 'Settings', category: 'Pages' },
];
```
Props: `value` ($bindable), `placeholder`, `size` (sm|md|lg), `items` (SearchItem[]), `loading`, `debounce`, `command`, `shortcut`, `expandable`, `onSearch`
---
### Accordion
```svelte
import Accordion from '$lib/components/Accordion.svelte';
const items = [
{
value: 'q1',
title: 'What is Ambar UI?',
children: mySnippet, // Svelte snippet
},
];
```
Props: `items` (Item[]), `multiple`, `variant` (default|card|flush), `animation` (smooth|spring|snappy|elastic|bounce), `defaultOpen`
Item type: `{ value, title, hint?, icon?: Snippet, disabled?, children: Snippet }`
---
### Tabs
```svelte
import Tabs from '$lib/components/Tabs.svelte';
const tabs = [
{ value: 'overview', label: 'Overview' },
{ value: 'analytics', label: 'Analytics' },
{ value: 'settings', label: 'Settings', disabled: true },
];
```
Props: `value` ($bindable), `tabs` (Tab[]), `variant`, `animation`
---
### Dialog
```svelte
import Dialog from '$lib/components/Dialog.svelte';
let open = $state(false);
```
Props: `open`, `onClose`, `children` (Snippet), `variant` (center|elastic|flip|rotate|zoom|slide-left|slide-right|fade-up|newspaper|swing|morph|alert|bottom-sheet|shrink|dropdown|fullscreen)
---
### Drawer
```svelte
import Drawer from '$lib/components/Drawer.svelte';
let open = $state(false);
open = false} title="Settings">
Content here
open = false} side="left" size="lg" title="Menu">
Nav content
```
Props: `open`, `onClose`, `side` (right|left|top|bottom), `size` (sm|md|lg|xl|full), `title`, `children` (Snippet), `footer` (Snippet)
---
### Sheet (Bottom Sheet)
```svelte
import Sheet from '$lib/components/Sheet.svelte';
let open = $state(false);
open = false} title="Share">
Content
```
Props: `open`, `onClose`, `title`, `size` (sm|md|lg|xl), `children` (Snippet), `footer` (Snippet)
---
### Dropdown
```svelte
import Dropdown from '$lib/components/Dropdown.svelte';
const items = [
{ label: 'Edit', onclick: () => edit() },
{ label: 'Share', onclick: () => share() },
{ type: 'divider' },
{ label: 'Delete', danger: true, onclick: () => del() },
];
{#snippet trigger({ toggle })}
{/snippet}
```
Props: `items` (DropdownItem[]), `placement`, `animation` (scale|slide|elastic|bounce|zoom), `offset`, `trigger` (Snippet)
DropdownItem: `{ type?: 'item'|'divider'|'label', label?, icon?: Snippet, shortcut?, hint?, danger?, disabled?, onclick? }`
---
### Popover
```svelte
import Popover from '$lib/components/Popover.svelte';
{#snippet trigger({ toggle })}
{/snippet}
Popover content
```
Props: `open` ($bindable), `placement` (top|bottom|left|right|top-start|top-end|bottom-start|bottom-end), `offset`, `arrow`, `animation` (scale|slide|elastic|flip|bounce|zoom), `trigger` (Snippet), `children` (Snippet)
---
### Tooltip
```svelte
import Tooltip from '$lib/components/Tooltip.svelte';
Shipping info
```
Props: `content` (string|Snippet), `placement`, `delay` (300), `offset` (8), `disabled`, `children` (Snippet)
---
### Toast
```svelte
import { toastStore } from '$lib/stores/toast.svelte';
import Toast from '$lib/components/Toast.svelte';
// In root layout — renders the toast container:
// Anywhere in the app — trigger toasts:
toastStore.show('Saved!', 'success');
toastStore.show('Something went wrong', 'error');
toastStore.show('New message', 'info');
toastStore.show('Low storage', 'warning');
```
---
### Avatar
```svelte
import Avatar from '$lib/components/Avatar.svelte';
import AvatarGroup from '$lib/components/AvatarGroup.svelte';
```
Props (Avatar): `src`, `name`, `size` (xs|sm|md|lg|xl|2xl), `shape` (circle|square), `status` (online|away|busy|offline|none), `class`
---
### Progress
```svelte
import Progress from '$lib/components/Progress.svelte';
```
Props: `value`, `max` (100), `size` (xs|sm|md|lg), `variant` (accent|success|warning|danger|info), `animation` (smooth|spring|bounce|none), `striped`, `indeterminate`, `label`, `showValue`
---
### Spinner
```svelte
import Spinner from '$lib/components/Spinner.svelte';
```
Props: `variant` (ring|ring-dual|ring-split|ring-track|dots|bounce|pulse|bars|wave|ripple|orbit), `size` (xs|sm|md|lg|xl), `color`
---
### Skeleton
```svelte
import Skeleton from '$lib/components/Skeleton.svelte';
```
Props: `shape` (rect|circle|text), `animation` (shimmer|pulse|wave|blink|glow|none), `width`, `height`, `radius`, `lines`, `delay`, `class`
---
### Link
```svelte
import Link from '$lib/components/Link.svelte';
Default underline
Pill link
Button-style
External
Highlight on hover
```
Props: `href`, `variant` (inline|accent|muted|underline|double|dotted|dashed|wavy|overline|over-under|strike|strike-soft|mark|reveal|pill|button|icon), `size`, `external`, `motion` (none|line|scan|dash|pulse|glint|highlight)
---
### Like (Heart Button)
```svelte
import Like from '$lib/components/Like.svelte';
updateLike(v)} />
```
Props: `liked` ($bindable), `count` ($bindable), `showCount`, `size` (sm|md|lg), `onchange`
---
### Breadcrumb
```svelte
import Breadcrumb from '$lib/components/Breadcrumb.svelte';
const items = [
{ label: 'Home', href: '/' },
{ label: 'Products', href: '/products' },
{ label: 'Sneakers' },
];
```
Props: `items` (BreadcrumbItem[]), `separator` (slash|chevron|dot|arrow), `size` (sm|md|lg), `itemStyle` (plain|soft|pill), `maxVisible`
---
### List
```svelte
import List from '$lib/components/List.svelte';
const items = [
{ id: '1', label: 'Item one', description: 'Description' },
{ id: '2', label: 'Item two' },
];
console.log(item)} />
```
Props: `items` (ListItem[]), `variant` (default|soft|card), `density` (compact|default|roomy), `columns` (1|2|3|4), `animated`, `onselect`
---
### Empty State
```svelte
import EmptyState from '$lib/components/EmptyState.svelte';
```
Props: `preset` (inbox|search|data|folder|users|error|custom), `title`, `description`, `action` ({label, onclick}), `size` (sm|md|lg), `icon` (Snippet)
---
### Sidebar
```svelte
import Sidebar from '$lib/components/Sidebar.svelte';
const sections = [
{
title: 'Main',
items: [
{ id: 'home', label: 'Home', icon: 'M3 9l9-7 9 7v11a2...' },
{ id: 'analytics',label: 'Analytics',icon: 'M18 20V10M12 20V4...' },
],
},
];
let active = $state('home');
navigate(id)} />
```
Props: `sections` (NavSection[]), `active` ($bindable), `collapsed` ($bindable), `open` ($bindable), `width`, `variant` (default|floating|inset), `itemStyle` (default|filled|outline|ghost), `activeIndicator` (bar|track|none), `animation`, `collapsible` (icon|offcanvas|none), `header` (Snippet), `footer` (Snippet), `onselect`
---
### Layout Primitives (Flex / Grid / HStack / VStack / Spacer)
```svelte
import Flex from '$lib/components/Flex.svelte';
import Grid from '$lib/components/Grid.svelte';
import HStack from '$lib/components/HStack.svelte';
import VStack from '$lib/components/VStack.svelte';
import Spacer from '$lib/components/Spacer.svelte';
Jane Doe
Admin
...
```
---
### Charts
#### BarChart
```svelte
import BarChart from '$lib/components/BarChart.svelte';
const labels = ['Jan','Feb','Mar'];
const series = [{ label: 'Sales', data: [42, 58, 73] }];
```
Props: `labels`, `series` (BarSeries[]), `height` (260), `grid`, `stacked`, `class`
#### LineChart
```svelte
import LineChart from '$lib/components/LineChart.svelte';
const series = [{ label: 'Views', data: [1200,1900,1500], area: true }];
```
Props: `labels`, `series` (LineSeries[]), `height` (260), `smooth` (true), `grid`, `class`
#### DonutChart
```svelte
import DonutChart from '$lib/components/DonutChart.svelte';
const slices = [{ label: 'A', value: 40 }, { label: 'B', value: 60 }];
```
Props: `slices` (DonutSlice[]), `size` (220), `thickness` (44), `centerLabel`, `centerValue`, `class`
#### Sparkline
```svelte
import Sparkline from '$lib/components/Sparkline.svelte';
```
Props: `data: number[]`, `width`, `height`, `color`, `area`, `value`, `minmax`, `class`
#### HeatMap
```svelte
import HeatMap from '$lib/components/HeatMap.svelte';
// data: Record<'YYYY-MM-DD', number>
```
Props: `data`, `label`, `color`, `cellSize` (12), `gap` (3), `class`
#### CandlestickChart
```svelte
import CandlestickChart from '$lib/components/CandlestickChart.svelte';
// candles: Candle[] — { date, open, high, low, close, volume? }
```
#### RealtimeLineChart
```svelte
import RealtimeLineChart from '$lib/components/RealtimeLineChart.svelte';
```
#### GlobeChart
```svelte
import GlobeChart from '$lib/components/GlobeChart.svelte';
// data: Record
```
---
## Theme Variables Reference
```css
--background /* page background */
--foreground /* primary text */
--card /* card / panel bg */
--muted /* subtle bg, code blocks */
--muted-foreground /* secondary text */
--border /* borders */
--accent /* brand / interactive */
--accent-foreground /* text on accent bg */
--secondary /* hover / chip bg */
--destructive /* error red */
```
Dark mode: add `html.dark` class to ``.
Toggle: `themeStore.toggleMode()` from `$lib/stores/theme.svelte`.
---
## File Structure
```
src/lib/components/ ← all component .svelte files
src/lib/stores/
theme.svelte ← themeStore (mode, accent, font)
toast.svelte ← toastStore (show, dismiss)
src/app.css ← @theme inline, global styles
```