|
| 1 | +# Select |
| 2 | + |
| 3 | +Adapt UI provides one theme for `Select` components with four styles and seven interaction states. |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | +#### Simple Usage |
| 9 | + |
| 10 | +```js |
| 11 | +import { Select } from "@adaptui/react-native-tailwind"; |
| 12 | + |
| 13 | +const themes: ItemData[] = [ |
| 14 | + { value: "system", label: "System" }, |
| 15 | + { value: "dark", label: "Dark" }, |
| 16 | + { value: "light", label: "Light" }, |
| 17 | +]; |
| 18 | + |
| 19 | +export default function App() { |
| 20 | + return <Select options={themes} placeholder="Select theme" />; |
| 21 | +} |
| 22 | +``` |
| 23 | + |
| 24 | +## Table of Contents |
| 25 | + |
| 26 | +- [Themes](#themes) |
| 27 | +- [Variant](#variant) |
| 28 | +- [Size](#size) |
| 29 | +- [Prefix](#prefix) |
| 30 | +- [Props](#props) |
| 31 | + |
| 32 | +## Themes |
| 33 | + |
| 34 | +Adapt UI provides only one `base` theme. You can add more themes by adding new variants and new design tokens if needed. |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | +<details> |
| 39 | + |
| 40 | +<summary> |
| 41 | + <h3>Usage</h3> |
| 42 | +</summary> |
| 43 | + |
| 44 | +```js |
| 45 | +import { Select, useTheme } from "@adaptui/react-native-tailwind" |
| 46 | + |
| 47 | +export default function App() { |
| 48 | + const tailwind = useTheme(); |
| 49 | + return ( |
| 50 | + <> |
| 51 | + <Select |
| 52 | + style={tailwind.style("w-60")} |
| 53 | + variant="subtle" |
| 54 | + size="xl" |
| 55 | + placeholder="Select a payment mode" |
| 56 | + /> |
| 57 | + </> |
| 58 | + ) |
| 59 | +} |
| 60 | +``` |
| 61 | +</details> |
| 62 | + |
| 63 | +## Variant |
| 64 | + |
| 65 | +Adapt UI provides four select component styles: `outline`, `subtle`, `underline`, and `ghost`. |
| 66 | +You can use these various styled select components based on the necessity and style you wish to provide to your design. |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | +<details> |
| 71 | +<summary> |
| 72 | + <h3>Usage</h3> |
| 73 | +</summary> |
| 74 | + |
| 75 | +```js |
| 76 | +import { Select, useTheme } from "@adaptui/react-native-tailwind" |
| 77 | + |
| 78 | +export default function App() { |
| 79 | + const tailwind = useTheme(); |
| 80 | + return ( |
| 81 | + <> |
| 82 | + <Select placeholder="Select a payment mode" />; |
| 83 | + <Select variant="subtle" placeholder="Select theme" />; |
| 84 | + <Select variant="underline" placeholder="Select an option" />; |
| 85 | + <Select variant="ghost" placeholder="Toggle list" />; |
| 86 | + |
| 87 | + </> |
| 88 | + ) |
| 89 | +} |
| 90 | +``` |
| 91 | +</details> |
| 92 | + |
| 93 | +## Size |
| 94 | + |
| 95 | +There are four different sizes for select components in Adapt UI. Based on your requirement, you can switch between different sizes. |
| 96 | + |
| 97 | + |
| 98 | + |
| 99 | +<details> |
| 100 | +<summary> |
| 101 | + <h3>Usage</h3> |
| 102 | +</summary> |
| 103 | + |
| 104 | +```js |
| 105 | +import { Select, useTheme } from "@adaptui/react-native-tailwind"; |
| 106 | + |
| 107 | +export default function App() { |
| 108 | + const tailwind = useTheme(); |
| 109 | + return ( |
| 110 | + <> |
| 111 | + <Select size="sm" placeholder="Select gender" /> |
| 112 | + <Select placeholder="Select gender" /> |
| 113 | + <Select size="lg" placeholder="Select gender" /> |
| 114 | + <Select size="xl" placeholder="Select gender" /> |
| 115 | + </> |
| 116 | + ); |
| 117 | +} |
| 118 | +``` |
| 119 | + |
| 120 | +</details> |
| 121 | + |
| 122 | +## Prefix |
| 123 | + |
| 124 | +The prefix is a slot at the beginning or prefix position of a component. Here in the select, the prefix slot can be used to bring icons. Prefix itself doesn't have any unique property. |
| 125 | + |
| 126 | +Here in the select, we have an icon in the prefix slot. You can change the icon by passing an <Icon /> component to prefix prop. |
| 127 | + |
| 128 | + |
| 129 | + |
| 130 | +<details> |
| 131 | +<summary> |
| 132 | + <h3>Usage</h3> |
| 133 | +</summary> |
| 134 | + |
| 135 | +```js |
| 136 | +import { Select, useTheme } from "@adaptui/react-native-tailwind"; |
| 137 | + |
| 138 | +export default function App() { |
| 139 | + const tailwind = useTheme(); |
| 140 | + return ( |
| 141 | + <> |
| 142 | + <Select size="xl" placeholder="Pick a date" /> |
| 143 | + <Select size="xl" placeholder="Sandeep Prabhakaran" /> |
| 144 | + </> |
| 145 | + ); |
| 146 | +} |
| 147 | +``` |
| 148 | + |
| 149 | +</details> |
| 150 | + |
| 151 | +## Props |
| 152 | + |
| 153 | + |
| 154 | +> Select implements Touchable accepting all `PressableProps` |
| 155 | +
|
| 156 | +| Name | Description | Type | Default | |
| 157 | +|---------------|------------------------------------------------------------------------|--------------------------------------------|-----------------| |
| 158 | +| options | The Select Component options, which is rendered inside the Bottomsheet | ItemData[]* | | |
| 159 | +| defaultState | Default value of Select when it is uncontrolled | string | | |
| 160 | +| state | Value of Select when it is controlled | string | | |
| 161 | +| onStateChange | Callback called with the new value when it changes | (val: string) => void | | |
| 162 | +| placeholder | Default placeholder valye | string | "Select option" | |
| 163 | +| size | How large should the select be? | `sm`, `md`, `lg`, `xl` | `md` | |
| 164 | +| variant | How the select should look? | `outline`, `subtle`, `underline` , `ghost` | `outline` | |
| 165 | +| prefix | Prefix for the Select. | RenderPropType | null | |
| 166 | +| suffix | Suffix for the Select. | RenderPropType | null | |
| 167 | +| invalid | Set to True, if the value of the Select is invalid. | boolean | false | |
| 168 | +| disabled | Set to True, if the value of the Select is disabled. | boolean | false | |
| 169 | +| snapPoints | Bottomsheet Snap points | string[] | ["50%"] | |
0 commit comments