> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# UI Components

**UI components** are ready-made buttons, form controls, dialogs, charts and more for AngularLynx apps. A CLI copies their source into your project, so you own the code and can change anything. It's the same idea as [shadcn/ui](https://ui.shadcn.com/).

Two package names are involved:

- **`@blotch/ui`** is the component source. You never install it.
- **`@blotch/dolan`** is the CLI. It carries a copy of that source and writes it into `src/components/ui/`.

## Before you start

The components are styled with Tailwind CSS. If you said yes to Tailwind when you created the app, you're ready. Otherwise, set it up first: see [Tailwind CSS](/guide/tailwindcss.md).

## Installation

**1. Set up dolan.**

```bash
npx @blotch/dolan init
```

Press Enter to accept both default folders. It writes `dolan.config.json`, copies three theme files into `src/styles/`, and installs `@blotch/dolan` as a dependency:

- `default.css`: the light theme's colors, corner radius and text size
- `dark.css`: the dark theme's colors
- `tailwind.css`: maps those colors to Tailwind classes such as `bg-primary`. An app on Tailwind 3 gets `tailwind-plugin.ts`, a Tailwind plugin, instead.

Copied components import `cn()` and animation helpers from `@blotch/dolan`, so your app needs it to build, not only to run commands. Once it's installed, `npx dolan` runs it too.

In CI, a script or an AI agent, `init` asks nothing and takes the default folders. Add `--yes` to skip the questions in a terminal too, and `--components` or `--theme` to choose other folders. See [`init`](/dolan/cli/index.md#init).

**2. Import the theme**, after Tailwind's own imports:

```css title="src/styles.css"
@layer theme, base, components, utilities;
@import 'tailwindcss/theme.css' layer(theme);
@import 'tailwindcss/utilities.css' layer(utilities);
@import '@blotch/angular-lynx/tailwind.css';
@import './styles/default.css'; /* [!code highlight] */
@import './styles/dark.css'; /* [!code highlight] */
@import './styles/tailwind.css'; /* [!code highlight] */
```

With `dark.css` imported, the app follows the phone's light or dark appearance. See [Theming](/dolan/theming.md#dark-mode).

**3. On Tailwind 3**, add the Tailwind plugin to your config instead, and import only the colors:

```typescript title="tailwind.config.ts"
import type { Config } from 'tailwindcss';
import preset from '@lynx-js/tailwind-preset';
import { blotchPlugin } from './src/styles/tailwind-plugin'; // [!code highlight]

const config: Config = {
  content: ['./src/**/*.{html,ts}'],
  presets: [preset],
  plugins: [blotchPlugin], // [!code highlight]
};

export default config;
```

```css title="src/styles.css"
@import './styles/default.css';
@import './styles/dark.css';

@tailwind base;
@tailwind utilities;
```

Put the `@import` lines first: CSS ignores an `@import` that comes after other rules.

**4. Add components.**

```bash
npx dolan add button card
```

Each one lands in `src/components/ui/<name>/`. Components it depends on come too: `button` brings `spinner`. So do the npm packages they import: `button` installs `class-variance-authority`.

**5. Use them.**

```typescript title="src/app/app.ts"
import { Component, signal } from '@angular/core';
import { LYNX_ELEMENTS } from '@blotch/angular-lynx';
import { UiButton } from '../components/ui/button';
import {
  UiCard,
  UiCardContent,
  UiCardHeader,
  UiCardTitle,
} from '../components/ui/card';

@Component({
  selector: 'app-root',
  imports: [
    LYNX_ELEMENTS,
    UiButton,
    UiCard,
    UiCardHeader,
    UiCardTitle,
    UiCardContent,
  ],
  template: `
    <view class="h-full bg-background p-6">
      <ui-card>
        <ui-card-header>
          <ui-card-title>Welcome</ui-card-title>
        </ui-card-header>
        <ui-card-content>
          <ui-button (pressed)="increment()">
            Tapped {{ count() }} times
          </ui-button>
        </ui-card-content>
      </ui-card>
    </view>
  `,
})
export class App {
  protected readonly count = signal(0);

  protected increment(): void {
    this.count.update((n) => n + 1);
  }
}
```

- The component pages import from `../components/ui/<name>`, a path relative to `src/app/`.
- Templates use [Lynx](/guide/glossary.md#lynx) **elements** such as `<view>` and `<text>` instead of HTML (see [Glossary](/guide/glossary.md#element)). Import `LYNX_ELEMENTS` whenever you use them (see [Elements](/api/angular-lynx/elements/index.md)).

## Good to know

- **Text color doesn't inherit.** Lynx passes only `font-size` down by default, so put a color class such as `text-foreground` on each of your own `<text>` elements. The components color their own text.
- **True/false inputs take a bare attribute.** `<ui-button disabled>` is `[disabled]="true"`, as on an HTML element. A two-way value, such as a switch's `checked`, is a `model()`, and Angular doesn't let a model take one, so bind it: `[checked]="true"`.
- **Tests come with the code.** Once you've set up [testing](/guide/testing/index.md) (`@blotch/angular-lynx-testing-library`), `dolan add` copies each component's tests too. They cover every line of the component under `ng test --coverage`, so the copies can stay in your coverage report.
- **Updates are merged, not forced.** Run [`dolan update`](/dolan/cli/updates.md#update) after upgrading `@blotch/dolan`. It keeps your edits and asks when both sides changed.

## Components

**General**

- [Button](/dolan/button.md): a tappable button with variants, sizes and a loading state
- [Button Group](/dolan/button-group.md): connected buttons that act as one toolbar
- [Copy Button](/dolan/copy-button.md): a button that copies text to the clipboard and says it did
- [Icon](/dolan/icon.md): 195 vector icons, or your own SVG
- [Typography](/dolan/typography.md): text styles for headings, body and captions

**Layout**

- [Card](/dolan/card.md): a bordered surface with header, content and footer
- [Separator](/dolan/separator.md): a thin horizontal or vertical line
- [Accordion](/dolan/accordion.md): stacked sections that expand one or many at a time
- [Collapsible](/dolan/collapsible.md): one section that shows and hides its content
- [Tabs](/dolan/tabs.md): panels switched by a row of tab buttons
- [Aspect Ratio](/dolan/aspect-ratio.md): a box that keeps a width-to-height ratio
- [Scroll Area](/dolan/scroll-area.md): a scrolling container with edge events

**Liquid Glass**

- [Glass](/dolan/glass.md): Liquid Glass for floating controls, with each platform's fallback
- [Dock](/dolan/dock.md): a floating glass tab bar that minimizes as content scrolls
- [Search Field](/dolan/search-field.md): a glass search field, which the dock can search with at the bottom of the screen
- [Menu](/dolan/menu.md): a pull-down menu that grows out of its button
- [Context Menu](/dolan/context-menu.md): a menu that opens on a long press, lifting the element
- [Glass sheets](/dolan/bottom-sheet.md#glass): sheets that float inset at half height and turn opaque at full height
- [Popover](/dolan/popover.md): content that grows out of the control that opens it
- [Switch](/dolan/switch.md#glass) and [Slider](/dolan/slider.md#glass): controls whose thumb turns to glass while it's dragged
- [Segmented Control](/dolan/toggle.md#segmented-control): a thumb that lifts into glass as it slides between segments, for toggle groups and [tabs](/dolan/tabs.md#segmented-control)

**Navigation**

- [Nav Drawer](/dolan/nav-drawer.md): a side menu that slides in
- [Tab Bar](/dolan/tab-bar.md): tabs along the bottom that switch routed screens
- [Pagination](/dolan/pagination.md): page numbers with previous and next buttons
- [Wizard](/dolan/wizard.md): a task split into steps, under an indicator of where the user is

**Data Display**

- [Avatar](/dolan/avatar.md): a profile picture with a fallback
- [Badge](/dolan/badge.md): a small status label
- [List](/dolan/list.md): a fast, recycling list for long data
- [Chart](/dolan/chart.md): draws any TanStack Charts definition
- [Line Chart](/dolan/line-chart.md), [Area Chart](/dolan/area-chart.md), [Bar Chart](/dolan/bar-chart.md), [Scatter Chart](/dolan/scatter-chart.md) and [Candlestick Chart](/dolan/candlestick-chart.md): ready-made charts
- [Progress](/dolan/progress.md): a progress bar
- [Skeleton](/dolan/skeleton.md): a placeholder shape while content loads
- [Spinner](/dolan/spinner.md): a loading indicator
- [Empty State](/dolan/empty-state.md): a message for screens with nothing to show

**Forms**

- [Input](/dolan/input.md): a single-line text field with label, helper text and error
- [Textarea](/dolan/textarea.md): a multi-line text field that grows with its content
- [Label](/dolan/label.md): a caption for a form control
- [Checkbox](/dolan/checkbox.md): an on/off box with a check mark
- [Radio Group](/dolan/radio-group.md): pick one option from a list
- [Select](/dolan/select.md): pick one option from a bottom sheet, with search for long lists
- [Multi Select](/dolan/multi-select.md): pick any number of options, shown as chips
- [Slider](/dolan/slider.md): pick a number in a range
- [Switch](/dolan/switch.md): an on/off toggle switch
- [Toggle](/dolan/toggle.md): a button that stays pressed, alone or in a group
- [Calendar](/dolan/calendar.md): a month of days to pick one from
- [Date Picker](/dolan/date-picker.md): a field that opens a calendar in a bottom sheet

**Feedback**

- [Alert](/dolan/alert.md): an inline message
- [Alert Dialog](/dolan/alert-dialog.md): a dialog that asks for confirmation
- [Dialog](/dolan/dialog.md): a centered modal window
- [Bottom Sheet](/dolan/bottom-sheet.md): a panel that slides up from the bottom
- [Sheet](/dolan/sheet.md): a bottom sheet with header and footer slots
- [Action Sheet](/dolan/action-sheet.md): a list of actions that slides up, or grows out of its button
- [Toast](/dolan/toast.md): short messages that appear and go away

## Design principles

- **You own the code.** Components are plain files in your repo. Edit them like your own.
- **Signals throughout.** Inputs use `input()`, events use `output()`, and two-way values use `model()`, so `[(value)]` and `[(checked)]` work.
- **Theme tokens, not colors.** Components use classes such as `bg-primary` and `text-muted-foreground`, defined once in your theme. See [Theming](/dolan/theming.md).
- **Variants with `cva`.** Variant classes come from [class-variance-authority](https://cva.style/). Components export them, for example `buttonVariants`.
- **Your classes win.** Most components take a `class` input. It's merged with `cn()`, so a conflicting class you pass replaces the default.
- **`cn()` merges as [tailwind-merge](https://github.com/dcastil/tailwind-merge)'s `twMerge()` does,** but knows only some kinds of class. It knows those the components use, those that conflict with them, and the margins, sizes and text styles apps often pass. That keeps the rest of tailwind-merge's config out of your app's script.
- **Two classes of another kind in one list are both kept.** `cn('rotate-45', 'rotate-90')` returns both, where `twMerge()` keeps the last. Where you need that, add `tailwind-merge` to your dependencies and call `twMerge()`.
- **Lynx elements only.** Components are built from `<view>`, `<text>`, `<svg>`, `<overlay>` and other Lynx elements, never HTML.

## Related

- [CLI](/dolan/cli/index.md): every `@blotch/dolan` command
- [Theming](/dolan/theming.md): change colors, radius and dark mode
- [Dynamic Color](/dolan/dynamic-color.md): the colors of the user's wallpaper on Android
- [Tailwind CSS](/guide/tailwindcss.md): set up Tailwind for Lynx
