|
| 1 | +--- |
| 2 | +slug: choicechips |
| 3 | +title: ChoiceChips |
| 4 | +tags: [] |
| 5 | +description: Learn how to add ChoiceChips in your FlutterFlow app. |
| 6 | +sidebar_position: 9 |
| 7 | +--- |
| 8 | + |
| 9 | + |
| 10 | +# ChoiceChips |
| 11 | +The ChoiceChips widget allows users to select a single option from a group of chips. Each chip is presented with an icon and accompanying text, making it easy to represent various choices. |
| 12 | + |
| 13 | +You could use this widget to implement a filter feature in an e-commerce app to let users select different product attributes like size, color, or price range. |
| 14 | + |
| 15 | + |
| 16 | +## Adding ChoiceChips widget |
| 17 | + |
| 18 | +To add the ChoiceChips widget to your app: |
| 19 | + |
| 20 | +1. Add the **ChoiceChips** widget from the **Form Elements** tab. |
| 21 | +2. By default, this widget adds a single option named **Option 1**. To change the name, move to the Properties Panel, and scroll down to the **Define Options** section. Find the **Option 1** property and change the **name** and **icon**. |
| 22 | +3. To add more options, click on the **Add Option** text and set the name and icon for new options. |
| 23 | +4. To set any chip as selected by default, find the **Initial Option** property and enter the chip name. |
| 24 | + 1. To set this value dynamically, open the **Set from Variable** menu and set the variable. |
| 25 | + 2. When [multiselect](#allow-multiselect) is enabled, you can also set the list of options to pre-select. |
| 26 | + |
| 27 | +<div style={{ |
| 28 | + position: 'relative', |
| 29 | + paddingBottom: 'calc(56.67989417989418% + 41px)', // Keeps the aspect ratio and additional padding |
| 30 | + height: 0, |
| 31 | + width: '100%'}}> |
| 32 | + <iframe |
| 33 | + src="https://www.loom.com/embed/16bb138384864990ae6991f477589d13?sid=1b31ba9a-2d8b-4b74-9640-746f1d93960d" |
| 34 | + title="" |
| 35 | + style={{ |
| 36 | + position: 'absolute', |
| 37 | + top: 0, |
| 38 | + left: 0, |
| 39 | + width: '100%', |
| 40 | + height: '100%', |
| 41 | + colorScheme: 'light' |
| 42 | + }} |
| 43 | + frameborder="0" |
| 44 | + loading="lazy" |
| 45 | + webkitAllowFullScreen |
| 46 | + mozAllowFullScreen |
| 47 | + allowFullScreen |
| 48 | + allow="clipboard-write"> |
| 49 | + </iframe> |
| 50 | +</div> |
| 51 | +<p></p> |
| 52 | + |
| 53 | +## Trigger action on change |
| 54 | + |
| 55 | +See how to [trigger an action when a selection changes](../../../../../resources/ui-building-blocks/widgets/widget-commonalities#trigger-action-on-selection-change) on this widget. |
| 56 | + |
| 57 | +## Select or clear all choices [Action] |
| 58 | + |
| 59 | +Users may need to swiftly deselect all chips or choose all available choice chips at once. You can do so by adding the **Clear All/Select All** action. |
| 60 | + |
| 61 | +:::info |
| 62 | +Before you add this action, ensure you [**allow multiselect**](#allow-mulitselect) on this widget. |
| 63 | +::: |
| 64 | + |
| 65 | +## Customizing |
| 66 | + |
| 67 | +You can customize the appearance and behavior of this widget using the various properties available under the properties panel. |
| 68 | + |
| 69 | +### Allow multiselect |
| 70 | + |
| 71 | +You might want to allow users to select multiple choices to filter the result. |
| 72 | + |
| 73 | +To allow multiselect, select the **ChoiceChips** widget, move to the properties panel, find the **Allow Multiselect** property and enable it. |
| 74 | + |
| 75 | + |
| 76 | + |
| 77 | +### Disable ChoiceChips |
| 78 | + |
| 79 | +Sometimes, you may want to present the choices in a read-only mode, preventing users from making any changes. |
| 80 | + |
| 81 | +To do so, move to the **Properties Panel** **>** turn on **Disable >** click **Unset,** and set the [**Conditions**](../../../../resources/functions/conditional-logic). This can be the [**Single Condition**](../../../../resources/functions/conditional-logic#single-condition) or [**Combine Conditions**](../../../../resources/functions/conditional-logic#multiple-conditions-andor) based on your requirement. **Note:** The ChoiceChips widget will be disabled only when condition(s) is true. |
| 82 | + |
| 83 | +<div style={{ |
| 84 | + position: 'relative', |
| 85 | + paddingBottom: 'calc(56.67989417989418% + 41px)', // Keeps the aspect ratio and additional padding |
| 86 | + height: 0, |
| 87 | + width: '100%'}}> |
| 88 | + <iframe |
| 89 | + src="https://www.loom.com/embed/6521e458211b4250b1376f8462a9cce2?sid=23586025-bed2-4cf2-869f-1c54eea5d59b" |
| 90 | + title="" |
| 91 | + style={{ |
| 92 | + position: 'absolute', |
| 93 | + top: 0, |
| 94 | + left: 0, |
| 95 | + width: '100%', |
| 96 | + height: '100%', |
| 97 | + colorScheme: 'light' |
| 98 | + }} |
| 99 | + frameborder="0" |
| 100 | + loading="lazy" |
| 101 | + webkitAllowFullScreen |
| 102 | + mozAllowFullScreen |
| 103 | + allowFullScreen |
| 104 | + allow="clipboard-write"> |
| 105 | + </iframe> |
| 106 | +</div> |
| 107 | +<p></p> |
| 108 | + |
| 109 | +### Adding Space between Chips |
| 110 | + |
| 111 | +To add a space between the chips, you can use the **Chip Spacing** ad **Row Spacing** property. |
| 112 | + |
| 113 | +- **Chip Spacing**: This adds horizontal gaps between individual chips. |
| 114 | +- **Row Spacing**: This adds vertical gaps between the chips in a row. |
| 115 | + |
| 116 | + |
| 117 | + |
| 118 | +### Align chips |
| 119 | + |
| 120 | +When you have chips in multiple rows, you can align them using the **Alignment** property. This is similar to setting main axis alignment for the Row widget. |
| 121 | + |
| 122 | + |
| 123 | + |
| 124 | +### Customizing selected and unselected chip style |
| 125 | + |
| 126 | +Various properties under the **Selected Chip Style** and **Unselected Chip Style** section allow you to customize chips to match your design. Here's how you do it: |
| 127 | + |
| 128 | +1. To change the background color, use the **Color** property. |
| 129 | +2. To change the icon's color and size, use the **Icon Color** and **Icon Size** property. |
| 130 | +3. To add a shadow or to create a sense of depth for the chip, you can use the **Elevation** property. |
| 131 | +4. To customize the border, use the **Border Color**, **Border Width** (thickness), and **Border Radius** (rounded corner) properties. |
| 132 | +5. To create some space around the label, use the **Label Padding** property. |
| 133 | +6. To change the label text styling, use the **Selected Text Style** property. |
| 134 | + |
| 135 | +<div style={{ |
| 136 | + position: 'relative', |
| 137 | + paddingBottom: 'calc(56.67989417989418% + 41px)', // Keeps the aspect ratio and additional padding |
| 138 | + height: 0, |
| 139 | + width: '100%'}}> |
| 140 | + <iframe |
| 141 | + src="https://www.loom.com/embed/75141dcf90cd4d1a8e22dd288a7e9dee?sid=2e289300-60a6-4d99-ab66-1e38baf5265f" |
| 142 | + title="" |
| 143 | + style={{ |
| 144 | + position: 'absolute', |
| 145 | + top: 0, |
| 146 | + left: 0, |
| 147 | + width: '100%', |
| 148 | + height: '100%', |
| 149 | + colorScheme: 'light' |
| 150 | + }} |
| 151 | + frameborder="0" |
| 152 | + loading="lazy" |
| 153 | + webkitAllowFullScreen |
| 154 | + mozAllowFullScreen |
| 155 | + allowFullScreen |
| 156 | + allow="clipboard-write"> |
| 157 | + </iframe> |
| 158 | +</div> |
| 159 | +<p></p> |
| 160 | + |
| 161 | +7. Similarly, you can customize the properties under the **Unselected Chip Style**. |
| 162 | + |
| 163 | + |
0 commit comments