# Elements reference

> Every option, event, custom property, and part of the drop-in elements.

From `client/src/elements/README.md` in tensile-tools/tensile-auth at commit `e66760d` (v0.4.1-7-ge66760d). The HTML page is https://auth.tensile.tools/docs/reference/elements.

## Options

Set an option in any of four ways. When an option is set more than once, the later way in this list wins:

1. `configure({...})`, for every element on the page.
2. The `config` property, one object for one element.
3. A JavaScript property, such as `el.appName = 'Acme'`.
4. An attribute, in kebab case, such as `app-name="Acme"`. A boolean attribute is true when present, and false with the value `false`, `0`, `off`, or `no`.

A value that isn't one of the choices is ignored, and so is an `accent` that isn't a hex colour.

### Sign-in methods

| Name | Attribute | Type | Default | What it does |
|---|---|---|---|---|
| `methods` | `methods` | `"passkey"` \| `"password"` \| `"both"` | `"both"` | Sets how people sign in, sign up, and confirm a sensitive action |
| `first` | `first` | `"passkey"` \| `"password"` | `"passkey"` | With `"both"`, sets which method comes first and gets the filled button |
| `autofill` | `autofill` | `boolean` | `true` | Offers saved passkeys in the email field's autofill, and shows a key icon in it |

### Brand

| Name | Attribute | Type | Default | What it does |
|---|---|---|---|---|
| `appName` | `app-name` | `string` | `"Acme"` | Your app's name, in the header and the headlines |
| `logo` | `logo` | `"none"` \| `"letter"` \| `"image"` | `"none"` | A mark before the app name: the first letter on the accent colour, or `logoSrc` |
| `logoSrc` | `logo-src` | `string` | `""` | The image for `logo: "image"`, 24 px high and up to 96 px wide |
| `accent` | `accent` | `"ink"` \| hex colour | `"ink"` | Colours the filled buttons, the letter mark, focus rings, and the current setup step. `"ink"` follows the theme. Text on the accent is white or near-black, whichever has the better contrast |
| `radius` | `radius` | `"sharp"` \| `"soft"` \| `"round"` | `"round"` | 2 px corners, 10 px buttons and an 18 px frame, or pill buttons and a 28 px frame |
| `font` | `font` | `"geist"` \| `"tight"` \| `"serif"` \| `"system"` | `"geist"` | The type pairing. See [Fonts](/docs/reference/elements#fonts) |

### Look

| Name | Attribute | Type | Default | What it does |
|---|---|---|---|---|
| `theme` | `theme` | `"light"` \| `"dark"` \| `"auto"` | `"light"` | `"auto"` follows `prefers-color-scheme` |
| `density` | `density` | `"comfortable"` \| `"compact"` | `"comfortable"` | 48 px controls and a 34 px headline, or 40 px controls and a 28 px headline |
| `headline` | `headline` | `"sentence"` \| `"title"` | `"sentence"` | The large sentence, or a quiet 22 px title with a one-line lead |

### Account sections

Each is a `boolean`, `true` by default. Turning one off hides its element, which renders nothing.

| Name | Attribute | What it does |
|---|---|---|
| `sessions` | `sessions` | Shows `<tensile-sessions>` |
| `agents` | `agents` | Shows the agents in `<tensile-sessions>`, and the approval elements |
| `activity` | `activity` | Shows `<tensile-activity>` |
| `twoStep` | `two-step` | Shows `<tensile-two-step>` |
| `recoveryCodes` | `recovery-codes` | Adds the recovery-code step to `<tensile-two-step>`, and shows `<tensile-wasnt-me>` and `<tensile-recovery-codes>` |

### Text

| Name | Attribute | Type | What it does |
|---|---|---|---|
| `headlineText` | `headline-text` | `string` | Replaces the sign-in headline, in one colour |
| `passkeyLabel` | `passkey-label` | `string` | Replaces "Sign in with passkey" |
| `passwordLabel` | `password-label` | `string` | Replaces "Continue with email" |
| `signUpLabel` | `sign-up-label` | `string` | Replaces the main sign-up button label |
| `text` | `text` (JSON) | `Record<string, string>` | Replaces any text by its key |

Every piece of text has a key, and English is the default. The keys and their English are in `text.ts`, and the module exports them as `english`. In a template, `{name}` is a value, `[words]` are the grey connecting words, `*words*` are green, and `!words!` are orange:

```js
configure({ text: {
  'signIn.headline': 'Good to see you [again.]',
  'sessions.signOutOthers': 'Sign out everywhere else',
} })
```

## Events

Every event bubbles out of the shadow root (`composed: true`), so you can listen on the element or on `document`.

| Event | From | `detail` |
|---|---|---|
| `signed-in` | `<tensile-sign-in>` | The session. Cancelable: call `preventDefault()` to stay instead of following `redirect` |
| `signed-up` | `<tensile-sign-up>` | `{method, data}` for a passkey, cancelable; `{method: "password", confirmed: false}` for a password |
| `needs-factor` | `<tensile-sign-in>` | `{needs}`, for example `["totp"]` |
| `reset-requested` | `<tensile-sign-in>` | `{email}` |
| `stepped-up` | `<tensile-step-up>` | The session |
| `cancelled` | `<tensile-step-up>` | `{}` |
| `approved`, `declined` | `<tensile-approval>`, `<tensile-approvals>` | `{id, action, agent}` |
| `change` | `<tensile-approvals>` | The pending requests |
| `revoked` | `<tensile-sessions>` | `{id, kind}` |
| `signed-out-others` | `<tensile-sessions>` | `{revoked}` |
| `undone` | `<tensile-wasnt-me>` | What was undone: `{sessions, agents, passkeys, totp, password, email}` |
| `kept` | `<tensile-wasnt-me>` | `{session}` |
| `new-codes` | `<tensile-wasnt-me>` | `{}`: show `<tensile-recovery-codes>` |
| `checked` | `<tensile-activity>` | The chain state |
| `codes-saved` | `<tensile-two-step>`, `<tensile-recovery-codes>` | `{}` |
| `two-step-on` | `<tensile-two-step>` | The session |
| `two-step-off` | `<tensile-two-step>` | `{}` |
| `problem` | Every element | The `Outcome` that failed |

## Theming

Set these custom properties on the element or an ancestor:

| Property | What it sets |
|---|---|
| `--tensile-accent`, `--tensile-on-accent` | The accent and the text on it, over the `accent` option |
| `--tensile-ink`, `--tensile-soft`, `--tensile-mute`, `--tensile-quiet`, `--tensile-join` | Text colours, from strongest to the grey connecting words |
| `--tensile-paper`, `--tensile-well`, `--tensile-line`, `--tensile-line-strong` | Backgrounds and rules |
| `--tensile-good`, `--tensile-good-tint`, `--tensile-warn`, `--tensile-warn-tint`, `--tensile-agent`, `--tensile-agent-tint` | Green, orange, and the violet of agent names and the tile behind their mark |
| `--tensile-radius-button`, `--tensile-radius-frame` | Corner radii, over the `radius` option |
| `--tensile-font-display`, `--tensile-font-text`, `--tensile-font-mono` | Font stacks, over the `font` option |

These parts are open to `::part()`: `root`, `frame`, `header`, `headline`, `field`, `input`, `button`, `button-primary`, `link`, `chip`, `divider`, `row`, `step`, `codes`, and `error`.

```css
tensile-sign-in::part(frame) { border: 0; }
tensile-sign-in { --tensile-accent: #0a84ff; }
```

## Fonts

The elements bundle Geist for headlines, Inter for text, and Geist Mono for codes, served from `/auth/client/fonts/` (see `fonts/`). Browsers download a font only when an element uses it.

- `font: "tight"` uses Inter Tight and `font: "serif"` uses Newsreader when your page loads them, and fall back to Inter and Georgia otherwise. They aren't bundled.
- `font: "system"` uses the platform's UI font and loads nothing.
