Reaction Bar
React Native (Expo)
A React Native row of emoji reactions whose emoji pops and wobbles when chosen, with counts that roll to their new number.
A row of emoji reactions. Choosing one pops and wobbles its emoji, tints the pill and rolls the count to its new number, and pressing your choice again takes it back. You can hold one reaction at a time. Each pill reads out as "Love, 9, selected" and mirrors its state 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 reaction-barManual
- Copy the code from the component tab.
- Create a file at
components/ui/reaction-bar.tsx. - Paste the code.
It needs no packages beyond react-native, which your Expo or React Native app already has.
Usage
tsx
counts holds what everyone else chose. Your own choice is added on top, so the bar always shows the right total.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
reactions | Reaction[] | - | The reactions, each with an id, an emoji and a spoken label. |
counts | Record<string, number> | - | How many other people chose each reaction, by id. |
value | string | null | - | The reaction you chose, or null. |
onChange | (next: string | null) => void | - | Called with the reaction you chose, or null when you take it back. |
hideZero | boolean | true | Hides the count on reactions nobody chose. |
colors | Partial<ReactionBarColors> | - | Overrides pill, selectedPill, border, selectedBorder, text and count. |
style | StyleProp<ViewStyle> | - | Style for the row. |
Comments