Skip to content

Commit 7853d7f

Browse files
authored
feat: adds an id prop to the component, enhancing its accessibility (#1041)
1 parent 01fe59f commit 7853d7f

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ The following APIs are shared by Slider and Range.
101101
| className | string | `''` | Additional CSS class for the root DOM node |
102102
| min | number | `0` | The minimum value of the slider |
103103
| max | number | `100` | The maximum value of the slider |
104+
| id | string | `''` | Unique identifier for the component, used for accessibility |
104105
| marks | `{number: ReactNode}` or`{number: { style, label }}` | `{}` | Marks on the slider. The key determines the position, and the value determines what will show. If you want to set the style of a specific mark point, the value should be an object which contains `style` and `label` properties. |
105106
| step | number or `null` | `1` | Value to be added or subtracted on each step the slider makes. Must be greater than zero, and `max` - `min` should be evenly divisible by the step value. <br /> When `marks` is not an empty object, `step` can be set to `null`, to make `marks` as steps. |
106107
| vertical | boolean | `false` | If vertical is `true`, the slider will be vertical. |

src/Slider.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ export interface SliderProps<ValueType = number | number[]> {
5454
classNames?: SliderClassNames;
5555
styles?: SliderStyles;
5656

57+
id?: string;
58+
5759
// Status
5860
disabled?: boolean;
5961
keyboard?: boolean;
@@ -126,6 +128,8 @@ const Slider = React.forwardRef<SliderRef, SliderProps<number | number[]>>((prop
126128
classNames,
127129
styles,
128130

131+
id,
132+
129133
// Status
130134
disabled = false,
131135
keyboard = true,
@@ -575,6 +579,7 @@ const Slider = React.forwardRef<SliderRef, SliderProps<number | number[]>>((prop
575579
})}
576580
style={style}
577581
onMouseDown={onSliderMouseDown}
582+
id={id}
578583
>
579584
<div
580585
className={cls(`${prefixCls}-rail`, classNames?.rail)}

0 commit comments

Comments
 (0)