SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

FareOptions

Fare classes as cards in a <fieldset>, each a native radio sharing one name.

Choose your fare
View code
tsx
<FareOptions
	legend="Choose your fare"
	name="fare"
	statusLabels={{ yes: "Included", no: "Not included", fee: "Available for a fee" }}
>
	<FareOptions.Option value="basic" title="Basic" price="$412" features={[
		{ label: "Personal item", included: "yes" },
		{ label: "Carry-on bag", included: "fee" },
		{ label: "Changes", included: "no" },
	]} />
	<FareOptions.Option value="standard" title="Standard" price="$468" priceDetail="+$56"
		ribbon="Recommended" checked features={[…]} />
	<FareOptions.Option value="flex" title="Flex" price="$544" priceDetail="+$132" features={[…]} />
</FareOptions>

Installation

An ordinary dependency: install it, import the theme once, and import the component where it is used.

Terminal
npm add @sdxc/ui remix
typescript
import "@sdxc/ui/theme.css";

Usage

typescript
import { FareOptions } from "@sdxc/ui/travel";

Renders the group: a <fieldset> named by its <legend>, with its cards stacked under 36rem and side by side, equal width, from there. Arrow keys move between the cards and the chosen one posts its value under name, both native radio behaviour.

Composition

The parts the component publishes, each a static property of the host.

  • FareOptions
  • FareOptions.OptionRenders one fare as a <label> card around its radio: the title and the radio, the price, then the feature list.

Props

Read from the component's own types, so every prop, every default and every allowed value is listed.

PropTypeRequiredDescription
legendRemixNodeYesWhat the choice is, such as "Choose your fare"; it names the group.
hideLegendbooleanNoHides the legend visually while it still names the group.
namestringYesThe radio name every card shares; the chosen card's value posts under it.
statusLabelsStatusLabelsYes
childrenRemixNodeYesThe FareOptions.Option cards.

Also accepts everything in TagProps<"fieldset">.

FareOptions.Option

PropTypeRequiredDescription
valuestringYesWhat the form posts when this fare is chosen, such as "standard".
titleRemixNodeYesThe fare's name, such as "Standard"; it names the radio.
priceRemixNodeYesThe fare's price, formatted by the caller, such as "$468".
priceDetailRemixNodeNoWhat the price covers, or the difference from the cheapest fare, such as "+$56".
featuresFeature[]No
ribbonRemixNodeNoA ribbon over the card, such as "Recommended".
checkedbooleanNoStarts chosen.
disabledbooleanNo
requiredbooleanNoMakes a choice required before the form submits; set it on one card of the group.

Also accepts everything in Omit<TagProps<"label">, "children" | "title">.

Types

NameValuesWhat it decides
Included"yes" | "no" | "fee"Whether a fare includes a feature, leaves it out, or offers it for a fee.
@sdxc/ui

Can’t find it? Contact us