SortSelect
The order a product listing is sorted in, as a labelled native select that submits its form the moment the shopper picks an order.
View code
<SortSelect
form="filters"
name="sort"
value={sort}
label="Sort by"
options={[
{ value: "featured", label: "Featured" },
{ value: "new", label: "Newest" },
{ value: "price-asc", label: "Price: low to high" },
{ value: "price-desc", label: "Price: high to low" },
]}
/>Installation
An ordinary dependency: install it, import the theme once, and import the component where it is used.
npm add @sdxc/ui remiximport "@sdxc/ui/theme.css";Usage
import { SortSelect } from "@sdxc/ui/commerce";Renders the label and select in a row, with a submit button that hides once script runs.
Props
Read from the component's own types, so every prop, every default and every allowed value is listed.
| Prop | Type | Required | Description |
|---|---|---|---|
name | string | Yes | The query field the order submits as, such as "sort". |
value | string | Yes | The order selected now. |
options | Option[] | Yes | |
label | string | Yes | The visible label, such as "Sort by". |
form | string | No | The id of the form the select belongs to, when it sits outside that form. |
submitLabel | string | No | The button that submits without script. @default "Apply" |
Also accepts everything in Omit<TagProps<"div">, "children">.