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.
Two package names are involved:
@blotch/uiis the component source. You never install it.@blotch/dolanis the CLI. It carries a copy of that source and writes it intosrc/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.
Installation
1. Set up dolan.
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 sizedark.css: the dark theme's colorstailwind.css: maps those colors to Tailwind classes such asbg-primary. An app on Tailwind 3 getstailwind-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.
2. Import the theme, after Tailwind's own imports:
With dark.css imported, the app follows the phone's light or dark appearance. See Theming.
3. On Tailwind 3, add the Tailwind plugin to your config instead, and import only the colors:
Put the @import lines first: CSS ignores an @import that comes after other rules.
4. Add components.
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.
- The component pages import from
../components/ui/<name>, a path relative tosrc/app/. - Templates use Lynx elements such as
<view>and<text>instead of HTML (see Glossary). ImportLYNX_ELEMENTSwhenever you use them (see Elements).
Good to know
- Text color doesn't inherit. Lynx passes only
font-sizedown by default, so put a color class such astext-foregroundon 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'schecked, is amodel(), 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 (
@blotch/angular-lynx-testing-library),dolan addcopies each component's tests too. They cover every line of the component underng test --coverage, so the copies can stay in your coverage report. - Updates are merged, not forced. Run
dolan updateafter upgrading@blotch/dolan. It keeps your edits and asks when both sides changed.
Components
General
- Button: a tappable button with variants, sizes and a loading state
- Button Group: connected buttons that act as one toolbar
- Copy Button: a button that copies text to the clipboard and says it did
- Icon: 195 vector icons, or your own SVG
- Typography: text styles for headings, body and captions
Layout
- Card: a bordered surface with header, content and footer
- Separator: a thin horizontal or vertical line
- Accordion: stacked sections that expand one or many at a time
- Collapsible: one section that shows and hides its content
- Tabs: panels switched by a row of tab buttons
- Aspect Ratio: a box that keeps a width-to-height ratio
- Scroll Area: a scrolling container with edge events
Liquid Glass
- Glass: Liquid Glass for floating controls, with each platform's fallback
- Dock: a floating glass tab bar that minimizes as content scrolls
- Search Field: a glass search field, which the dock can search with at the bottom of the screen
- Menu: a pull-down menu that grows out of its button
- Context Menu: a menu that opens on a long press, lifting the element
- Glass sheets: sheets that float inset at half height and turn opaque at full height
- Popover: content that grows out of the control that opens it
- Switch and Slider: controls whose thumb turns to glass while it's dragged
- Segmented Control: a thumb that lifts into glass as it slides between segments, for toggle groups and tabs
Navigation
- Nav Drawer: a side menu that slides in
- Tab Bar: tabs along the bottom that switch routed screens
- Pagination: page numbers with previous and next buttons
- Wizard: a task split into steps, under an indicator of where the user is
Data Display
- Avatar: a profile picture with a fallback
- Badge: a small status label
- List: a fast, recycling list for long data
- Chart: draws any TanStack Charts definition
- Line Chart, Area Chart, Bar Chart, Scatter Chart and Candlestick Chart: ready-made charts
- Progress: a progress bar
- Skeleton: a placeholder shape while content loads
- Spinner: a loading indicator
- Empty State: a message for screens with nothing to show
Forms
- Input: a single-line text field with label, helper text and error
- Textarea: a multi-line text field that grows with its content
- Label: a caption for a form control
- Checkbox: an on/off box with a check mark
- Radio Group: pick one option from a list
- Select: pick one option from a bottom sheet, with search for long lists
- Multi Select: pick any number of options, shown as chips
- Slider: pick a number in a range
- Switch: an on/off toggle switch
- Toggle: a button that stays pressed, alone or in a group
- Calendar: a month of days to pick one from
- Date Picker: a field that opens a calendar in a bottom sheet
Feedback
- Alert: an inline message
- Alert Dialog: a dialog that asks for confirmation
- Dialog: a centered modal window
- Bottom Sheet: a panel that slides up from the bottom
- Sheet: a bottom sheet with header and footer slots
- Action Sheet: a list of actions that slides up, or grows out of its button
- Toast: 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 useoutput(), and two-way values usemodel(), so[(value)]and[(checked)]work. - Theme tokens, not colors. Components use classes such as
bg-primaryandtext-muted-foreground, defined once in your theme. See Theming. - Variants with
cva. Variant classes come from class-variance-authority. Components export them, for examplebuttonVariants. - Your classes win. Most components take a
classinput. It's merged withcn(), so a conflicting class you pass replaces the default. cn()merges as tailwind-merge'stwMerge()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, wheretwMerge()keeps the last. Where you need that, addtailwind-mergeto your dependencies and calltwMerge(). - Lynx elements only. Components are built from
<view>,<text>,<svg>,<overlay>and other Lynx elements, never HTML.
Related
- CLI: every
@blotch/dolancommand - Theming: change colors, radius and dark mode
- Dynamic Color: the colors of the user's wallpaper on Android
- Tailwind CSS: set up Tailwind for Lynx
