{"id":13400600,"url":"https://github.com/airbnb/rheostat","last_synced_at":"2025-05-14T03:04:13.168Z","repository":{"id":46283938,"uuid":"47292486","full_name":"airbnb/rheostat","owner":"airbnb","description":"Rheostat is a www, mobile, and accessible slider component built with React","archived":false,"fork":false,"pushed_at":"2024-04-12T15:02:04.000Z","size":1227,"stargazers_count":1695,"open_issues_count":67,"forks_count":188,"subscribers_count":43,"default_branch":"master","last_synced_at":"2025-05-10T05:01:41.306Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/airbnb.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-12-02T22:28:26.000Z","updated_at":"2025-04-29T14:42:33.000Z","dependencies_parsed_at":"2024-01-13T19:34:30.958Z","dependency_job_id":"e249572b-2adb-41aa-a72a-01087ad36b40","html_url":"https://github.com/airbnb/rheostat","commit_stats":{"total_commits":183,"total_committers":26,"mean_commits":7.038461538461538,"dds":0.6174863387978142,"last_synced_commit":"d0d5ffab7cf4b393a1d1932ef76f389156b5c1fd"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/airbnb%2Frheostat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/airbnb%2Frheostat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/airbnb%2Frheostat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/airbnb%2Frheostat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/airbnb","download_url":"https://codeload.github.com/airbnb/rheostat/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254059486,"owners_count":22007768,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T19:00:53.781Z","updated_at":"2025-05-14T03:04:13.151Z","avatar_url":"https://github.com/airbnb.png","language":"JavaScript","funding_links":[],"categories":["Uncategorized","JavaScript","React [🔝](#readme)","📦 Legacy \u0026 Inactive Projects"],"sub_categories":["Uncategorized"],"readme":"# Rheostat\n\n\u003e A mobile, tablet, desktop, and accessible slider for the web.\n\n![Rheostat demo](sample.gif)\n\n## Install\n\n`npm install rheostat`\n\n## Initialize\n\nAs of v3.0.0, the `rheostat` project relies on `react-with-styles`. If you want to continue using CSS stylesheets and classes, there is a little bit of extra set-up required to get things going. As such, you need to use to use `rheostat/initialize` to set up class names on your components.\n\n    import 'rheostat/initialize';\n\nFor example, the above import should go at the top of your application as you won't be able to import `rheostat` with it.\n\n## Props\n\nThe algorithm, by default [`linear`](src/algorithms/linear.js), the slider will use. Feel free to write\nyour own as long as it conforms to the shape.\n\n```js\n  algorithm: PropTypes.shape({\n    getValue: PropTypes.func,\n    getPosition: PropTypes.func,\n  })\n```\n\nCustom class name that will be applied to the root of Rheostat.\n\n```js\n  className: PropTypes.string\n```\n\nCustom React component overrides for the handles, background, and the \"progress\" bar.\n\n```js\n  background: PropTypes.oneOfType([PropTypes.func, PropTypes.string])\n  handle: PropTypes.oneOfType([PropTypes.func, PropTypes.string])\n  progressBar: PropTypes.oneOfType([PropTypes.func, PropTypes.string])\n```\n\nThe maximum and minimum possible values, by default 0 - 100.\n\n```js\n  max: PropTypes.number\n  min: PropTypes.number\n```\n\n`pitComponent` is a custom React component for rendering \"pits\" across the bar.\n`pitPoints` is the set of points at which it will render a pit. Points are an array\nof `values` on the slider.\n\n```js\n  pitComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.string])\n  pitPoints: PropTypes.arrayOf(PropTypes.number)\n```\n\nNOTE: `onChange` is called whenever the value is changed and committed. This happens at the end of\na drag, keypress, or click event. `onChange` is recommended when you wish to persist the values.\n\n`onValuesUpdated` is a convenience event that is triggered while the value is being actively\nchanged. This includes dragging, click, or keypress. `onValuesUpdated` is recommended if you need\nto work with the values before they're committed.\n\nIf you need to perform custom logic to postprocess the handle position, `getNextHandlePosition` accepts\na callback of the form `(handleIdx: int, percentPosition: float) =\u003e float`. Return the updated\nhandle position. This is useful if you need to customize ranges within a single slider.\n\n```js\n  onChange: PropTypes.func\n  onClick: PropTypes.func\n  onKeyPress: PropTypes.func\n  onSliderDragEnd: PropTypes.func\n  onSliderDragMove: PropTypes.func\n  onSliderDragStart: PropTypes.func\n  onValuesUpdated: PropTypes.func\n  getNextHandlePosition: PropTypes.func\n```\n\n`snap` is a boolean which controls the slider's snapping behavior.\n`snapPoints` is an array of `values` on the slider where the slider should snap to.\n\nIf `snap` is set to true and no `snapPoints` are set then the slider is snapped into an absolute\nposition. For example, on a scale of 1-10 if the slider is let go at the 54% mark it'll pick the\nvalue 5 and snap to 50%.\n\n```js\n  snap: PropTypes.bool\n  snapPoints: PropTypes.arrayOf(PropTypes.number)\n```\n\nThe values, by default 0 and 100.\n\n```js\n  values: PropTypes.arrayOf(PropTypes.number)\n```\n\nYou can disable the slider to prevent the user from moving it.\n\n```js\n  disabled: PropTypes.bool\n```\n\n## Usage\n\n\u003e Important: Make sure to include the [css file](https://unpkg.com/rheostat@3/css/rheostat.css) or feel free to create your own.\n\n* Simple.\n\n```js\nimport Rheostat from 'rheostat';\n\nReactDOM.render(\u003cRheostat /\u003e, document.getElementById('slider-root'));\n```\n\n* A slider with a multiple handles.\n\n```js\nimport Rheostat from 'rheostat';\n\nReactDOM.render((\n  \u003cRheostat\n    min={1}\n    max={100}\n    values={[1, 100]}\n  /\u003e\n), document.getElementById('slider-root'));\n```\n\n### Advanced Styling\n\nThe `rheostat/initialize` script actually relies on [react-with-styles-interface-css](https://github.com/airbnb/react-with-styles-interface-css) under the hood. If you are interested in a different solution for styling in your project, you can do your own initialization of a another [interface](https://github.com/airbnb/react-with-styles/blob/master/README.md#interfaces). At Airbnb, for instance, we rely on [Aphrodite](https://github.com/Khan/aphrodite) under the hood and therefore use the Aphrodite interface for `react-with-styles`. If you want to do the same, you would use the following pattern:\n```js\nimport ThemedStyleSheet from 'react-with-styles/lib/ThemedStyleSheet';\nimport aphroditeInterface from 'react-with-styles-interface-aphrodite';\nimport DefaultTheme from 'rheostat/lib/themes/DefaultTheme';\n\nThemedStyleSheet.registerInterface(aphroditeInterface);\nThemedStyleSheet.registerTheme(DefaultTheme);\n```\n\nThe above code has to be run before any `rheostat` component is imported. Otherwise, you will get an error. Also note that if you register any custom interface manually, you *must* also manually register a theme.\n\n### Theming\n`rheostat` also now supports a different way to theme. You can see the default theme values in [this file](https://github.com/airbnb/rheostat/blob/master/src/themes/DefaultTheme.js) and you would override them in the following manner:\n```js\nimport ThemedStyleSheet from 'react-with-styles/lib/ThemedStyleSheet';\nimport aphroditeInterface from 'react-with-styles-interface-aphrodite';\nimport DefaultTheme from 'rheostat/lib/themes/DefaultTheme';\n\nThemedStyleSheet.registerInterface(aphroditeInterface);\nThemedStyleSheet.registerTheme({\n  rheostat: {\n    ...DefaultTheme.rheostat,\n    color: {\n      ...DefaultTheme.rheostat.color,\n      progressBar: 'red',\n    },\n  },\n});\n```\n\nThe above code would make the default progress bar red, instead of light blue. Note that you *must* register an interface if you manually register a theme. One will not work without the other.\n\n#### A note on using `react-with-styles-interface-css`\nThe default interface that `rheostat` ships with is the [CSS interface](https://github.com/airbnb/react-with-styles-interface-css). If you want to use this interface along with the theme registration method, you will need to rebuild the core `rheostat.css` file. We do not currently expose a utility method to build this file, but you can follow along with the code in https://github.com/airbnb/rheostat/blob/master/scripts/buildCSS.js to build your own custom themed CSS file.\n\n### RTL Support\n\n`rheostat` now supports automatic RTL rendering through [`react-with-direction`](https://github.com/airbnb/react-with-direction).\n\n## Live Playground\n\nFor more examples you can check out the storybook.\n\n* Clone this repo on your machine.\n* `npm install`\n* `npm run storybook`\n* Visit `http://localhost:9001/`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fairbnb%2Frheostat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fairbnb%2Frheostat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fairbnb%2Frheostat/lists"}