# VariantPicker

> The options a product comes in, such as colour, size and format, where every option is a link to the product page with that option chosen.

```ts
import { VariantPicker } from "@sdxc/ui/commerce";
```

Renders the picker, a column of axes. Its `target` reaches every option link as
`data-rmx-target`, so a choice reloads that frame in place: the page keeps its scroll and
the address changes to the variant without a new history entry per pick.

## Examples

```tsx
<VariantPicker target="product"><VariantPicker.Axis label="Size" value="50×70"><VariantPicker.Choice href="?size=50x70" label="50×70" selected /></VariantPicker.Axis></VariantPicker>
```

## Props

| Prop | Type | Description |
| --- | --- | --- |
| `children` | `RemixNode` |  |
| `target?` | `string` | A frame's name every option link loads into, so choosing swaps that frame in place. |

Also accepts everything in `Omit<TagProps<"div">, "children">`.


### VariantPicker.Axis

Renders one axis: a row with its label, the current choice and an aside, over the options in a group named by that row.

| Prop | Type | Description |
| --- | --- | --- |
| `label` | `RemixNode` | The axis's name, such as "Colour". |
| `value?` | `RemixNode` | The current choice's name, shown after the label. |
| `aside?` | `RemixNode` | Content at the row's end, such as a "Size guide" link. |
| `children` | `RemixNode` |  |


### VariantPicker.Swatch

Renders a round colour swatch as a link, ringed when selected and struck diagonally when unavailable.

| Prop | Type | Description |
| --- | --- | --- |
| `href` | `string` |  |
| `name` | `string` | The colour's name; it is the link's accessible name and tooltip. |
| `color` | `string` | Any CSS colour or gradient. |
| `selected?` | `boolean` |  |
| `unavailable?` | `boolean` | Strikes the swatch through; it still links, so its page can offer a notice. |
| `unavailableLabel?` | `string` | Added to the accessible name when unavailable, such as "sold out". |


### VariantPicker.Choice

Renders a choice as a link: a pill for a size, or a card with a detail and note for a format.

| Prop | Type | Description |
| --- | --- | --- |
| `href` | `string` |  |
| `label` | `RemixNode` |  |
| `detail?` | `RemixNode` | A second line in a card, such as its price or "Instant download". |
| `note?` | `RemixNode` | A small line under a card's detail, such as "Only 2 left". |
| `selected?` | `boolean` |  |
| `unavailable?` | `boolean` | Strikes the choice through; it still links, so its page can offer a notice. |
| `unavailableLabel?` | `string` | Read after the label when unavailable, such as "sold out". |
| `variant?` | `"pill" \| "card"` | A compact pill for sizes, or a card for formats with a detail line. @default "pill" |

