import { Select } from "@vortexlabs/vortex-native";
import React from "react";
export const DeliveryPicker = () => {
const [delivery, setDelivery] = React.useState("");
return (
<Select.Root
width={260}
presentation="sheet"
size="md"
variant="outline"
disabled={false}
error={false}
>
<Select.Label>Delivery method</Select.Label>
<Select.Field value={delivery} placeholder="Choose a method" onClearAll={() => setDelivery("")}>
<Select.SectionLabel>Ship to address</Select.SectionLabel>
<Select.Item selected={delivery === "Standard"} onPress={() => setDelivery("Standard")}>
Standard
</Select.Item>
<Select.Item selected={delivery === "Express"} onPress={() => setDelivery("Express")}>
Express
</Select.Item>
<Select.SectionLabel>Collect in store</Select.SectionLabel>
<Select.Item selected={delivery === "Store pickup"} onPress={() => setDelivery("Store pickup")}>
Store pickup
</Select.Item>
</Select.Field>
<Select.HelperText>Choose how to receive your order.</Select.HelperText>
<Select.ErrorMessage>Choose a delivery method to continue.</Select.ErrorMessage>
</Select.Root>
);
};Features
- Opens choices in a bottom sheet or beside the field.
- Accepts custom rows or options loaded by ID.
- Shows checkboxes and a Done action for multiple selection in a sheet.
Anatomy
<Select.Root>
<Select.Label>Delivery method</Select.Label>
<Select.Field>
<Select.SectionLabel>Home delivery</Select.SectionLabel>
<Select.Item>Standard</Select.Item>
<Select.Item>Express</Select.Item>
</Select.Field>
{/* Use <Select.Combobox /> in place of Select.Field to add search. */}
<Select.ErrorMessage>Choose a delivery method.</Select.ErrorMessage>
<Select.HelperText>Choose how to receive your order.</Select.HelperText>
</Select.Root>Use one field per root. For static items, pass the selected label as value, set selected on its row, and update the value in onPress.
A sheet is the default. Choose floating under presentation to open options beside the field at any screen width.
Loaded Options
Use loadOptions on Select.Field for a list that people can pick from without typing. Store the option ID from onValueChange.
import { Select } from "@vortexlabs/vortex-native";
import React from "react";
const loadRegions = () => [
{ value: "au", label: "Australia" },
{ value: "nz", label: "New Zealand" },
];
export const LoadedRegion = () => {
const [region, setRegion] = React.useState<string>();
return (
<Select.Root width={260}>
<Select.Label>Shipping region</Select.Label>
<Select.Field
placeholder="Choose a region"
loadOptions={loadRegions}
value={region}
onValueChange={(value) => setRegion(value ?? undefined)}
onClearAll={() => setRegion(undefined)}
/>
</Select.Root>
);
};Search
Use Select.Combobox to load options for the typed query. Set selection="single" to close the picker as soon as someone makes a choice.
import { Select } from "@vortexlabs/vortex-native";
import React from "react";
const warehouses = [
{ value: "syd", label: "Sydney" },
{ value: "mel", label: "Melbourne" },
{ value: "per", label: "Perth" },
];
const loadWarehouses = async (query: string) => {
await new Promise<void>((resolve) => {
setTimeout(resolve, 400);
});
const search = query.trim().toLowerCase();
return warehouses.filter((warehouse) =>
warehouse.label.toLowerCase().includes(search),
);
};
export const WarehousePicker = () => {
const [warehouse, setWarehouse] = React.useState<string | null>(null);
return (
<Select.Root width={260}>
<Select.Label>Pickup warehouse</Select.Label>
<Select.Combobox
selection="single"
loadOptions={loadWarehouses}
selectedValue={warehouse}
onSelectedValueChange={setWarehouse}
onClearAll={() => setWarehouse(null)}
placeholder="Choose a warehouse"
searchLabel="Search warehouses"
loadingLabel="Loading warehouses"
emptyState="No warehouses match"
/>
</Select.Root>
);
};For static options, filter your Select.Item children in onSearch. Keep the same loadOptions function between renders to preserve cached labels.
Multiple Selection
Use selectedValues to keep the selected IDs. In a bottom sheet, people can tick several options and tap Done. The field displays the first two labels and a count for the rest.
import { Select } from "@vortexlabs/vortex-native";
import React from "react";
const teams = [
{ value: "design", label: "Design" },
{ value: "engineering", label: "Engineering" },
{ value: "research", label: "Research" },
];
const loadTeams = async (query: string) =>
teams.filter((team) =>
team.label.toLowerCase().includes(query.trim().toLowerCase()),
);
export const TeamPicker = () => {
const [selectedTeams, setSelectedTeams] = React.useState<string[]>([]);
return (
<Select.Root width={260}>
<Select.Label>Teams</Select.Label>
<Select.Combobox
loadOptions={loadTeams}
selectedValues={selectedTeams}
onSelectedValuesChange={setSelectedTeams}
onClearAll={() => setSelectedTeams([])}
placeholder="Choose teams"
searchLabel="Search teams"
/>
<Select.HelperText>Choose all teams that need access.</Select.HelperText>
</Select.Root>
);
};Sizes
Set size on Select.Root to size the field. Set it on an individual Select.Item to override the root size for that row.
import { Select, Stack } from "@vortexlabs/vortex-native";
import React from "react";
const loadRegions = () => [
{ value: "au", label: "Australia" },
{ value: "nz", label: "New Zealand" },
];
export const RegionSizes = () => {
const [region, setRegion] = React.useState<string>();
return (
<Stack width={260} maxWidth="100%" gap={3}>
<Select.Root size="sm" variant="outline" presentation="floating">
<Select.Label>Small</Select.Label>
<Select.Field
placeholder="Choose a region"
loadOptions={loadRegions}
value={region}
onValueChange={(value) => setRegion(value ?? undefined)}
/>
</Select.Root>
<Select.Root size="md" variant="outline" presentation="floating">
<Select.Label>Medium</Select.Label>
<Select.Field
placeholder="Choose a region"
loadOptions={loadRegions}
value={region}
onValueChange={(value) => setRegion(value ?? undefined)}
/>
</Select.Root>
</Stack>
);
};Variants
Set variant on Select.Root to choose an outlined or filled field.
import { Select, Stack } from "@vortexlabs/vortex-native";
import React from "react";
const loadRegions = () => [
{ value: "au", label: "Australia" },
{ value: "nz", label: "New Zealand" },
];
export const RegionVariants = () => {
const [region, setRegion] = React.useState<string>();
return (
<Stack width={260} maxWidth="100%" gap={3}>
<Select.Root size="md" variant="outline" presentation="floating">
<Select.Label>Outline</Select.Label>
<Select.Field
placeholder="Choose a region"
loadOptions={loadRegions}
value={region}
onValueChange={(value) => setRegion(value ?? undefined)}
/>
</Select.Root>
<Select.Root size="md" variant="fill" presentation="floating">
<Select.Label>Fill</Select.Label>
<Select.Field
placeholder="Choose a region"
loadOptions={loadRegions}
value={region}
onValueChange={(value) => setRegion(value ?? undefined)}
/>
</Select.Root>
</Stack>
);
};Disabled and Error States
Set disabled on a field that people can’t change. Set error on the root to reveal Select.ErrorMessage.
import { Select, Stack } from "@vortexlabs/vortex-native";
import React from "react";
const loadRegions = () => [
{ value: "au", label: "Australia" },
{ value: "nz", label: "New Zealand" },
];
export const RegionStates = () => {
const [region, setRegion] = React.useState<string>();
const [touched, setTouched] = React.useState(false);
return (
<Stack width={260} maxWidth="100%" gap={3}>
<Select.Root disabled>
<Select.Label>Billing region</Select.Label>
<Select.Field loadOptions={loadRegions} value="au" />
<Select.HelperText>Set by your organisation.</Select.HelperText>
</Select.Root>
<Select.Root error={touched && !region}>
<Select.Label>Shipping region</Select.Label>
<Select.Field
placeholder="Choose a region"
loadOptions={loadRegions}
value={region}
onValueChange={(value) => setRegion(value ?? undefined)}
onClose={() => setTouched(true)}
/>
<Select.ErrorMessage>Choose a region to continue.</Select.ErrorMessage>
</Select.Root>
</Stack>
);
};Use DropdownMenu when people need to run an action.