Skip to main content

Slider Component

The Slider component allows for the adjustment of a numerical value within a defined range using a graphical slider interface. It is built using Material-UI components and integrates seamlessly with forms managed by React Hook Form.

Schema

warning

Note: Ensure that the slider values are managed correctly in the form state to avoid discrepancies and state synchronization issues.

{
"name": "volume",
"meta": {
"displayName": "Volume Control",
"displayType": "slider",
"value": 20,
"min": 0,
"max": 100,
"step": 1,
"description": "Adjust the volume level.",
"readOnly": false,
"htmlProps": {
"showInfoIcon": true,
"showRange": true
},
"validation": {
"infoDetail": {
"infoMsg": "Choose a value between 0 and 100"
}
}
}
}

Example

20

0

100

Adjust the volume level.


Form Data:
{}

;

Props

meta object

NameDescriptionType
displayNameThe label displayed above the sliderstring
displayTypeType of the field display, which is "slider" in this casestring
valueInitial value of the slidernumber
minMinimum value the slider can adjust tonumber
maxMaximum value the slider can adjust tonumber
stepThe granularity that the slider can step throughnumber
descriptionA brief description of what the slider controlsstring
htmlPropsAdditional HTML properties like showInfoIconobject
allowDynamicEnable Static or dynamic input for array inputboolean
showRangeShow range text below sliderboolean
readOnlyA readonly field is not editable and value cannot be changedboolean

htmlProps object

NameDescriptionType
showInfoIconToggles visibility of an info icon with a tooltip on hoverboolean

Interaction Handlers

NameDescription
handleChangeFunction to execute when the slider value changes
validationRulesValidation rules passed to the Controller component

Example JSON

Basic Slider

{
"name": "brightness",
"meta": {
"displayName": "Screen Brightness",
"displayType": "slider",
"value": 50,
"min": 0,
"max": 100,
"step": 10,
"description": "Adjust screen brightness level."
}
}

Slider with Info Icon and Validation

{
"name": "contrast",
"meta": {
"displayName": "Screen Contrast",
"displayType": "slider",
"value": 50,
"min": 10,
"max": 90,
"step": 5,
"description": "Adjust screen contrast level.",
"htmlProps": {
"showInfoIcon": true
},
"validation": {
"infoDetail": {
"infoMsg": "Choose a value between 10 and 90"
}
}
}
}