Skip to content

Commit

Permalink
docs: slider thumb alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
segunadebayo committed Apr 24, 2024
1 parent 9786ad0 commit 49b07e6
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions website/data/components/slider.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,34 @@ const [state, send] = useMachine(
)
```

## Changing the thumb alignment

By default, the thumb is aligned to the start of the track. Set the
`thumbAlignment` context property to `contain` or `center`.

- `center`: the thumb will extend beyond the bounds of the slider track.
- `contain`: the thumb will be contained within the bounds of the track.

```jsx {3}
const [state, send] = useMachine(
slider.machine({
thumbAlignment: "center",
}),
)
```

If you use `contain` alignment, you might need to set the thumb size to prevent
any flickering.

```jsx {4}
const [state, send] = useMachine(
slider.machine({
thumbAlignment: "contain",
thumbSize: { width: 20, height: 20 },
}),
)
```

## Usage within forms

To use slider within forms, use the exposed `inputProps` from the `connect`
Expand Down

0 comments on commit 49b07e6

Please sign in to comment.