# Theme components

A theme restyles the app's own components, or wraps them in its own, with no app update. Both
live in the theme's app look, `parts.app.overrides` ([theme-pack-spec.md](theme-pack-spec.md)):

```json
"overrides": {
  "style": "Menu, Dropdown, Popup { border-radius: 0; background: #000; border: 1px solid var(--accent); }",
  "script": "import { override, Box, Text, Original } from 'isolink/theme'; …",
  "missing": { "icons": "placeholder", "art": "hide" }
}
```

In a store or theme-skill folder, keep each as a file of its own beside `pack.json`:
`"style": {"path": "overrides/theme.css"}`, `"script": {"path": "overrides/theme.tsx"}`. Publishing reads
them in, so the pack's signature covers them ([theme-store.md](theme-store.md#the-repo)).

Written by `packages/isolink_core/tool/theme_components.dart` from the catalogue in
`packages/isolink_core/lib/src/overrides/catalogue.dart`. A new component gets its name there, so
themes can style it in a theme update.

## Selectors

Rules select components the way CSS selects elements, by the names below:

| Selector | Matches |
| --- | --- |
| `Fab` | every create button |
| `SearchField#chats` | one instance, by its id |
| `IconTile[icon="store"]` | a prop equal to a value; also `^=`, `$=`, `*=` and `~=` |
| `MenuItem[danger]` | a prop that is set |
| `Button:pressed` | a state: `:pressed`, `:hover`, `:focus`, `:disabled`, `:selected`, `:checked`, `:unthemed`, `:active` |
| `Composer::send` | a named part of a component |
| `Page#theme IconTile` | a component anywhere inside another |
| `Menu > MenuItem` | a component right inside another |
| `IconTile[os="oneui"]` | one system: `oneui`, `android`, `ios`, `mac`, `windows`, `linux`, `web` |
| `Fab[dark]` | in dark mode |

`@media (prefers-color-scheme: dark)`, `(min-width: …)` and `(max-width: …)` hold rules for one mode
or window size. Where rules clash, the more specific wins as in CSS (an id over props, states and
parts, those over a name), then the later one. A rule may chain at most 6 components.

## Properties

The same CSS store apps use, with `var(--…)` for the theme's tokens:
`display`, `flex-direction`, `flex`, `flex-grow`, `flex-wrap`, `gap`, `align-items`, `justify-content`, `width`, `height`, `min-width`, `min-height`, `max-width`, `max-height`, `aspect-ratio`, `padding`, `padding-top`, `padding-right`, `padding-bottom`, `padding-left`, `padding-block`, `padding-inline`, `margin`, `margin-top`, `margin-right`, `margin-bottom`, `margin-left`, `margin-block`, `margin-inline`, `background`, `background-color`, `border`, `border-top`, `border-right`, `border-bottom`, `border-left`, `border-color`, `border-width`, `border-radius`, `box-shadow`, `opacity`, `overflow`, `filter`, `backdrop-filter`, `color`, `font`, `font-size`, `font-weight`, `font-family`, `font-style`, `line-height`, `letter-spacing`, `text-align`, `text-transform`, `text-decoration`, `transform`, `transform-origin`, `translate`, `scale`, `rotate`, `transition`, `content`, `caret-color`, `caret-shape`.

Tokens: `--accent`, `--accent-soft`, `--on-accent`, `--surface`, `--bg`, `--ink`, `--muted`, `--outline`, `--success`, `--warning`, `--danger`, `--space-1`, `--space-2`, `--space-3`, `--space-4`, `--space-5`, `--space-6`, `--radius-sm`, `--radius-md`, `--radius-lg`, `--radius-xl`, `--shadow-1`, `--shadow-2`, `--shadow-3`, `--font-body`, `--font-display`, `--font-mono`, `--font-hand`, `--font-serif`.

- `display: none` hides a component. Any theme may hide decoration (the components marked
  hideable below); only a theme Isolink signed may hide others, so a control never vanishes.
- `content: placeholder` on `Icon` or `Art` draws the theme's own `missing_icon` or `missing_art`
  code in its place; `content: normal` keeps the original.
- `caret-color` and `caret-shape: block` set a text field's caret.
- `url()` isn't allowed: pictures come from the theme's own codes.
- A component's box (`background`, `border`, `border-radius`, `box-shadow`, `padding`, sizes) is
  drawn as its Box column says: on its own surface, on the glass inside it, round it, or not at
  all (only text, colour and visibility apply).

## Missing icons and art

`missing.icons` and `missing.art` say what icons and pictures the theme has none of do:
`original` (the app's own, the default), `hide`, or `placeholder` (the theme's `missing_icon` or
`missing_art` code). `Icon:unthemed` and `Art:unthemed` select them in the stylesheet too. An icon
that is all a button shows is never hidden.

## Wrapper script

`script` is TypeScript with JSX, importing `isolink/theme`. Each `override(name, (props, ctx) => …)`
draws round one component; `<Original />` is where the app's own goes:

```tsx
import { override, Box, Text, Original } from 'isolink/theme';

override('Composer', (props, ctx) => (
  <Box style={{ flexDirection: 'row', alignItems: 'center', gap: 6 }}>
    <Text style={{ color: 'var(--accent)', fontFamily: 'var(--font-mono)' }}>{props.editing ? '~' : '>'}</Text>
    <Original />
  </Box>
));
```

- `props` are the component's props from the table below. `ctx` has `os`, `dark`, `width`, `id`,
  `states`, `accent` and `official`.
- It may use every store-app component (`Box`, `Text`, `Icon`, `Image`…) but reaches nothing outside:
  no data, network or storage, a small memory, and a few milliseconds a wrapper. Taps go to the
  original, not the wrapper.
- A wrapper draws `<Original />` exactly once. One that leaves it out or draws it twice, throws or
  runs long is turned off and the component is drawn as the stylesheet has it. A theme Isolink
  signed may leave it out, replacing the component.
- Each wrapper is drawn once for each set of props, and kept.
- People can turn a theme's components off in its Options.

## Components

Every component also has `[os]` and `[dark]`.

### WindowFrame

The frame around a desktop window. A theme with `roundness: "square"` gets square corners on Mac and Windows 11. A `border-radius` rule overrides that preference. Windows uses its system corners for a positive radius, and on Linux the window manager controls the outer shape. For a square Mac frame with an accent outline, use `WindowFrame[os="mac"] { border-radius: 0; border: 1px solid var(--accent); }`.

- Ids: `#main` The main window, `#chat` A detached or floating chat
- Box: its own

### Page

A whole screen. Use it to reach what's on one page: `Page#chats SearchField`.

- Ids: `#chats` Chats, `#people` People, `#you` You, `#chat` One chat, `#devices` My devices, `#settings` Settings, `#theme` Theme, `#store` Store, `#apps` All apps, `#forums` Forums
- Box: none

### TopBar

A page's bar along its top: title, back and actions.

- Parts: `::title`
- Box: round it

### Fab

The round create button that floats over a list.

- Parts: `::icon`, `::label`
- Props: `[icon]` its icon code, `[extended]` it shows a label
- Box: its own

### FloatingButton

Buttons that float over a page: One UI's over its top as it scrolls, a Mac's way back.

- Ids: `#back` The way back over a page or a cover
- Box: its glass

### Button

A button with words.

- Parts: `::label`, `::icon`
- Props: `[variant]` primary, secondary, ghost or danger; pill for the Store's Get and Open, `[icon]` its icon code
- Box: its own

### IconButton

A button that's only an icon.

- Parts: `::icon`
- Props: `[icon]` its icon code, `[filled]` drawn on a fill, `[send]` the chat's Send
- Box: its own

### SearchField

A search box.

- Parts: `::icon`, `::field`
- Props: `[hint]` its placeholder
- Ids: `#chats` Chats' search, `#icons` Searching a theme's icons
- Box: its own

### TextField

A box to type in.

- Parts: `::field`
- Props: `[label]` its label, `[hint]` its placeholder
- Box: its own

### Composer

The bar at a chat's foot where messages are written.

- Parts: `::bar`, `::field`, `::send`, `::add`
- Props: `[editing]` a message is being edited
- Ids: `#chat` In a chat, `#devices` In My devices
- Box: its own

### IconTile

An icon on a small tile at the start of a settings row: One UI's round, a Mac's rounded square.

- Props: `[icon]` its icon code, `[colour]` its own colour, as #rrggbb
- Box: its own

### AppIcon

An app's square on Apps and in the Store: on its own colour, or the plain ground for forums and tools.

- Props: `[icon]` its icon code, `[colour]` its own colour, as #rrggbb, `[plain]` it has no colour of its own
- Box: its own

### Icon

Any icon. `:unthemed` matches icons the theme has no picture or glyph for; `content: placeholder` draws the theme's `missing_icon` there.

- Props: `[icon]` its icon code, `[themed]` the theme draws it
- Box: none; hideable

### Art

An illustration. `:unthemed` matches pictures the theme has none of; `content: placeholder` draws its `missing_art` there.

- Props: `[art]` which picture, `[themed]` the theme draws it
- Box: none; hideable

### Menu

A menu: a computer's context menu, or a phone's sheet of actions.

- Ids: `#message` A message's actions
- Box: its glass

### MenuItem

One choice in a menu.

- Parts: `::icon`, `::label`
- Props: `[danger]` it deletes or can't be undone, `[checked]` it's ticked, `[icon]` its icon code
- Box: round it

### Dropdown

The list a pop-up button opens.

- Box: its glass

### Sheet

A sheet that slides up over the page.

- Box: its glass

### Popup

A floating panel over the page: what holds a computer's menus and lists.

- Box: its own

### Dialog

A question or alert in the middle of the screen.

- Parts: `::title`
- Box: its own

### Glass

Any pane of the platform's glass, frost or acrylic.

- Box: its own

### Card

A raised card on a page: You's stats, Send to my devices, the Store's big featured cards.

- Ids: `#featured` The Store's big featured cards, `#store` The Store's smaller cards, `#picture` A Store page's cover and pictures, `#facts` A Store page's size and version
- Box: its own

### Group

Rows grouped on one card, as in Settings.

- Ids: `#sidebar` An open app's rows in a Mac's sidebar
- Box: its own

### Row

A row in a list or group; `:selected` while it's the one showing.

- Parts: `::title`, `::subtitle`
- Props: `[title]` its words, `[danger]` it deletes or can't be undone
- Ids: `#sidebar` A row of a Mac's sidebar
- Box: round it

### Pill

A small rounded label.

- Props: `[label]` its words, `[tone]` neutral, accent, success, warning or danger
- Box: its own

### Switch

An on-off switch; `:checked` while on.

- Props: `[on]` it's on
- Box: round it

### FilterTabs

The row of filters over a list: All, Unread, Groups.

- Box: round it

### Chip

One filter in a row of them, as over Chats or the Store, or a Store page's tag; `:selected` while picked.

- Props: `[label]` its words
- Box: its own

### NavBar

The tabs along a phone's foot.

- Box: its own

### Segmented

A row of options with the chosen one raised, as Light, Dark and System; its thumb follows its corners.

- Box: its own

### Checkbox

A tick box; `:checked` while ticked.

- Box: its own

### Progress

A bar that fills as something comes or is done.

- Box: its own

### Banner

A notice across a page: a warning, a tip, something waiting.

- Props: `[tone]` neutral, accent, success, warning or danger
- Box: its own

### Toast

A short note that shows for a moment and goes.

- Box: its own

### Avatar

Someone's picture.

- Box: none

### Badge

A count on an icon or row.

- Box: its own; hideable

### EmptyState

What a page shows when there's nothing in it yet.

- Parts: `::art`
- Box: round it
