import * as React from "react"; import * as System from "~/components/system"; import * as Constants from "~/common/constants"; import Group from "~/components/system/Group"; import SystemPage from "~/components/system/SystemPage"; import ViewSourceLink from "~/components/system/ViewSourceLink"; import CodeBlock from "~/components/system/CodeBlock"; export default class SystemPageSliders extends React.Component { state = { one: 0, two: 0, three: 9500, four: 0, }; _handleChange = (e) => { this.setState({ [e.target.name]: e.target.value }); }; render() { return ( Sliders

The Slider component is used to select from a range of numeric values.


Imports

Import React and the Slider Component.

{`import * as React from 'react'; import { Slider } from 'slate-react-system';`}

Slider



Declare the Slider component, specifying a{" "} min,{" "} max, and{" "} step. Declaring{" "} discrete true will yield a slider that snaps to each step.

{`class ExampleOne extends React.Component { state = { one: 0, two: 0 } _handleChange = e => this.setState( { [e.target.name]: e.target.value } ); render() { return(
) } }`}



Slider with display



You can declare the Slider component with{" "} inputBox or{" "} bubble to include a display of the value. Values can be entered in the input box and the input box can be styled with inputStyle.

{`class ExampleTwo extends React.Component { state = { three: 9500, four: 0 } _handleChange = e => this.setState( { [e.target.name]: e.target.value } ); render() { return(
) } }`}



Accepted React Properties

onChange ), b: "function", c: "null", d: "Function called upon an onChange event", }, { id: 2, a: ( value ), b: "number", c: "null", d: "The value that the slider takes. Can be used to assign default values as well.", }, { id: 3, a: "name", b: "string", c: "null", d: "Slider name.", }, { id: 4, a: "label", b: "string", c: "null", d: "Label text.", }, { id: 5, a: "description", b: "string", c: "null", d: "Description text.", }, { id: 6, a: "tooltip", b: "string", c: "null", d: "Tooltip text.", }, { id: 7, a: "min", b: "number", c: "0", d: "Lower end of range", }, { id: 8, a: "max", b: "number", c: "100", d: "Higher end of range", }, { id: 9, a: "step", b: "number", c: "1", d: "Increments in which values can be selected.", }, { id: 10, a: "discrete", b: "boolean", c: "false", d: "If true, slider will snap to steps specified. Otherwise, slider is continuous", }, { id: 11, a: "bubble", b: "boolean", c: "false", d: "If true, a bubble floating above the handle will be displayed with the selected value.", }, { id: 12, a: "inputBox", b: "boolean", c: "false", d: "If true, an input box will be displayed with the selected value. The value can be edited using the input box.", }, { id: 13, a: "inputStyle", b: "Object", c: "null", d: "Style applied to the input box (useful for specifying width, etc).", }, { id: 14, a: "containerStyle", b: "Object", c: "null", d: "Style applied to the container holding the slider and input box (useful for specifying margin or height, etc).", }, ], }} />
); } }