Docyrus

MegaSelect

Searchable bottom-sheet select with categories, DocyrusIcon / image items, Tailwind accent colours, detail pages and a Choose CTA.

iOSAndroid
Preview MegaSelect on your device

Scan with Expo Go

Download Expo Go, then scan the QR code to preview native components.

Installation

pnpm dlx @docyrus/cli add @docyrus/rn-mega-select
Required Packages(1 package)
pnpm add @shopify/flash-list

Usage

import { MegaSelect, type MegaSelectItem } from '@/components/docyrus-native/mega-select';

const items: MegaSelectItem[] = [
  { id: 'figma', label: 'Figma', description: 'Design tool', icon: 'fab figma', color: 'purple', categoryId: 'design' },
  { id: 'vscode', label: 'VS Code', description: 'Code editor', icon: 'fal code', color: 'blue-500', categoryId: 'dev' }
];

<MegaSelect
  items={items}
  categories={[{ id: 'design', label: 'Design', icon: 'fal palette' }, { id: 'dev', label: 'Development' }]}
  value={selectedId}
  onSelectionChange={(value, item) => setSelectedId(value)}
  onChoose={(value, item) => handleChoose(item)}
  columns="auto"
  size="large"
/>

Mapping API rows

import { MegaSelect, mapToMegaSelectItems } from '@/components/docyrus-native/mega-select';

const items = mapToMegaSelectItems(rows, {
  id: 'id',
  label: 'name',
  description: 'summary',
  icon: 'icon',
  color: 'color',
  categoryId: 'category_id'
});

<MegaSelect items={items} onSelectionChange={setValue} />

Behaviour

  • The trigger opens an ActionSheet. Tapping a row selects it (onSelectionChange) and closes the sheet, unless onChoose is set — then a Choose button confirms (onChoose) and closes.
  • Items with content show a Read more chip that opens the detail page; with forceOpenDetail a tap on the row opens it directly.
  • onClose fires only on user dismissal (backdrop tap, drag-down, close button) — not after a selection or Choose.
  • String icons render through DocyrusIcon; color accepts Tailwind names ("blue" → 500 shade, "emerald-500") or hex, and the icon tile gets a translucent tint of it.
  • Copy is translated through useUiTranslation() with the web keys: ui.megaSelect.placeholder (Select an item...), ui.megaSelect.chooseItem (Choose item), ui.megaSelect.choose, ui.megaSelect.readMore, ui.megaSelect.back, ui.megaSelect.allCategories, ui.megaSelect.noItems, ui.megaSelect.noResults, ui.megaSelect.currentSelection, ui.megaSelect.result / ui.megaSelect.results, ui.common.close, ui.common.searchPlaceholder.

API Reference

MegaSelectProps<T>

PropTypeDefaultDescription
itemsMegaSelectItem<T>[]-Array of selectable items (required)
categoriesMegaSelectCategory[]-Category chips for filtering
valuestring | null-Controlled selected item ID
defaultValuestring | null-Initial selected item ID (uncontrolled)
onSelectionChange(value: string | null, item: MegaSelectItem<T> | null) => void-Called when a row is tapped
onChoose(value: string, item: MegaSelectItem<T>) => void-Called on the "Choose" button; enables the Choose CTA
onClose() => void-Called when the user dismisses the sheet (backdrop, drag, close button)
searchablebooleantrueShow search input
placeholderstringt('ui.megaSelect.placeholder', 'Select an item...')Trigger placeholder text
disabledbooleanfalseDisable the trigger
loadingbooleanfalseShow skeleton rows instead of items
forceOpenDetailbooleanfalseOpen the detail page on tap for items with content
defaultColorstring-Accent colour (Tailwind name or hex) for items without a colour
defaultIconstring-DocyrusIcon for items without an icon or image
columns1 | 2 | 3 | 4 | 'auto'1List columns; 'auto' = 1 on phones, 2 on tablets (≥ 768pt)
size'thin' | 'default' | 'large' | 'full''default'Sheet size (maps to ActionSheet detents — see below)
variant'default' | 'elevated' | 'flat''default'Trigger styling
closablebooleantrueShow the close button and close on backdrop tap
restrictedValuestring-Only this item is interactable; others render disabled
classNamestring-Trigger CSS classes
styleViewStyle-Trigger style

Sizes

sizeSheet detents
thin['medium']
default['medium', 'large']
large['large']
full['large']

Variants

variantTrigger
defaultCard background, subtle border
elevatedCard background, lighter border, shadow-lg
flatMuted background, no border

MegaSelectItem<T>

FieldTypeDefaultDescription
idstring-Unique identifier (required)
labelstring-Display text (required)
descriptionstring-Secondary text
iconstring | ReactNode-DocyrusIcon identifier (e.g. "fal star") or a custom element
imagestring-Image URL — takes precedence over icon
colorstring-Accent colour — Tailwind name ("blue", "emerald-500") or hex. Colour-only items render a letter avatar
categoryIdstring-Category ID for filtering (falls back to data.category)
contentReactNode-Rich content rendered in the detail page
disabledbooleanfalseNon-interactive, reduced opacity
dataT-Original data passthrough

MegaSelectCategory

FieldTypeDefaultDescription
idstring-Category identifier (required)
labelstring-Chip label (required)
iconstring | ReactNode-DocyrusIcon identifier or a custom element

mapToMegaSelectItems

mapToMegaSelectItems<R>(data: R[], config: MapToMegaSelectItemsConfig<R>): MegaSelectItem<R>[] — maps raw rows to items (identical to web). Each row is kept in item.data.

FieldTypeDescription
idkeyof RColumn for item.id (required)
labelkeyof RColumn for item.label (required)
descriptionkeyof RColumn for item.description
iconkeyof RColumn for item.icon
imagekeyof RColumn for item.image
colorkeyof RColumn for item.color
categoryIdkeyof RColumn for item.categoryId

Exports

ExportDescription
MegaSelectTrigger + bottom-sheet select
mapToMegaSelectItemsRaw rows → MegaSelectItem[] helper

Type Exports

TypeDescription
MegaSelectProps<T>Props for MegaSelect
MegaSelectItem<T>Selectable item configuration
MegaSelectCategoryCategory chip configuration
MegaSelectSize'thin' | 'default' | 'large' | 'full'
MegaSelectVariant'default' | 'elevated' | 'flat'
MapToMegaSelectItemsConfig<R>Field mapping for mapToMegaSelectItems

On this page