包含以下组件
步进器
名称 | 类型 | 默认值 | 描述 |
---|---|---|---|
buttonsOnly | 布尔值 | false | 禁用步进器按钮之间的内部值容器 |
颜色 | 对象 | 具有 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' | |
组件 | 字符串 | 'div' | 组件的 HTML 元素 |
输入 | 布尔值 | false | 定义是否应渲染元素 |
inputDisabled | 布尔值 | false | 定义步进器输入是否禁用 |
inputPlaceholder | 字符串 | 输入占位符 | |
inputReadOnly | 布尔值 | false | 定义步进器输入是否只读 |
inputType | 字符串 | 'text' | 输入类型 |
大 | 布尔值 | 未定义 | 使步进器变大。覆盖 |
largeIos | 布尔值 | false | 在 iOS 主题中使步进器变大 |
largeMaterial | 布尔值 | false | 在 Material 主题中使步进器变大 |
轮廓 | 布尔值 | 未定义 | 使步进器轮廓。覆盖 |
outlineIos | 布尔值 | false | 在 iOS 主题中使步进器轮廓 |
outlineMaterial | 布尔值 | false | 在 Material 主题中使步进器轮廓 |
凸起 | 布尔值 | 未定义 | 使步进器凸起(带阴影)。覆盖 |
raisedIos | 布尔值 | false | 在 iOS 主题中使步进器凸起(带阴影) |
raisedMaterial | 布尔值 | false | 在 Material 主题中使步进器凸起(带阴影) |
圆形 | 布尔值 | 未定义 | 使步进器圆形。覆盖 |
roundedIos | 布尔值 | false | 在 iOS 主题中使步进器圆形 |
roundedMaterial | 布尔值 | false | 在 Material 主题中使步进器圆形 |
小 | 布尔值 | 未定义 | 使步进器变小。覆盖 |
smallIos | 布尔值 | false | 在 iOS 主题中使步进器变小 |
smallMaterial | 布尔值 | false | 在 Material 主题中使步进器变小 |
touchRipple | 布尔值 | true | 在 Material 主题中启用触摸涟漪效果 |
价值 | 数字 | 0 | 步进器值 |
onBlur | function(e) | 步进器输入 | |
onChange | function(e) | 步进器输入 | |
onFocus | function(e) | 步进器输入 | |
onInput | function(e) | 步进器输入 | |
onMinus | function(e) | 步进器“减号”按钮单击处理程序 | |
onPlus | function(e) | 步进器“加号”按钮单击处理程序 |
<script>import {Page,Navbar,NavbarBackLink,Stepper,Block,BlockTitle,List,ListItem,} from 'konsta/svelte';let value = 1;const increase = () => {value = value + 1;};const decrease = () => {value = value - 1 < 0 ? 0 : value - 1;};let inputValue = 1;const increaseInput = () => {const v = parseInt(inputValue, 10);if (isNaN(v)) inputValue = 0;else inputValue = v + 1;};const decreaseInput = () => {const v = parseInt(inputValue, 10);if (isNaN(v)) inputValue = 0;inputValue = v - 1 < 0 ? 0 : v - 1;};const onInputChange = (e) => {inputValue = e.target.value;};const onInputBlur = () => {if (isNaN(parseInt(inputValue, 10))) inputValue = 0;};</script><Page><Navbar title="Stepper" /><BlockTitle>Shape and size</BlockTitle><Block strongIos outlineIos class="text-center space-y-4"><div class="grid grid-cols-2 gap-4"><div><div class="block text-xs mb-1">Default</div><Stepper {value} onPlus={increase} onMinus={decrease} /></div><div><div class="block text-xs mb-1">Round</div><Stepper {value} rounded onPlus={increase} onMinus={decrease} /></div></div><div class="grid grid-cols-2 gap-4 margin-top"><div><div class="block text-xs mb-1">Outline</div><Stepper {value} outline onPlus={increase} onMinus={decrease} /></div><div><div class="block text-xs mb-1">Rounded Outline</div><Stepper {value} outline rounded onPlus={increase} onMinus={decrease} /></div></div><div class="grid grid-cols-2 gap-4 margin-top"><div><div class="block text-xs mb-1">Small</div><Stepper {value} onPlus={increase} onMinus={decrease} small /></div><div><div class="block text-xs mb-1">Small Round</div><Stepper {value} small rounded onPlus={increase} onMinus={decrease} /></div></div><div class="grid grid-cols-2 gap-4 margin-top"><div><div class="block text-xs mb-1">Small Outline</div><Stepper {value} small outline onPlus={increase} onMinus={decrease} /></div><div><div class="block text-xs mb-1">Small Rounded Outline</div><Stepper{value}smallroundedoutlineonPlus={increase}onMinus={decrease}/></div></div><div class="grid grid-cols-2 gap-4 margin-top"><div><div class="block text-xs mb-1">Large</div><Stepper {value} onPlus={increase} onMinus={decrease} large /></div><div><div class="block text-xs mb-1">Large Round</div><Stepper {value} large rounded onPlus={increase} onMinus={decrease} /></div></div><div class="grid grid-cols-2 gap-4 margin-top"><div><div class="block text-xs mb-1">Large Outline</div><Stepper {value} large outline onPlus={increase} onMinus={decrease} /></div><div><div class="block text-xs mb-1">Large Rounded Outline</div><Stepper{value}largeroundedoutlineonPlus={increase}onMinus={decrease}/></div></div></Block><BlockTitle>Raised</BlockTitle><Block strongIos outlineIos class="text-center space-y-4"><div class="grid grid-cols-2 gap-4"><div><div class="block text-xs mb-1">Default</div><Stepper {value} raised onPlus={increase} onMinus={decrease} /></div><div><div class="block text-xs mb-1">Round</div><Stepper {value} raised rounded onPlus={increase} onMinus={decrease} /></div></div><div class="grid grid-cols-2 gap-4 margin-top"><div><div class="block text-xs mb-1">Outline</div><Stepper {value} raised outline onPlus={increase} onMinus={decrease} /></div><div><div class="block text-xs mb-1">Round Outline</div><Stepper{value}raisedoutlineroundedonPlus={increase}onMinus={decrease}/></div></div><div class="grid grid-cols-2 gap-4 margin-top"><div><div class="block text-xs mb-1">Small</div><Stepper {value} raised small onPlus={increase} onMinus={decrease} /></div><div><div class="block text-xs mb-1">Small Round</div><Stepper{value}raisedsmallroundedonPlus={increase}onMinus={decrease}/></div></div><div class="grid grid-cols-2 gap-4 margin-top"><div><div class="block text-xs mb-1">Small Outline</div><Stepper{value}raisedsmalloutlineonPlus={increase}onMinus={decrease}/></div><div><div class="block text-xs mb-1">Small Rounded Outline</div><Stepper{value}raisedsmallroundedoutlineonPlus={increase}onMinus={decrease}/></div></div><div class="grid grid-cols-2 gap-4 margin-top"><div><div class="block text-xs mb-1">Large</div><Stepper {value} raised large onPlus={increase} onMinus={decrease} /></div><div><div class="block text-xs mb-1">Large Round</div><Stepper{value}raisedlargeroundedonPlus={increase}onMinus={decrease}/></div></div><div class="grid grid-cols-2 gap-4 margin-top"><div><div class="block text-xs mb-1">Large Outline</div><Stepper{value}raisedlargeoutlineonPlus={increase}onMinus={decrease}/></div><div><div class="block text-xs mb-1">Large Rounded Outline</div><Stepper{value}raisedlargeroundedoutlineonPlus={increase}onMinus={decrease}/></div></div></Block><BlockTitle>With Text Input</BlockTitle><Block strongIos outlineIos class="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><ListItem title={`Value is ${value}`}><Stepperslot="after"{value}buttonsOnlyonPlus={increase}onMinus={decrease}/></ListItem><ListItem title={`Value is ${value}`}><Stepperslot="after"{value}outlinebuttonsOnlyonPlus={increase}onMinus={decrease}/></ListItem><ListItem title={`Value is ${value}`}><Stepperslot="after"{value}raisedoutlinebuttonsOnlyonPlus={increase}onMinus={decrease}/></ListItem></List><BlockTitle>Colors</BlockTitle><Block strongIos outlineIos class="text-center space-y-4"><div class="grid grid-cols-2 gap-4"><div><Stepper{value}class="k-color-brand-red"onPlus={increase}onMinus={decrease}/></div><div><Stepper{value}roundedclass="k-color-brand-green"onPlus={increase}onMinus={decrease}/></div></div><div class="grid grid-cols-2 gap-4"><div><Stepper{value}class="k-color-brand-yellow"onPlus={increase}onMinus={decrease}/></div><div><Stepper{value}roundedclass="k-color-brand-purple"onPlus={increase}onMinus={decrease}/></div></div></Block></Page>