Stepper - 图1

Stepper React Component

Stepper React component represents Stepper component.

Stepper Components

There are following components included:

  • **Stepper** / **F7Stepper**

Stepper Properties

PropTypeDefaultDescription
<Stepper> properties
initbooleantrueInitializes Stepper
valuenumber0Stepper value
minnumber0Minimum value
maxnumber100Maximum value
stepnumber1Maximum value
wrapsbooleanfalseWhen enabled, incrementing beyond maximum value sets value to minimum value; likewise, decrementing below minimum value sets value to maximum value
autorepeatbooleanfalseWhen enabled it will repeatedly increase/decrease values while you tap and hold plus/minus buttons
autorepeatDynamicbooleanfalseWhen enabled it will increase autorepeat ratio based on how long you hold the button
inputbooleantrueDefines should it render <input> element or not
inputReadonlybooleanfalseMakes inner input element readonly
namestringInput element “name” attribute
buttonsOnlybooleanfalseDisables inner value container between stepper buttons
formatValuefunction(value)Custom function to format value for value element between buttons. It must return new formatted value
manualInputModebooleanfalseEnables manual input mode. This mode allows to type value from keyboar and check fractional part with defined accurancy. Also, step parameter is ignored when typing in this mode.
decimalPointnumber4Number of digits after dot, when in manual input mode.
buttonsEndInputModebooleantrueDisables manual input mode on Stepper’s minus or plus button click.
disabledbooleanfalseDefines whether the stepper is disabled or not
roundbooleanfalseMakes stepper round
roundIosbooleanfalseMakes stepper round for iOS theme only
roundMdbooleanfalseMakes stepper round for MD theme only
roundAurorabooleanfalseMakes stepper round for Aurora theme only
largebooleanfalseMakes large stepper
largeIosbooleanfalseMakes large stepper for iOS theme only
largeMdbooleanfalseMakes large stepper for MD theme only
largeAurorabooleanfalseMakes large stepper for Aurora theme only
smallbooleanfalseMakes small stepper
smallIosbooleanfalseMakes small stepper for iOS theme only
smallMdbooleanfalseMakes small stepper for MD theme only
smallAurorabooleanfalseMakes small stepper for Aurora theme only
fillbooleanfalseMakes stepper filled color
fillIosbooleanfalseMakes stepper filled color for iOS theme only
fillMdbooleanfalseMakes stepper filled color for MD theme only
fillAurorabooleanfalseMakes stepper filled color for Aurora theme only
raisedbooleanfalseMakes stepper raised.
raisedIosbooleanfalseMakes stepper raised for iOS theme.
raisedMdbooleanfalseMakes stepper raised for MD theme.
raisedAurorabooleanfalseMakes stepper raised for Aurora theme.

Stepper Events

EventDescription
<Stepper> events
stepperChangeEvent will be triggered when Stepper value has been changed
stepperMinusClickEvent will be triggered on “minus” button click
stepperPlusClickEvent will be triggered on “plus” button click
inputEvent will be triggered on input’s input event

Stepper Methods

EventDescription
<Stepper> methods
.increment()Increment stepper value, similar to clicking on its “plus” button
.decremenet()Decrement stepper value, similar to clicking on its “minus” button
.setValue(newValue)Set new stepper value
.getValue()Returns stepper value

Examples

  1. export default class extends React.Component {
  2. constructor(props) {
  3. super(props);
  4. this.state = {
  5. applesCount: 0,
  6. orangesCount: 0,
  7. meetingTime: 15,
  8. };
  9. }
  10. get meetingTimeComputed() {
  11. const self = this;
  12. const value = self.state.meetingTime;
  13. const hours = Math.floor(value / 60);
  14. const minutes = value - (hours * 60);
  15. const formatted = [];
  16. if (hours > 0) {
  17. formatted.push(hours + ' ' + (hours > 1 ? 'hours' : 'hour'));
  18. }
  19. if (minutes > 0) {
  20. formatted.push(minutes + ' minutes');
  21. }
  22. return formatted.join(' ');
  23. }
  24. setApples(value) {
  25. this.setState({ applesCount: value });
  26. }
  27. setOranges(value) {
  28. this.setState({ orangesCount: value });
  29. }
  30. setMeetingTime(value) {
  31. this.setState({ meetingTime: value });
  32. }
  33. render () {
  34. return (
  35. <Page>
  36. <Navbar title="Stepper"></Navbar>
  37. <BlockTitle>Shape and size</BlockTitle>
  38. <Block strong className="text-align-center">
  39. <Row>
  40. <Col>
  41. <small className="display-block">Default</small>
  42. <Stepper></Stepper>
  43. </Col>
  44. <Col>
  45. <small className="display-block">Round</small>
  46. <Stepper round></Stepper>
  47. </Col>
  48. </Row>
  49. <Row className="margin-top">
  50. <Col>
  51. <small className="display-block">Fill</small>
  52. <Stepper fill></Stepper>
  53. </Col>
  54. <Col>
  55. <small className="display-block">Round Fill</small>
  56. <Stepper fill round></Stepper>
  57. </Col>
  58. </Row>
  59. <Row className="margin-top">
  60. <Col>
  61. <small className="display-block">Small</small>
  62. <Stepper small></Stepper>
  63. </Col>
  64. <Col>
  65. <small className="display-block">Small Round</small>
  66. <Stepper small round></Stepper>
  67. </Col>
  68. </Row>
  69. <Row className="margin-top">
  70. <Col>
  71. <small className="display-block">Small Fill</small>
  72. <Stepper small fill></Stepper>
  73. </Col>
  74. <Col>
  75. <small className="display-block">Small Round Fill</small>
  76. <Stepper small round fill></Stepper>
  77. </Col>
  78. </Row>
  79. <Row className="margin-top">
  80. <Col>
  81. <small className="display-block">Large</small>
  82. <Stepper large></Stepper>
  83. </Col>
  84. <Col>
  85. <small className="display-block">Large Round</small>
  86. <Stepper large round></Stepper>
  87. </Col>
  88. </Row>
  89. <Row className="margin-top">
  90. <Col>
  91. <small className="display-block">Large Fill</small>
  92. <Stepper large fill></Stepper>
  93. </Col>
  94. <Col>
  95. <small className="display-block">Large Round Fill</small>
  96. <Stepper large round fill></Stepper>
  97. </Col>
  98. </Row>
  99. </Block>
  100. <BlockTitle>Raised</BlockTitle>
  101. <Block strong className="text-align-center">
  102. <Row>
  103. <Col>
  104. <small className="display-block">Default</small>
  105. <Stepper raised></Stepper>
  106. </Col>
  107. <Col>
  108. <small className="display-block">Round</small>
  109. <Stepper raised round></Stepper>
  110. </Col>
  111. </Row>
  112. <Row className="margin-top">
  113. <Col>
  114. <small className="display-block">Fill</small>
  115. <Stepper raised fill></Stepper>
  116. </Col>
  117. <Col>
  118. <small className="display-block">Round Fill</small>
  119. <Stepper raised fill round></Stepper>
  120. </Col>
  121. </Row>
  122. <Row className="margin-top">
  123. <Col>
  124. <small className="display-block">Small</small>
  125. <Stepper raised small></Stepper>
  126. </Col>
  127. <Col>
  128. <small className="display-block">Small Round</small>
  129. <Stepper raised small round></Stepper>
  130. </Col>
  131. </Row>
  132. <Row className="margin-top">
  133. <Col>
  134. <small className="display-block">Small Fill</small>
  135. <Stepper raised small fill></Stepper>
  136. </Col>
  137. <Col>
  138. <small className="display-block">Small Round Fill</small>
  139. <Stepper raised small round fill></Stepper>
  140. </Col>
  141. </Row>
  142. <Row className="margin-top">
  143. <Col>
  144. <small className="display-block">Large</small>
  145. <Stepper raised large></Stepper>
  146. </Col>
  147. <Col>
  148. <small className="display-block">Large Round</small>
  149. <Stepper raised large round></Stepper>
  150. </Col>
  151. </Row>
  152. <Row className="margin-top">
  153. <Col>
  154. <small className="display-block">Large Fill</small>
  155. <Stepper raised large fill></Stepper>
  156. </Col>
  157. <Col>
  158. <small className="display-block">Large Round Fill</small>
  159. <Stepper raised large round fill></Stepper>
  160. </Col>
  161. </Row>
  162. </Block>
  163. <BlockTitle>Colors</BlockTitle>
  164. <Block strong className="text-align-center">
  165. <Row>
  166. <Col>
  167. <Stepper fill color="red"></Stepper>
  168. </Col>
  169. <Col>
  170. <Stepper fill round color="green"></Stepper>
  171. </Col>
  172. </Row>
  173. <Row className="margin-top">
  174. <Col>
  175. <Stepper fill color="blue"></Stepper>
  176. </Col>
  177. <Col>
  178. <Stepper fill round color="pink"></Stepper>
  179. </Col>
  180. </Row>
  181. <Row className="margin-top">
  182. <Col>
  183. <Stepper fill small color="yellow"></Stepper>
  184. </Col>
  185. <Col>
  186. <Stepper fill small round color="orange"></Stepper>
  187. </Col>
  188. </Row>
  189. <Row className="margin-top">
  190. <Col>
  191. <Stepper fill small color="gray"></Stepper>
  192. </Col>
  193. <Col>
  194. <Stepper fill small round color="black"></Stepper>
  195. </Col>
  196. </Row>
  197. </Block>
  198. <BlockTitle>Without input element</BlockTitle>
  199. <Block strong className="text-align-center">
  200. <Row>
  201. <Col>
  202. <Stepper input={false}></Stepper>
  203. </Col>
  204. <Col>
  205. <Stepper input={false} round></Stepper>
  206. </Col>
  207. </Row>
  208. </Block>
  209. <BlockTitle>Min, max, step</BlockTitle>
  210. <Block strong className="text-align-center">
  211. <Row>
  212. <Col>
  213. <Stepper value={100} min={0} max={1000} step={100}></Stepper>
  214. </Col>
  215. <Col>
  216. <Stepper input={false} value={5} min={0} max={10} step={0.5}></Stepper>
  217. </Col>
  218. </Row>
  219. </Block>
  220. <BlockTitle>Autorepeat (Tap & hold)</BlockTitle>
  221. <BlockHeader>Pressing and holding one of its buttons increments or decrements the steppers value repeatedly. With dynamic autorepeat, the rate of change depends on how long the user continues pressing the control.</BlockHeader>
  222. <Block strong className="text-align-center">
  223. <Row>
  224. <Col>
  225. <small className="display-block">Default</small>
  226. <Stepper value={0} min={0} max={100} step={1} autorepeat={true}></Stepper>
  227. </Col>
  228. <Col>
  229. <small className="display-block">Dynamic</small>
  230. <Stepper value={0} min={0} max={100} step={1} autorepeat={true} autorepeatDynamic={true}></Stepper>
  231. </Col>
  232. </Row>
  233. </Block>
  234. <BlockTitle>Wraps</BlockTitle>
  235. <BlockHeader>In wraps mode incrementing beyond maximum value sets value to minimum value, likewise, decrementing below minimum value sets value to maximum value</BlockHeader>
  236. <Block strong className="text-align-center">
  237. <Row>
  238. <Col>
  239. <Stepper value={0} min={0} max={10} step={1} autorepeat={true} wraps={true}></Stepper>
  240. </Col>
  241. </Row>
  242. </Block>
  243. <BlockTitle>Custom value element</BlockTitle>
  244. <List>
  245. <ListItem title={`Apples ${this.state.applesCount}`}>
  246. <Stepper buttonsOnly={true} small raised slot="after" onStepperChange={this.setApples.bind(this)}></Stepper>
  247. </ListItem>
  248. <ListItem title={`Oranges ${this.state.orangesCount}`}>
  249. <Stepper buttonsOnly={true} small raised slot="after" onStepperChange={this.setOranges.bind(this)}></Stepper>
  250. </ListItem>
  251. </List>
  252. <BlockTitle>Custom value format</BlockTitle>
  253. <List>
  254. <ListItem header="Meeting starts in" title={this.meetingTimeComputed}>
  255. <Stepper
  256. min={15}
  257. max={240}
  258. step={15}
  259. value={this.state.meetingTime}
  260. buttonsOnly={true}
  261. small
  262. slot="after"
  263. onStepperChange={this.setMeetingTime.bind(this)}
  264. ></Stepper>
  265. </ListItem>
  266. </List>
  267. <BlockTitle>Manual input</BlockTitle>
  268. <BlockHeader>It is possible to enter value manually from keyboard or mobile keypad. When click on input field, stepper enter into manual input mode, which allow type value from keyboar and check fractional part with defined accurancy. Click outside or enter Return key, ending manual mode.</BlockHeader>
  269. <Block strong className="text-align-center">
  270. <Row>
  271. <Col>
  272. <Stepper fill value={0} min={0} max={1000} step={1} autorepeat={true} wraps={true} manualInputMode={true} decimalPoint={2}></Stepper>
  273. </Col>
  274. </Row>
  275. </Block>
  276. </Page>
  277. );
  278. }
  279. }