# Leader row

Source: https://ecosphere.dev/docs/data/leader-row (Ecosphere 1.5). Install `vue-ecosphere` for Vue 3 or `react-ecosphere` for React 18.2+/19: same components, props, markup and stylesheet.

The compact row a rail is made of: position, avatar, a name with one line of why it is here, and its state.

`import { EcoLeaderRow } from "vue-ecosphere"`

## Ranked

Only the leader’s numeral is coloured: a whole highlighted row in a list of ten says less.

Vue (vue-ecosphere):

```vue
<EcoLeaderRow :rank="1" top initials="MR" name="Meera Raghavan" hint="Grade 9-B · 98.4% attendance" />
<EcoLeaderRow :rank="2" initials="KS" name="Kabir Sharma" hint="Grade 9-A · 97.9%" />
<EcoLeaderRow :rank="3" initials="AI" name="Ananya Iyer" hint="Grade 10-C · 97.1%" />
```

React (react-ecosphere):

```tsx
<EcoLeaderRow rank={1} top initials="MR" name="Meera Raghavan" hint="Grade 9-B · 98.4% attendance" />
<EcoLeaderRow rank={2} initials="KS" name="Kabir Sharma" hint="Grade 9-A · 97.9%" />
<EcoLeaderRow rank={3} initials="AI" name="Ananya Iyer" hint="Grade 10-C · 97.1%" />
```

## Unranked, with a state badge

Vue (vue-ecosphere):

```vue
<EcoLeaderRow initials="NS" name="Nilesh Shah" hint="Aarav · absent · SMS + app" :status="{ label: 'Queued', tone: 'accent' }" />
<EcoLeaderRow initials="FQ" name="Farah Qureshi" hint="Zoya · late · app only" :status="{ label: 'Delivered', tone: 'success' }" />
<EcoLeaderRow initials="DM" name="Deepa Menon" hint="Rohan · absent · SMS" :status="{ label: 'No number', tone: 'warning' }" />
```

React (react-ecosphere):

```tsx
<EcoLeaderRow initials="NS" name="Nilesh Shah" hint="Aarav · absent · SMS + app" status={{ label: "Queued", tone: "accent" }} />
<EcoLeaderRow initials="FQ" name="Farah Qureshi" hint="Zoya · late · app only" status={{ label: "Delivered", tone: "success" }} />
<EcoLeaderRow initials="DM" name="Deepa Menon" hint="Rohan · absent · SMS" status={{ label: "No number", tone: "warning" }} />
```

## As a list of choices

Click a row: the selected one takes --brand-violet-tint, the system’s selection fill.

Vue (vue-ecosphere):

```vue
<EcoLeaderRow selectable :selected="section === '9B'" initials="GR" name="Grade 9 · section B"
  hint="42 students · R. Menon" @click="section = '9B'" />
<EcoLeaderRow selectable :selected="section === '9C'" initials="GR" name="Grade 9 · section C"
  hint="41 students · P. Nair" @click="section = '9C'" />
```

React (react-ecosphere):

```tsx
const [section, setSection] = useState("9B");

<EcoLeaderRow selectable selected={section === "9B"} initials="GR" name="Grade 9 · section B"
  hint="42 students · R. Menon" onClick={() => setSection("9B")} />
<EcoLeaderRow selectable selected={section === "9C"} initials="GR" name="Grade 9 · section C"
  hint="41 students · P. Nair" onClick={() => setSection("9C")} />
```

## API

Vue (vue-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `name` | `string` | — | The row’s name. |
| `hint` | `string` | — | Why this row is in this list. One line; it truncates. |
| `initials` | `string` | — | Small avatar. The #avatar slot overrides it. |
| `rank` | `number \| string` | — | Position in a fixed 20px column. Leave it out when the list is not ranked. |
| `top` | `boolean` | false | First place: the numeral takes the accent (lbr--top). |
| `status` | `EcoDataBadge` | — | State badge at the end; or the #badge slot. |
| `selectable / selected` | `boolean` | false | Render as a button (lbrl) in a rail that selects what the body shows; selected takes the violet tint. |
| `@click` | `(event) => void` | — | Selectable rows only. |

React (react-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `name` | `string` | — | The row’s name. |
| `hint` | `string` | — | Why this row is in this list. One line; it truncates. |
| `initials` | `string` | — | Small avatar. The avatar prop (ReactNode) overrides it. |
| `rank` | `number \| string` | — | Position in a fixed 20px column. Leave it out when the list is not ranked. |
| `top` | `boolean` | false | First place: the numeral takes the accent (lbr--top). |
| `status` | `EcoDataBadge` | — | State badge at the end; or the badge prop (ReactNode). |
| `selectable / selected` | `boolean` | false | Render as a button (lbrl) in a rail that selects what the body shows; selected takes the violet tint. |
| `onClick` | `(event) => void` | — | Selectable rows only. |
