Select Grid
React Native (Expo)
A React Native multi-select grid of cards where a tick springs in, with an optional limit that dims the rest.
A grid of cards where any number can be picked, such as interests during onboarding. A picked card takes the accent border and a tick springs into its corner. Set max and the remaining cards dim once the limit is reached. Every card is a checkbox for screen readers. Built for React Native and Expo with react-native only; this page previews it in the browser through react-native-web.
Installation
CLI
npx @modus-ui/cli add select-gridManual
- Copy the code from the component tab.
- Create a file at
components/ui/select-grid.tsx. - Paste the code.
It needs no packages beyond react-native, which your Expo or React Native app already has.
Usage
tsx
Props
| Prop | Type | Default | Description |
|---|---|---|---|
options | SelectOption[] | - | The cards, each with an id, a label and an optional icon. |
value | string[] | - | The ids of the selected options. |
onChange | (value: string[]) => void | - | Called with the new selection. |
columns | number | 2 | Cards per row. |
max | number | - | The most cards that can be selected. |
colors | Partial<SelectGridColors> | - | Overrides accent, border, surface, selectedSurface, label and checkText. |
style | StyleProp<ViewStyle> | - | Style for the grid. |
Comments