@@ -205,18 +205,23 @@ React.createElement(() => {
205205});
206206```
207207
208- However, your project may use the label color as the primary means to indicate
209- the required state of input fields (see
210- [ Forms Theming] ( /docs/customize/theming/forms ) for more). Because not checking
211- an input is also a valid action, it may be confusing to users to see the
212- optional check inputs greyed out.
208+ #### Styling the Required State
213209
214- For this case, there is the ` renderAsRequired ` prop:
210+ All form fields in React UI can be
211+ [ styled] ( /docs/customize/theming/forms/#required-state )
212+ to indicate the required state.
213+
214+ However, you may find yourself in a misleading situation where a form field
215+ is valid in both checked and unchecked states, for example to turn on or off a
216+ feature. If your project uses the label color as the primary means to indicate
217+ the required state of input fields and the usual asterisk ` * ` is omitted,
218+ you may want to keep the label color consistent for both states.
219+
220+ For this edge case, there is the ` renderAsRequired ` prop:
215221
216222``` docoff-react-preview
217223React.createElement(() => {
218224 const [optional, setOptional] = React.useState(false);
219- const [required, setRequired] = React.useState(false);
220225 const [renderAsRequired, setRenderAsRequired] = React.useState(false);
221226 return (
222227 <React.Fragment>
@@ -236,16 +241,9 @@ React.createElement(() => {
236241 onChange={() => setOptional(!optional)}
237242 />
238243 <br />
239- <CheckboxField
240- checked={required}
241- label="This field is required and must be checked"
242- onChange={() => setRequired(!required)}
243- required
244- />
245- <br />
246244 <CheckboxField
247245 checked={renderAsRequired}
248- label="Checked or unchecked, both states are valid "
246+ label="This field is optional but looks like required "
249247 onChange={() => setRenderAsRequired(!renderAsRequired)}
250248 renderAsRequired
251249 />
@@ -255,8 +253,8 @@ React.createElement(() => {
255253});
256254```
257255
258- It renders the field as required, but doesn't add the ` required ` attribute to
259- the actual input.
256+ It renders the field as if it was required, but doesn't add the ` required `
257+ attribute to the actual input.
260258
261259### Disabled State
262260
0 commit comments