# Ambar UI — Full Component Sources for LLMs # Generated automatically from src/lib/components/ # Every component is a single .svelte file — copy, own, modify. # # Quick reference: /llms.txt # Docs: https://ambarui.vercel.app --- ## Accordion ```svelte
{#each items as item, i} {@const isOpen = open.has(item.value)}
{@render item.children()}
{/each}
``` --- ## Avatar ```svelte {#if showImg} {name (imgError = true)} /> {:else if showInit} {initials(name)} {:else} {/if} {#if status !== 'none'} {/if} ``` --- ## AvatarGroup ```svelte
{#each visible as av, i} {/each} {#if overflow > 0} +{overflow} {/if}
``` --- ## BarChart ```svelte
(hoverIdx = null)} > {#if svgW > 0} {#if grid} {#each yTicks as t} {/each} {/if} {#if hoverIdx !== null} {/if} {#if stacked} {#each labels as _lbl, gi} {@const totalH = stackedMaxes[gi] ?? 0} {@const bx = barX(gi, 0)} {@const totalPx = ((totalH - yMin) / (yMax - yMin)) * cH} {@const animH = animated ? totalPx : 0} {@const animY = P.t + cH - animH} {#each series as s, si} {@const val = s.data[gi] ?? 0} {@const c = s.color ?? COLORS[si % COLORS.length]} {@const segH = ((val - yMin) / (yMax - yMin)) * cH} {@const prevH = series.slice(0, si).reduce((acc, sr) => acc + ((sr.data[gi] ?? 0) / (yMax - yMin)) * cH, 0)} {@const realY = P.t + cH - prevH - segH} {@const dispH = animated ? segH : 0} {@const dispY = animated ? realY : P.t + cH} {/each} {/each} {:else} {#each series as s, si} {@const c = s.color ?? COLORS[si % COLORS.length]} {#each labels as _lbl, gi} {@const val = s.data[gi] ?? 0} {@const bx = barX(gi, si)} {@const fullH = Math.max(0, ((val - yMin) / (yMax - yMin)) * cH)} {@const dispH = animated ? fullH : 0} {@const dispY = animated ? sy(val) : P.t + cH} {/each} {/each} {/if} {#each yTicks as t} {fmt(t)} {/each} {#each labels as lbl, i} {@const skip = Math.max(1, Math.ceil(labels.length / Math.max(1, Math.floor(cW / 52))))} {#if i % skip === 0 || i === labels.length - 1} {lbl} {/if} {/each} {#if hoverIdx !== null} {@const flip = tip.x > svgW * 0.6}

{labels[hoverIdx]}

{#if stacked} {@const total = stackedMaxes[hoverIdx] ?? 0} {#each series as s, i} {@const c = s.color ?? COLORS[i % COLORS.length]}
{s.label} {fmt(s.data[hoverIdx] ?? 0)}
{/each}
Total {fmt(total)}
{:else} {#each series as s, i} {@const c = s.color ?? COLORS[i % COLORS.length]}
{s.label} {fmt(s.data[hoverIdx] ?? 0)}
{/each} {/if}
{/if} {#if series.length > 1}
{#each series as s, i} {@const c = s.color ?? COLORS[i % COLORS.length]}
{s.label}
{/each}
{/if} {/if}
``` --- ## Breadcrumb ```svelte ``` --- ## Button ```svelte {#if href} {#if loading} {/if} {#if children} {@render children()} {/if} {:else} {/if} ``` --- ## CandlestickChart ```svelte
(hoverIdx = null)} > {#if svgW > 0} {#if grid} {#each yTicks as t} {/each} {/if} {#if hoverIdx !== null} {/if} {#each candles as c, i} {@const bull = c.close >= c.open} {@const color = bull ? BULL : BEAR} {@const x = cx2(i)} {@const bodyTop = sy(Math.max(c.open, c.close))} {@const bodyBottom = sy(Math.min(c.open, c.close))} {@const rawH = Math.max(1, bodyBottom - bodyTop)} {@const isHov = hoverIdx === i} {@const animBodyTop = animated ? bodyTop : sy((c.open + c.close) / 2)} {@const animBodyH = animated ? rawH : 0} {@const animHigh = animated ? sy(c.high) : sy((c.open + c.close) / 2)} {@const animLow = animated ? sy(c.low) : sy((c.open + c.close) / 2)} {@const delay = `${i * 18}ms`} {/each} {#if volume} {#each candles as c, i} {@const bull = c.close >= c.open} {@const color = bull ? BULL : BEAR} {@const vol = c.volume ?? 0} {@const fullH = maxVol > 0 ? (vol / maxVol) * volH : 0} {@const dispH = animated ? fullH : 0} {@const dispY = volTopY + volH - dispH} {@const delay = `${i * 18 + 80}ms`} {/each} {/if} {#each yTicks as t} {fmt(t)} {/each} {#each candles as c, i} {@const skip = Math.max(1, Math.ceil(candles.length / Math.max(1, Math.floor(cW / 56))))} {#if i % skip === 0 || i === candles.length - 1} {c.date} {/if} {/each} {/if}
``` --- ## Checkbox ```svelte ``` --- ## Dialog ```svelte
{#if visible} {/if}
``` --- ## DonutChart ```svelte
(hoverIdx = null)} > {#each computed as sl, i} {/each}
{#if hoverIdx !== null} {@const sl = computed[hoverIdx]} {fmt(sl.value)} {sl.label} {(sl.pct * 100).toFixed(1)}% {:else if centerValue} {centerValue} {#if centerLabel} {centerLabel} {/if} {:else if centerLabel} {centerLabel} {/if}
{#each computed as sl, i}
(hoverIdx = i)} onmouseleave={() => (hoverIdx = null)} > {sl.label} {fmt(sl.value)}
{/each}
``` --- ## Drawer ```svelte
{#if visible} {/if}
``` --- ## Dropdown ```svelte {@render trigger({ toggle, open })}
{#if open} {#if subIdx >= 0 && items[subIdx]?.children} {/if} {/if}
``` --- ## EmptyState ```svelte
{#if icon} {@render icon()} {:else if preset !== 'custom'} {/if}
{#if title}

{title}

{/if} {#if description}

{description}

{/if} {#if children} {@render children()} {/if} {#if action} {/if}
``` --- ## Flex ```svelte {@render children()} ``` --- ## GlobeChart ```svelte
{#if loading}
Loading…
{/if}
Drag to rotate
{#if hoverId !== null} {@const name = COUNTRY_NAMES[hoverId] ?? 'Unknown'} {@const nd = buildNumericData()} {@const val = nd[hoverId]} {@const flip = tipX > size * 0.6}

{name}

{#if val !== undefined}

{fmt(val)}

{:else}

No data

{/if}
{/if}
``` --- ## Grid ```svelte {@render children()} ``` --- ## HStack ```svelte {@render children()} ``` --- ## HeatMap ```svelte
{#each monthLabels as { text, wi }} {text} {/each} {#each Object.entries(DAY_LABELS) as [di, name]} {name} {/each} {#each weeks as week, wi} {#each week as cell, di} {@const today = new Date()} {@const isFuture = cell.date > today} {@const op = isFuture ? 0 : cellOpacity(cell.key)} {@const isHov = hoverKey === cell.key} 0.1 ? color : 'none'} stroke-width={isHov ? 1.5 : 0} stroke-opacity="0.6" style:transition="opacity 0.3s ease {wi * 16}ms" style:cursor="default" onmouseenter={(e) => onEnter(cell, e)} onmousemove={onMove} /> {/each} {/each}
Less {#each legendSteps as t} {/each} More
{#if hoverCell !== null} {@const val = data[hoverCell.key]} {@const flip = tipX > svgW * 0.6}

{fmtDate(hoverCell.date)}

{#if val !== undefined && val > 0}

{label}{fmt(val)}

{:else}

No activity

{/if}
{/if}
``` --- ## Input ```svelte
{#if label} {/if}
{#if start} {@render start()} {:else if type === 'search'} {/if} {#if prefix} {prefix} {/if}
(focused = true)} onblur={() => (focused = false)} oninput={handleInput} />
{#if suffix} {suffix} {/if} {#if clearable && value && !disabled} {/if} {#if type === 'password'} {/if} {#if end} {@render end()} {/if}
{#if error}

{error}

{:else if hint}

{hint}

{/if}
``` --- ## Like ```svelte ``` --- ## LineChart ```svelte
(hoverIdx = null)} > {#if svgW > 0} {#each series as s, i} {#if s.area} {@const c = s.color ?? COLORS[i % COLORS.length]} {/if} {/each} {#if grid} {#each yTicks as t} {/each} {/if} {#each series as s, i} {#if s.area} {/if} {/each} {#each series as s, i} {@const c = s.color ?? COLORS[i % COLORS.length]} {@const len = lengths[i] ?? 0} 0 ? len : undefined} stroke-dashoffset={len > 0 ? (animated ? 0 : len) : undefined} style="transition:stroke-dashoffset 1.2s cubic-bezier(.16,1,.3,1) {i * 100}ms" /> {/each} {#if hoverIdx !== null} {#each series as s, i} {@const c = s.color ?? COLORS[i % COLORS.length]} {/each} {/if} {#each yTicks as t} {fmt(t)} {/each} {#each labels as lbl, i} {@const skip = Math.max(1, Math.ceil(labels.length / Math.max(1, Math.floor(cW / 52))))} {#if i % skip === 0 || i === labels.length - 1} {lbl} {/if} {/each} {#if hoverIdx !== null} {@const flip = tip.x > svgW * 0.6}

{labels[hoverIdx]}

{#each series as s, i} {@const c = s.color ?? COLORS[i % COLORS.length]}
{s.label} {fmt(s.data[hoverIdx] ?? 0)}
{/each}
{/if} {#if series.length > 1}
{#each series as s, i} {@const c = s.color ?? COLORS[i % COLORS.length]}
{s.label}
{/each}
{/if} {/if}
``` --- ## Link ```svelte {#if icon && iconSide === 'left'} {/if} {#if children} {@render children()} {/if} {#if external} {:else if icon && iconSide === 'right'} {/if} ``` --- ## List ```svelte
{#each items as item (item.id)} {/each}
``` --- ## OtpInput ```svelte
{#each Array(length) as _, i} onInput(i, e)} onkeydown={(e) => onKeydown(i, e)} onfocus={(e) => (e.target as HTMLInputElement).select()} onpaste={onPaste} aria-label="Digit {i + 1}" /> {/each}
{#if error}

{error}

{/if}
``` --- ## Popover ```svelte {@render trigger({ toggle, open })}
{#if open} {/if}
``` --- ## Progress ```svelte {#if label || showValue}
{#if label}{label}{/if} {#if showValue}{Math.round(pct)}%{/if}
{/if}
{#if indeterminate}
{:else}
{/if}
``` --- ## Radio ```svelte ``` --- ## RadioGroup ```svelte {#if variant === 'default'}
{#each options as opt} {@const checked = value === opt.value} {/each}
{:else if variant === 'card'}
{#each options as opt} {@const checked = value === opt.value} {/each}
{:else if variant === 'button'}
{#each options as opt} {@const checked = value === opt.value} {/each}
{/if} ``` --- ## RealtimeLineChart ```svelte
(hoverIdx = null)} > {#if svgW > 0}
{label} {fmt(current)} {change >= 0 ? '+' : ''}{fmt(change)} ({pct >= 0 ? '+' : ''}{pct.toFixed(2)}%)
LIVE
{#each yTicks as t} {@const ty = sy(t)} {#if ty >= P.t && ty <= P.t + cH} {/if} {/each} {#if sy(current) >= P.t && sy(current) <= P.t + cH} {@const cy2 = sy(current)} {/if} {#if hoverIdx !== null} {@const hx = sx(hoverIdx)} {@const hy = sy(renderPrices[hoverIdx])} {#if hx >= P.l - 1 && hx <= P.l + cW + 1} {/if} {/if} {#each yTicks as t} {@const ty = sy(t)} {#if ty >= P.t + 8 && ty <= P.t + cH - 8} {#if Math.abs(ty - sy(current)) > 14} {fmt(t)} {/if} {/if} {/each} {#if sy(current) >= P.t && sy(current) <= P.t + cH} {@const ly = sy(current)} {fmt(current)} {/if} {#if hoverIdx !== null} {@const hx = sx(hoverIdx)} {#if hx >= P.l && hx <= P.l + cW} {@const flip = tipX > svgW * 0.55}
{fmt(renderPrices[hoverIdx])}
{/if} {/if} {/if}
``` --- ## Search ```svelte
{#if loading} {:else} {/if} {#if !collapsed} { focused = true; if (shouldOpen()) openDrop(); }} onblur={() => { focused = false; if (expandable && !value.trim()) { setTimeout(() => { expanded = false; closeDrop(); }, 150); } }} oninput={handleInput} /> {#if command && !value && !focused} {shortcut} {/if} {#if value} {/if} {/if}
{#if open}
e.stopPropagation()} > {#if !value && recent.length > 0}
{#each recent as q, i}
(focusIdx = i)} onclick={() => selectRecent(q)} > {q} removeRecent(q, e)} >
{/each} {:else if value && loading}
{:else if value && !loading && items.length === 0}

{emptyText}

"{value}" için sonuç yok

{:else if value && items.length > 0} {#each grouped as [cat, catItems], gi} {#if cat} {/if} {#each catItems as item} {@const idx = items.indexOf(item)}
(focusIdx = idx)} onclick={() => selectItem(item)} > {#if item.icon} {@render item.icon()} {:else} {/if} {@html hl(item.label, value)} {#if item.description} {item.description} {/if} {#if item.badge} {item.badge} {/if}
{/each} {#if gi < grouped.length - 1}
{/if} {/each} {/if}
{/if}
``` --- ## Select ```svelte
{#if label} {/if} {#if error}

{error}

{:else if hint}

{hint}

{/if}
{#if open}
{ if (e.target === e.currentTarget) closeDrop(); }}>
e.stopPropagation()} > {#if searchable}
{/if}
{#if flatFiltered.length === 0}

Sonuç bulunamadı.

{:else} {#each filteredGroups as item} {#if isGroup(item)}

{item.group}

{#each item.options as opt} {@const isActive = flatFiltered.indexOf(opt) === activeIdx} {/each} {:else} {@const isActive = flatFiltered.indexOf(item) === activeIdx} {/if} {/each} {/if}
{/if}
``` --- ## Sheet ```svelte
{#if visible}
{#if title}

{title}

{/if}
{@render children()}
{#if footer} {/if}
{/if}
``` --- ## Sidebar ```svelte {#if isMobile && open} {/if} ``` --- ## Skeleton ```svelte {#if shape === 'text'}
{#each Array(lines) as _, i}
{/each}
{:else if shape === 'circle'}
{:else}
{/if} ``` --- ## Slider ```svelte
{#if label || showValue}
{#if label} {label} {/if} {#if showValue} {display} {/if}
{/if}
{#if dragging}
{display}
{/if}
{#if hint}

{hint}

{/if}
``` --- ## Spacer ```svelte ``` --- ## Sparkline ```svelte
(hoverIdx = null)} > {#if area} {/if} {#if minmax && vals.length > 1} {/if} {#if hoverIdx !== null} {/if} {#if value} {current % 1 === 0 ? current : current.toFixed(2)} {/if} {#if hoverIdx !== null}
{vals[hoverIdx] % 1 === 0 ? vals[hoverIdx] : vals[hoverIdx].toFixed(2)}
{/if}
``` --- ## Spinner ```svelte {#if variant === 'ring'} {:else if variant === 'ring-dual'} {:else if variant === 'ring-split'} {:else if variant === 'ring-track'} {:else if variant === 'dots'} {:else if variant === 'bounce'} {:else if variant === 'pulse'} {:else if variant === 'bars'} {:else if variant === 'wave'} {:else if variant === 'ripple'} {:else if variant === 'orbit'} {/if} ``` --- ## Switch ```svelte ``` --- ## Tabs ```svelte
{#if variant === 'line'}
{:else if variant === 'pill'}
{/if} {#each tabs as tab} {/each}
``` --- ## Text ```svelte {@render children()} ``` --- ## Textarea ```svelte
{#if label} {/if}
{#if error}

{error}

{:else if hint}

{hint}

{:else} {/if} {#if maxlength} {value.length}/{maxlength} {/if}
``` --- ## Toast ```svelte
{#each toastStore.toasts as toast (toast.id)}
{toast.message}
{/each}
``` --- ## Tooltip ```svelte {@render children()}
{#if visible} {/if}
``` --- ## VStack ```svelte {@render children()} ``` ---