# Sveltier
> A Svelte 5 UI framework with five built-in design languages, a zero-dependency theme engine and flash-free server-side theming.
## Setup
```sh
pnpm add sveltier
```
```svelte
{@render children()}
```
## Conventions
Install `sveltier`, wrap the app in `UIProvider` with at least one theme pack (for example `monolith` from `sveltier/themes/monolith`), and import components from `sveltier`.
- Svelte 5 only: runes (`$state`, `$derived`, `$effect`, `$props`, `$bindable`), snippets and callback props. Never write Svelte 4 syntax: no `export let`, no `on:click` (use `onclick`), no `` (use snippets and `{@render}`), no `createEventDispatcher`, no `$:`. Svelte's own tools for agents, including an MCP server and an autofixer, are listed at https://svelte.dev/docs/ai.
- Every component takes the same names for the same things: `variant` (elevated, flat, tonal, outlined, text, plain), `size` (xs to xl), `density` (compact, default, comfortable), `color` (an intent such as primary or error, neutral, or a custom colour), `rounded`, `disabled`, `loading`.
- Content goes in snippets (`children`, `prepend`, `append`, `actions`), events are callback props (`onclick`), and two-way values use `bind:` (`bind:value`, `bind:selected`, `bind:open`).
- Every component passes other attributes to its root element, merges `class`, and exposes the element as a bindable `ref`. Form fields are the exception: their attributes and `ref` go to the native control (`name`, `placeholder`, `autocomplete` reach the ``), while `class` and `style` stay on the field.
- Form fields validate with the HTML constraints first (`required`, `minlength`, `maxlength`, `pattern`, `type="email"`), then `rules` (functions returning `true` or a message), and show `error` from outside (a server's answer) as given. Messages appear when the user leaves a field they changed, then follow every change.
- Defaults for a whole app or section go in the `defaults` of `UIProvider` or a `DefaultsProvider`, by component name; a prop on the component still wins.
- Style your own elements with the theme's CSS variables, never fixed values: `--sv-color-*` for colour, `--sv-space-*` for spacing, `--sv-radius-md` for one-line controls. A theme may make `--sv-radius-md` a pill, so a box that grows with its content takes `min(var(--sv-radius-md), var(--sv-radius-lg))`.
## Components
### Alert
Docs: ./components/alert
A message about something that happened or needs attention.
```svelte
The card ending 4471 was declined by the issuer.
{#snippet actions()}
{/snippet}
Transfer sent.
```
`AlertProps`:
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `variant` | `'elevated' \| 'flat' \| 'tonal' \| 'outlined' \| 'text' \| 'plain'` | `'tonal'` | Visual weight. |
| `color` | `Color` | `'info'` | The colour, when there is no `type` to take it from. |
| `density` | `'compact' \| 'default' \| 'comfortable'` | `'default'` | Multiplies the padding. |
| `rounded` | `boolean \| 'none' \| 'sm' \| 'md' \| 'lg' \| 'xl' \| 'full'` | `true` | Corner rounding. `true` keeps the theme's radius. |
| `type` | `'info' \| 'success' \| 'warning' \| 'error'` | | What kind of message: sets the colour and the icon. Warnings and errors are announced at once (`role="alert"`), the others politely (`role="status"`). |
| `title` | `string` | | A short summary, above the text. |
| `icon` | `boolean` | `true` | Shows the icon of the `type`. |
| `open` | `boolean` | `true` | Shown while true; a closable alert sets it to false. Bindable. |
| `closable` | `boolean` | `false` | Adds a button that closes the alert and calls `onclose`. |
| `closeLabel` | `string` | | The name of the close button. Defaults to the locale's `close`. |
| `onclose` | `() => void` | | Called when the close button closes the alert. |
| `prepend` | `Snippet` | | Content in place of the type's icon. |
| `actions` | `Snippet` | | Buttons or links after the text, such as `Retry`. |
| `children` | `Snippet` | | The message. |
| `class` | `ClassValue \| null` | | Classes added after the component's own: a string, an array or an object. |
| `ref` | `HTMLDivElement \| null` | | The root element, bindable with `bind:ref`. |
### Avatar
Docs: ./components/avatar
A picture of a person or an account: an image, or initials or an icon when there is none
or it fails to load.
```svelte
AM Alex Morgan
AM
```
`AvatarProps`:
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `size` | `'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl'` | `'md'` | Width and height: the control height of the size. |
| `variant` | `'elevated' \| 'flat' \| 'tonal' \| 'outlined' \| 'text' \| 'plain'` | `'tonal'` | How the fallback is painted. |
| `color` | `Color` | `'neutral'` | The colour of the fallback. |
| `rounded` | `boolean \| 'none' \| 'sm' \| 'md' \| 'lg' \| 'xl' \| 'full'` | `'full'` | Corner rounding. |
| `src` | `string` | | The image. |
| `alt` | `string` | | Who or what the avatar shows, for screen readers. Leave it out when a name is shown next to the avatar: it is then decorative and hidden from them. |
| `children` | `Snippet` | | Initials or an icon, shown while there is no image or it failed to load. |
| `class` | `ClassValue \| null` | | Classes added after the component's own: a string, an array or an object. |
| `ref` | `HTMLSpanElement \| null` | | The root element, bindable with `bind:ref`. |
### Badge
Docs: ./components/badge
A count or a dot pinned to the top end corner of its content, or standing alone in a line
when it has none. A count of 0 hides it.
```svelte
Savings
```
`BadgeProps`:
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `color` | `Color` | `'primary'` | The badge's fill. |
| `max` | `number` | `99` | Counts above it show as `max+`. |
| `content` | `number \| string` | | What the badge says: usually a count. |
| `dot` | `boolean` | `false` | A dot instead of the content. |
| `label` | `string` | | What the content counts, read after it by screen readers: `unread messages` reads "3 unread messages". With `dot`, the whole announcement. With an `id`, this text has the id `{id}-label`, for the `aria-describedby` of a button the badge is pinned to. |
| `children` | `Snippet` | | The content the badge is pinned to. |
| `class` | `ClassValue \| null` | | Classes added after the component's own: a string, an array or an object. |
| `ref` | `HTMLSpanElement \| null` | | The root element, bindable with `bind:ref`. |
### Button
Docs: ./components/button
A button, or a link that looks like one (`href`). Every other attribute of `