Swatch Picker
React Native (Expo)
A React Native colour picker of circles where the chosen one gets a ring that springs out and a tick inside.
A row of colour circles to choose from, such as a theme or a label colour. The chosen one gets a ring that springs out around it and a tick inside. The circles are a radio group and each is read out by the name you give it, not by its hex code. 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 swatch-pickerManual
- Copy the code from the component tab.
- Create a file at
components/ui/swatch-picker.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 | Swatch[] | - | The colours, each with a value and a spoken label. |
value | string | - | The chosen swatch's colour value. |
onChange | (value: string) => void | - | Called with the pressed swatch's value. |
size | number | 36 | Diameter of a swatch. |
colors | Partial<SwatchPickerColors> | - | Overrides ring and check. |
style | StyleProp<ViewStyle> | - | Style for the row of swatches. |
Comments