Skip to content

Commit 48994a7

Browse files
authored
Docs updates (#4867)
1 parent 71a827b commit 48994a7

38 files changed

+396
-15
lines changed

packages/@react-aria/color/docs/useColorArea.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,14 @@ It's up to you to style your color area to appear disabled accordingly.
710710
isDisabled />
711711
```
712712

713+
### HTML forms
714+
715+
ColorArea supports the `xName` and `yName` props for integration with HTML forms. The values will be submitted as numbers between the minimum and maximum value for the corresponding channel in the X and Y direction.
716+
717+
```tsx example
718+
<ColorArea xName="red" yName="green" />
719+
```
720+
713721
## Internationalization
714722

715723
### Labeling

packages/@react-aria/color/docs/useColorField.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,13 @@ The difference is that read only color fields are focusable but disabled color f
141141
<ColorField defaultValue="#7f007f" isReadOnly />
142142
```
143143

144+
### HTML forms
145+
146+
ColorField supports the `name` prop for integration with HTML forms. The value will be submitted to the server as a hex color string.
147+
148+
```tsx example
149+
<ColorField label="Color" name="color" />
150+
```
144151

145152
## Internationalization
146153

packages/@react-aria/color/docs/useColorSlider.mdx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,17 @@ It's up to you to style your color slider to appear disabled accordingly.
325325
<ColorSlider channel="red" defaultValue="#7f007f" isDisabled />
326326
```
327327

328+
### HTML forms
329+
330+
ColorSlider supports the `name` prop for integration with HTML forms. The value will be submitted as a number between the minimum and maximum value for the displayed channel.
331+
332+
```tsx example
333+
<ColorSlider
334+
defaultValue="#7f0000"
335+
channel="red"
336+
name="red" />
337+
```
338+
328339
## Internationalization
329340

330341
### Labeling

packages/@react-aria/color/docs/useColorWheel.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,14 @@ It's up to you to style your color wheel to appear disabled accordingly.
189189
<ColorWheel defaultValue="hsl(80, 100%, 50%)" isDisabled />
190190
```
191191

192+
### HTML forms
193+
194+
ColorWheel supports the `name` prop for integration with HTML forms. The value will be submitted as a number between 0 and 360 degrees.
195+
196+
```tsx example
197+
<ColorWheel name="hue" />
198+
```
199+
192200
## Internationalization
193201

194202
### Labeling

packages/@react-aria/slider/docs/useSlider.mdx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,19 +141,20 @@ function Slider(props) {
141141
}
142142
{/* The track element holds the visible track line and the thumb. */}
143143
<div {...trackProps} ref={trackRef} className={`track ${state.isDisabled ? 'disabled' : ''}`}>
144-
<Thumb index={0} state={state} trackRef={trackRef} />
144+
<Thumb index={0} state={state} trackRef={trackRef} name={props.name} />
145145
</div>
146146
</div>
147147
);
148148
}
149149

150150
function Thumb(props) {
151-
let {state, trackRef, index} = props;
151+
let {state, trackRef, index, name} = props;
152152
let inputRef = React.useRef(null);
153153
let {thumbProps, inputProps, isDragging} = useSliderThumb({
154154
index,
155155
trackRef,
156-
inputRef
156+
inputRef,
157+
name
157158
}, state);
158159

159160
let {focusProps, isFocusVisible} = useFocusRing();
@@ -421,6 +422,16 @@ A slider can be disabled using the `isDisabled` prop.
421422
defaultValue={25}
422423
isDisabled />
423424
```
425+
### HTML forms
426+
427+
useSliderThumb supports the `name` prop for integration with HTML forms.
428+
429+
```tsx example
430+
<Slider
431+
label="Opacity"
432+
defaultValue={50}
433+
name="opacity" />
434+
```
424435

425436
## Internationalization
426437

packages/@react-spectrum/checkbox/docs/Checkbox.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ The Checkbox will visually remain indeterminate until the `isIndeterminate` prop
8787
<Checkbox isIndeterminate>Subscribe</Checkbox>
8888
```
8989

90+
### HTML forms
91+
92+
Checkbox supports the `name` and `value` props for integration with HTML forms.
93+
94+
```tsx example
95+
<Checkbox name="newsletter" value="subscribe">Subscribe</Checkbox>
96+
```
97+
9098
## Events
9199

92100
Checkboxes accept a user defined `onChange` prop, triggered whenever the Checkbox is clicked.

packages/@react-spectrum/checkbox/docs/CheckboxGroup.mdx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,18 @@ function Example() {
8080
}
8181
```
8282

83+
### HTML forms
84+
85+
CheckboxGroup supports the `name` prop, paired with the Checkbox `value` prop, for integration with HTML forms.
86+
87+
```tsx example
88+
<CheckboxGroup label="Condiments" name="condiments">
89+
<Checkbox value="mayo">Mayo</Checkbox>
90+
<Checkbox value="mustart">Mustard</Checkbox>
91+
<Checkbox value="ketchup">Ketchup</Checkbox>
92+
</CheckboxGroup>
93+
```
94+
8395
## Labeling
8496
A visual label should be provided for the CheckboxGroup using the `label` prop. If the CheckboxGroup requires an option to be selected by the user,
8597
the `isRequired` and `necessityIndicator` props can be used to show a required state.

packages/@react-spectrum/color/docs/ColorArea.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,14 @@ function Example() {
8888
}
8989
```
9090

91+
### HTML forms
92+
93+
ColorArea supports the `xName` and `yName` props for integration with HTML forms. The values will be submitted as numbers between the minimum and maximum value for the corresponding channel in the X and Y direction.
94+
95+
```tsx example
96+
<ColorArea xName="red" yName="green" />
97+
```
98+
9199
## Labeling
92100

93101
By default, ColorArea uses an `aria-label` for the localized string "Color Picker",

packages/@react-spectrum/color/docs/ColorField.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ function Example() {
6868
}
6969
```
7070

71+
### HTML forms
72+
73+
ColorField supports the `name` prop for integration with HTML forms. The value will be submitted to the server as a hex color string.
74+
75+
```tsx example
76+
<ColorField label="Color" name="color" />
77+
```
78+
7179
## Labeling
7280

7381
A visual label should be provided for the ColorField using the `label` prop. If the ColorField is required, the `isRequired` and

packages/@react-spectrum/color/docs/ColorSlider.mdx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,17 @@ function Example() {
7272
}
7373
```
7474

75+
### HTML forms
76+
77+
ColorSlider supports the `name` prop for integration with HTML forms. The value will be submitted as a number between the minimum and maximum value for the displayed channel.
78+
79+
```tsx example
80+
<ColorSlider
81+
defaultValue="#7f0000"
82+
channel="red"
83+
name="red" />
84+
```
85+
7586
## Labeling
7687

7788
The ColorSlider's channel name and value are shown above the ColorSlider by default. The label and value label can be hidden by providing

0 commit comments

Comments
 (0)