包含以下组件
步进器
名称 | 类型 | 默认值 | 描述 |
---|---|---|---|
buttonsOnly | 布尔值 | false | 禁用步进器按钮之间的内部值容器 |
colors | 对象 | 包含 Tailwind CSS 颜色类别的对象 | |
colors.activeBgIos | 字符串 | 'active:bg-primary' | |
colors.activeBgMaterial | 字符串 | '' | |
colors.fillActiveBgIos | 字符串 | 'active:bg-ios-primary-shade' | |
colors.fillActiveBgMaterial | 字符串 | '' | |
colors.fillBgIos | 字符串 | 'bg-primary' | |
colors.fillBgMaterial | 字符串 | 'bg-md-light-primary dark:bg-md-dark-primary' | |
colors.fillTextIos | 字符串 | 'text-white' | |
colors.fillTextMaterial | 字符串 | 'text-md-light-on-primary dark:text-md-dark-on-primary' | |
colors.fillTouchRipple | 字符串 | 'touch-ripple-white dark:touch-ripple-primary' | |
colors.outlineBorderIos | 字符串 | 'border-primary' | |
colors.outlineBorderMaterial | 字符串 | 'border-md-light-outline dark:border-md-dark-outline' | |
colors.textIos | 字符串 | 'text-primary' | |
colors.textMaterial | 字符串 | 'text-md-light-primary dark:text-md-dark-primary' | |
colors.touchRipple | 字符串 | 'touch-ripple-primary' | |
component | 字符串 | 'div' | 组件的 HTML 元素 |
defaultValue | 数字 | 在非受控组件的情况下,步进器输入的默认值 | |
input | 布尔值 | false | 定义是否渲染元素 |
inputDisabled | 布尔值 | false | 定义步进器输入是否禁用 |
inputPlaceholder | 字符串 | 输入占位符 | |
inputReadOnly | 布尔值 | false | 定义步进器输入是否为只读 |
inputType | 字符串 | 'text' | 输入类型 |
large | 布尔值 | undefined | 使步进器变大。覆盖 `largeIos` 和 `largeMaterial` |
largeIos | 布尔值 | false | 在 iOS 主题中使步进器变大 |
largeMaterial | 布尔值 | false | 在 Material 主题中使步进器变大 |
outline | 布尔值 | undefined | 使步进器轮廓分明。覆盖 `outlineIos` 和 `outlineMaterial` |
outlineIos | 布尔值 | false | 在 iOS 主题中使步进器轮廓分明 |
outlineMaterial | 布尔值 | false | 在 Material 主题中使步进器轮廓分明 |
raised | 布尔值 | undefined | 使步进器凸起(带阴影)。覆盖 `raisedIos` 和 `raisedMaterial` |
raisedIos | 布尔值 | false | 在 iOS 主题中使步进器凸起(带阴影) |
raisedMaterial | 布尔值 | false | 在 Material 主题中使步进器凸起(带阴影) |
rounded | 布尔值 | undefined | 使步进器圆形。覆盖 `roundedIos` 和 `roundedMaterial` |
roundedIos | 布尔值 | false | 在 iOS 主题中使步进器圆形 |
roundedMaterial | 布尔值 | false | 在 Material 主题中使步进器圆形 |
small | 布尔值 | undefined | 使步进器变小。覆盖 `smallIos` 和 `smallMaterial` |
smallIos | 布尔值 | false | 在 iOS 主题中使步进器变小 |
smallMaterial | 布尔值 | false | 在 Material 主题中使步进器变小 |
touchRipple | 布尔值 | true | 在 Material 主题中启用触摸涟漪效果 |
value | 数字 | 0 | 步进器值 |
onBlur | function(e) | 步进器输入 `blur` 处理程序 | |
onChange | function(e) | 步进器输入 `change` 处理程序 | |
onFocus | function(e) | 步进器输入 `focus` 处理程序 | |
onInput | function(e) | 步进器输入 `input` 处理程序 | |
onMinus | function(e) | 步进器“减号”按钮点击处理程序 | |
onPlus | function(e) | 步进器“加号”按钮点击处理程序 |
import React, { useState } from 'react';import {Page,Navbar,NavbarBackLink,Stepper,Block,BlockTitle,List,ListItem,} from 'konsta/react';export default function StepperPage() {const [value, setValue] = useState(1);const increase = () => {setValue(value + 1);};const decrease = () => {setValue(value - 1 < 0 ? 0 : value - 1);};const [inputValue, setInputValue] = useState(1);const increaseInput = () => {const v = parseInt(inputValue, 10);if (isNaN(v)) setInputValue(0);else setInputValue(v + 1);};const decreaseInput = () => {const v = parseInt(inputValue, 10);if (isNaN(v)) setInputValue(0);setInputValue(v - 1 < 0 ? 0 : v - 1);};const onInputChange = (e) => {setInputValue(e.target.value);};const onInputBlur = () => {if (isNaN(parseInt(inputValue, 10))) setInputValue(0);};return (<Page><Navbartitle="Stepper"/><BlockTitle>Shape and size</BlockTitle><Block strongIos outlineIos className="text-center space-y-4"><div className="grid grid-cols-2 gap-4"><div><div className="block text-xs mb-1">Default</div><Stepper value={value} onPlus={increase} onMinus={decrease} /></div><div><div className="block text-xs mb-1">Round</div><Steppervalue={value}roundedonPlus={increase}onMinus={decrease}/></div></div><div className="grid grid-cols-2 gap-4 margin-top"><div><div className="block text-xs mb-1">Outline</div><Steppervalue={value}outlineonPlus={increase}onMinus={decrease}/></div><div><div className="block text-xs mb-1">Rounded Outline</div><Steppervalue={value}outlineroundedonPlus={increase}onMinus={decrease}/></div></div><div className="grid grid-cols-2 gap-4 margin-top"><div><div className="block text-xs mb-1">Small</div><Stepper value={value} onPlus={increase} onMinus={decrease} small /></div><div><div className="block text-xs mb-1">Small Round</div><Steppervalue={value}smallroundedonPlus={increase}onMinus={decrease}/></div></div><div className="grid grid-cols-2 gap-4 margin-top"><div><div className="block text-xs mb-1">Small Outline</div><Steppervalue={value}smalloutlineonPlus={increase}onMinus={decrease}/></div><div><div className="block text-xs mb-1">Small Rounded Outline</div><Steppervalue={value}smallroundedoutlineonPlus={increase}onMinus={decrease}/></div></div><div className="grid grid-cols-2 gap-4 margin-top"><div><div className="block text-xs mb-1">Large</div><Stepper value={value} onPlus={increase} onMinus={decrease} large /></div><div><div className="block text-xs mb-1">Large Round</div><Steppervalue={value}largeroundedonPlus={increase}onMinus={decrease}/></div></div><div className="grid grid-cols-2 gap-4 margin-top"><div><div className="block text-xs mb-1">Large Outline</div><Steppervalue={value}largeoutlineonPlus={increase}onMinus={decrease}/></div><div><div className="block text-xs mb-1">Large Rounded Outline</div><Steppervalue={value}largeroundedoutlineonPlus={increase}onMinus={decrease}/></div></div></Block><BlockTitle>Raised</BlockTitle><Block strongIos outlineIos className="text-center space-y-4"><div className="grid grid-cols-2 gap-4"><div><div className="block text-xs mb-1">Default</div><Steppervalue={value}raisedonPlus={increase}onMinus={decrease}/></div><div><div className="block text-xs mb-1">Round</div><Steppervalue={value}raisedroundedonPlus={increase}onMinus={decrease}/></div></div><div className="grid grid-cols-2 gap-4 margin-top"><div><div className="block text-xs mb-1">Outline</div><Steppervalue={value}raisedoutlineonPlus={increase}onMinus={decrease}/></div><div><div className="block text-xs mb-1">Round Outline</div><Steppervalue={value}raisedoutlineroundedonPlus={increase}onMinus={decrease}/></div></div><div className="grid grid-cols-2 gap-4 margin-top"><div><div className="block text-xs mb-1">Small</div><Steppervalue={value}raisedsmallonPlus={increase}onMinus={decrease}/></div><div><div className="block text-xs mb-1">Small Round</div><Steppervalue={value}raisedsmallroundedonPlus={increase}onMinus={decrease}/></div></div><div className="grid grid-cols-2 gap-4 margin-top"><div><div className="block text-xs mb-1">Small Outline</div><Steppervalue={value}raisedsmalloutlineonPlus={increase}onMinus={decrease}/></div><div><div className="block text-xs mb-1">Small Rounded Outline</div><Steppervalue={value}raisedsmallroundedoutlineonPlus={increase}onMinus={decrease}/></div></div><div className="grid grid-cols-2 gap-4 margin-top"><div><div className="block text-xs mb-1">Large</div><Steppervalue={value}raisedlargeonPlus={increase}onMinus={decrease}/></div><div><div className="block text-xs mb-1">Large Round</div><Steppervalue={value}raisedlargeroundedonPlus={increase}onMinus={decrease}/></div></div><div className="grid grid-cols-2 gap-4 margin-top"><div><div className="block text-xs mb-1">Large Outline</div><Steppervalue={value}raisedlargeoutlineonPlus={increase}onMinus={decrease}/></div><div><div className="block text-xs mb-1">Large Rounded Outline</div><Steppervalue={value}raisedlargeroundedoutlineonPlus={increase}onMinus={decrease}/></div></div></Block><BlockTitle>With Text Input</BlockTitle><Block strongIos outlineIos className="text-center space-y-4"><div><Steppervalue={inputValue}inputonChange={onInputChange}onBlur={onInputBlur}onPlus={increaseInput}onMinus={decreaseInput}/></div><div><Steppervalue={inputValue}outlineinputonChange={onInputChange}onBlur={onInputBlur}onPlus={increaseInput}onMinus={decreaseInput}/></div></Block><BlockTitle>Only Buttons</BlockTitle><List strongIos outlineIos><ListItemtitle={`Value is ${value}`}after={<Steppervalue={value}buttonsOnlyonPlus={increase}onMinus={decrease}/>}/><ListItemtitle={`Value is ${value}`}after={<Steppervalue={value}outlinebuttonsOnlyonPlus={increase}onMinus={decrease}/>}/><ListItemtitle={`Value is ${value}`}after={<Steppervalue={value}raisedoutlinebuttonsOnlyonPlus={increase}onMinus={decrease}/>}/></List><BlockTitle>Colors</BlockTitle><Block strongIos outlineIos className="text-center space-y-4"><div className="grid grid-cols-2 gap-4"><div><Steppervalue={value}className="k-color-brand-red"onPlus={increase}onMinus={decrease}/></div><div><Steppervalue={value}roundedclassName="k-color-brand-green"onPlus={increase}onMinus={decrease}/></div></div><div className="grid grid-cols-2 gap-4"><div><Steppervalue={value}className="k-color-brand-yellow"onPlus={increase}onMinus={decrease}/></div><div><Steppervalue={value}roundedclassName="k-color-brand-purple"onPlus={increase}onMinus={decrease}/></div></div></Block></Page>);}