@@ -9,6 +9,12 @@ title: Getting Started
9
9
yarn add formik formik-material-ui @material-ui/core
10
10
```
11
11
12
+ ### Material-UI Lab (Optional)
13
+
14
+ ```
15
+ yarn add formik-material-ui-lab @material-ui/lab
16
+ ```
17
+
12
18
### Material-UI Pickers (Optional)
13
19
14
20
```
@@ -87,6 +93,120 @@ function App() {
87
93
88
94
Note: that the ` Field ` wrapper is not used, for more details on why see the [ FAQ] ( guide/faq.md ) .
89
95
96
+ ## Configuring Components
97
+
98
+ Several properties are purposefully excluded, please see the [ FAQ] ( guide/faq.md ) for details.
99
+
100
+ ``` jsx
101
+ import { TextField } from ' formik-material-ui' ;
102
+ import InputAdornment from ' @material-ui/core/InputAdornment' ;
103
+ import AccountCircle from ' @material-ui/icons/AccountCircle' ;
104
+
105
+ < TextField
106
+ name= " customized"
107
+ label= " Outlined"
108
+ variant= " outlined"
109
+ InputProps= {{
110
+ startAdornment: (
111
+ < InputAdornment position= " start" >
112
+ < AccountCircle / >
113
+ < / InputAdornment>
114
+ ),
115
+ }}
116
+ / > ;
117
+ ```
118
+
119
+ ## Quick Start (Lab)
120
+
121
+ See [ Material-UI Lab Info] ( https://material-ui.com/components/about-the-lab/ ) for more information
122
+
123
+ ``` jsx {4,31,52}
124
+ import * as React from ' react' ;
125
+ import { Formik , Form , Field } from ' formik' ;
126
+ import { Button , LinearProgress } from ' @material-ui/core' ;
127
+ import { Autocomplete , ToggleButtonGroup } from ' formik-material-ui-lab' ;
128
+ import Box from ' @material-ui/core/Box' ;
129
+ import ToggleButton from ' @material-ui/lab/ToggleButton' ;
130
+ import FormatAlignLeftIcon from ' @material-ui/icons/FormatAlignLeft' ;
131
+ import FormatAlignCenterIcon from ' @material-ui/icons/FormatAlignCenter' ;
132
+ import FormatAlignRightIcon from ' @material-ui/icons/FormatAlignRight' ;
133
+ import FormatAlignJustifyIcon from ' @material-ui/icons/FormatAlignJustify' ;
134
+
135
+ function App () {
136
+ return (
137
+ < MuiPickersUtilsProvider utils= {DateFnsUtils}>
138
+ < Formik
139
+ initialValues= {{
140
+ toggle: null ,
141
+ autocomplete: null ,
142
+ }}
143
+ onSubmit= {(values , { setSubmitting }) => {
144
+ setTimeout (() => {
145
+ setSubmitting (false );
146
+ alert (JSON .stringify (values, null , 2 ));
147
+ }, 500 );
148
+ }}
149
+ >
150
+ {({ submitForm, isSubmitting, errors }) => (
151
+ < Form>
152
+ < Box margin= {1 }>
153
+ < Field
154
+ component= {ToggleButtonGroup}
155
+ name= " toggle"
156
+ type= " checkbox"
157
+ >
158
+ < ToggleButton value= " left" aria- label= " left aligned" >
159
+ < FormatAlignLeftIcon / >
160
+ < / ToggleButton>
161
+ < ToggleButton value= " center" aria- label= " centered" >
162
+ < FormatAlignCenterIcon / >
163
+ < / ToggleButton>
164
+ < ToggleButton value= " right" aria- label= " right aligned" >
165
+ < FormatAlignRightIcon / >
166
+ < / ToggleButton>
167
+ < ToggleButton value= " justify" aria- label= " justified" disabled>
168
+ < FormatAlignJustifyIcon / >
169
+ < / ToggleButton>
170
+ < / Field>
171
+ < / Box>
172
+ < Box margin= {1 }>
173
+ < Field
174
+ name= " autocomplete"
175
+ component= {Autocomplete}
176
+ options= {top100Films}
177
+ getOptionLabel= {(option : Movie ) => option .title }
178
+ style= {{ width: 300 }}
179
+ renderInput= {(params : AutocompleteRenderInputParams ) => (
180
+ < TextField
181
+ {... params}
182
+ error= {touched[' autocomplete' ] && !! errors[' autocomplete' ]}
183
+ helperText= {
184
+ touched[' autocomplete' ] && errors[' autocomplete' ]
185
+ }
186
+ label= " Autocomplete"
187
+ variant= " outlined"
188
+ / >
189
+ )}
190
+ / >
191
+ < / Box>
192
+ < Box margin= {1 }>
193
+ < Button
194
+ variant= " contained"
195
+ color= " primary"
196
+ disabled= {isSubmitting}
197
+ onClick= {submitForm}
198
+ >
199
+ Submit
200
+ < / Button>
201
+ < / Box>
202
+ < / Form>
203
+ )}
204
+ < / Formik>
205
+ < / MuiPickersUtilsProvider>
206
+ );
207
+ }
208
+ ```
209
+
90
210
## Quick Start (Picker)
91
211
92
212
See [ Material-UI Pickers getting started] ( https://material-ui-pickers.dev/getting-started/installation ) for more information
0 commit comments