# Segment thumb

The travelling plate under the chosen cell of a segmented control.

## Web 0.2.0

### Usage

Position the thumb behind the selected segment. Let the owning control provide selection and interaction semantics.

### Accessibility

Treat the thumb as decoration. The owning control must expose selection without relying on position or animation.

### When to use

Use inside a segmented control as its selection indicator. Do not use it as a standalone input.

### Install

Add this registry to your project's components.json once, before the first install. Keep your existing settings and other registries.

```json
{
  "registries": {
    "@maeso": "http://127.0.0.1:4321/r/{name}.json"
  }
}
```

Then install the registry's default theme once, and import its sheet in the CSS entry that imports Tailwind. It paints every item from this registry.

```sh
npx shadcn@latest add @maeso/maeso
```

```css
@import "./styles/theme.web.css";
```

```sh
npx shadcn@latest add @maeso/segment-thumb
```

### Props

#### SegmentThumb

| Prop | Type | Required | Description |
| --- | --- | --- | --- |
| at | number | yes | The chosen cell, `0` to `count - 1`; out of range draws no thumb. |
| count | number | yes | The number of equal cells; 0 draws no thumb, and 1 fills the single cell. |

### Proof

#### Contrast

measured on 0.2.0

| State | Foreground | Background | Ratio | Floor |
| --- | --- | --- | --- | --- |
| default | rgb(7 21 34) | rgb(248 245 240) | 16.95 | AA 4.5 |
| default (dark) | rgb(248 245 240) | rgb(7 21 34) | 16.95 | AA 4.5 |

#### Size

1553 gzip bytes · measured on 0.2.0

### Motion

The selection thumb travels to the active segment.

Configured duration: 200 ms

Reduced motion: none

#### Motion timing

Observed duration: 200 ms · measured on 0.2.0

#### Reduced motion

passed · measured on 0.2.0

### Example

```tsx
import { SegmentThumb } from "@/components/ui/_kit/core/segment-thumb/SegmentThumb";

const Example = () => (
		<div className="relative grid grid-cols-3 w-full max-w-75 p-1 border border-border rounded-lg bg-surface-base">
			<SegmentThumb count={3} at={1} />

			{["One", "Two", "Three"].map((label) => (
				<span key={label} className="px-2 py-1.5 text-center text-(length:--text-xs) text-inherit">
					{label}
				</span>
			))}
		</div>
	);
export default Example;
```

### Preview · 0.2.0

not on native yet
