@molecule/app-sort-picker-solid
Feature · sort-picker · App (browser) · v1.1.2 · Apache-2.0
Standalone single-select sort menu with options and label
npm install @molecule/app-sort-picker-solidHow it works
@molecule/app-sort-picker-solid is a ready-made sort-picker feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.
import { createSignal } from 'solid-js'
import { SortPicker } from '@molecule/app-sort-picker-solid'
export function ListToolbar() {
const [sort, setSort] = createSignal('newest')
return (
<SortPicker
value={sort()}
onChange={setSort}
options={[
{ value: 'newest', label: 'Newest' },
{ value: 'oldest', label: 'Oldest' },
{ value: 'popular', label: 'Most Popular' },
]}
/>
)
}Works with: @molecule/app-solid, @molecule/app-ui, @molecule/app-ui-solid
Reference
Solid sort-by picker.
Exports SortPicker — the Solid counterpart of
@molecule/app-sort-picker-react with the same props and the same DOM:
a single-select wrapper around <Select> from @molecule/app-ui-solid
with a conventional "Sort by" label — and the SortOption type.
Different from <FilterBar>, which manages multiple filter fields.
Props: value, onChange(value), options ({ value, label }[]),
label, ariaLabel, labelPosition ('inline' | 'above', default
inline), className.
Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit
src/index.tsJSDoc, not this file.
Quick Start
import { createSignal } from 'solid-js'
import { SortPicker } from '@molecule/app-sort-picker-solid'
export function ListToolbar() {
const [sort, setSort] = createSignal('newest')
return (
<SortPicker
value={sort()}
onChange={setSort}
options={[
{ value: 'newest', label: 'Newest' },
{ value: 'oldest', label: 'Oldest' },
{ value: 'popular', label: 'Most Popular' },
]}
/>
)
}
Type
feature
Installation
npm install @molecule/app-sort-picker-solid @molecule/app-solid @molecule/app-ui @molecule/app-ui-solid solid-js
API
Interfaces
SortOption
A single option entry for the SortPicker select list.
interface SortOption<T extends string = string> {
value: T
/**
* Option label. A native `<select>`/`<option>` can only display text,
* so this is a plain `string` — it is rendered as the option's text
* child (never `String()`-coerced). For a rich label above/beside the
* control, use the `SortPickerProps.label` prop, which accepts a
* JSX node.
*/
label: string
}
SortPickerProps
Props accepted by the SortPicker component (the React package's props).
interface SortPickerProps<T extends string = string> {
/** The currently selected option value. */
value: T
/** Called with the selected value when the user picks an option. */
onChange: (value: T) => void
/** The options to list. */
options: SortOption<T>[]
/**
* Optional label rendered above or to the left of the select. Rendered as
* JSX children, so a node (icon + text, styled element, …) displays as
* nodes — it is never stringified. When you pass a non-string node, also
* pass `SortPickerProps.ariaLabel` to give the select an accessible
* name.
*/
label?: JSX.Element
/**
* Accessible name for the underlying `<select>`. Defaults to `label`
* when it is a plain string, otherwise the translated "Sort by".
*/
ariaLabel?: string
/** Where to render the label. Defaults to `'inline'`. */
labelPosition?: 'inline' | 'above'
/** Extra classes. */
className?: string
}
Functions
SortPicker(props)
Standalone sort-by selector. Thin wrapper around <Select> with a
conventional "Sort by:" label and a focused single-select API.
function SortPicker(props: SortPickerProps<string>): JSX.Element
props— Component props (seeSortPickerProps).
Returns: The rendered sort picker.
Injection Notes
Requirements
Peer dependencies:
@molecule/app-solid^3.14.0 || ^4.0.0@molecule/app-ui^1.0.1@molecule/app-ui-solid^1.1.0solid-js^1.8.0
Runtime Dependencies
-
@molecule/app-solid -
@molecule/app-ui -
@molecule/app-ui-solid -
solid-js -
Must render inside the app's i18n provider and with a ClassMap bond wired (
useTranslation()/getClassMap()throw otherwise). -
SortOption.labelis a plainstring— a native<select>/<option>can only display text, so it is rendered as the option's text child. -
The outer
labelprop is JSX rendered as-is, so icons/styled elements display as nodes. When it is a non-string node, passariaLabelto name the select (a node cannot be anaria-label). -
The default "Sort by" label uses the
sort.labeli18n key; passlabelto override.
Translations
Translation strings are provided by @molecule/app-locales-sort-picker.