Skip to content

Commit

Permalink
feat: adds an id prop to the component, enhancing its accessibility (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Mirrorgo authored Sep 26, 2024
1 parent 01fe59f commit 7853d7f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ The following APIs are shared by Slider and Range.
| className | string | `''` | Additional CSS class for the root DOM node |
| min | number | `0` | The minimum value of the slider |
| max | number | `100` | The maximum value of the slider |
| id | string | `''` | Unique identifier for the component, used for accessibility |
| 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. |
| 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. |
| vertical | boolean | `false` | If vertical is `true`, the slider will be vertical. |
Expand Down
5 changes: 5 additions & 0 deletions src/Slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ export interface SliderProps<ValueType = number | number[]> {
classNames?: SliderClassNames;
styles?: SliderStyles;

id?: string;

// Status
disabled?: boolean;
keyboard?: boolean;
Expand Down Expand Up @@ -126,6 +128,8 @@ const Slider = React.forwardRef<SliderRef, SliderProps<number | number[]>>((prop
classNames,
styles,

id,

// Status
disabled = false,
keyboard = true,
Expand Down Expand Up @@ -575,6 +579,7 @@ const Slider = React.forwardRef<SliderRef, SliderProps<number | number[]>>((prop
})}
style={style}
onMouseDown={onSliderMouseDown}
id={id}
>
<div
className={cls(`${prefixCls}-rail`, classNames?.rail)}
Expand Down

0 comments on commit 7853d7f

Please sign in to comment.