🔥 认识我们的新项目 t0ggles - 你终极的项目管理工具! 🔥

按钮 React 组件

按钮组件

包含以下组件

  • Button - 单个按钮

按钮属性

名称类型默认值描述
clear布尔值未定义

使按钮采用清晰样式(无填充颜色)。覆盖clearIosclearMaterial属性

clearIos布尔值false

在 iOS 主题中使按钮采用清晰样式(无填充颜色)

clearMaterial布尔值false

在 Material 主题中使按钮采用清晰样式(无填充颜色)

colors对象

带有 Tailwind CSS 颜色类的对象

colors.activeBgIos字符串'active:bg-primary'
colors.activeBgMaterial字符串''
colors.disabledBg字符串'bg-black bg-opacity-10 dark:bg-white dark:bg-opacity-10'
colors.disabledBorder字符串'border-black border-opacity-10 dark:border-white dark:border-opacity-10'
colors.disabledText字符串'text-black text-opacity-30 dark:text-white dark:text-opacity-30'
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.tonalBgIos字符串'bg-primary'
colors.tonalBgMaterial字符串'bg-md-light-secondary-container dark:bg-md-dark-secondary-container'
colors.tonalTextIos字符串'text-primary'
colors.tonalTextMaterial字符串'text-md-light-on-secondary-container dark:text-md-dark-on-secondary-container'
colors.touchRipple字符串'touch-ripple-primary'
component字符串'button'

组件的 HTML 元素

disabled布尔值false

使按钮禁用

href字符串

链接的href属性,如果指定,也将被渲染为<a>元素

inline布尔值false

使按钮内联(例如display: inline-flex

large布尔值未定义

使按钮变大。覆盖largeIoslargeMaterial属性

largeIos布尔值false

在 iOS 主题中使按钮变大

largeMaterial布尔值false

在 Material 主题中使按钮变大

outline布尔值未定义

使按钮轮廓。覆盖outlineIosoutlineMaterial属性

outlineIos布尔值false

在 iOS 主题中使按钮轮廓

outlineMaterial布尔值false

在 Material 主题中使按钮轮廓

raised布尔值未定义

使按钮凸起(带有阴影)。覆盖raisedIosraisedMaterial属性

raisedIos布尔值false

在 iOS 主题中使按钮凸起(带有阴影)

raisedMaterial布尔值false

在 Material 主题中使按钮凸起(带有阴影)

rounded布尔值未定义

使按钮圆角。覆盖roundedIosroundedMaterial属性

roundedIos布尔值false

在 iOS 主题中使按钮圆角

roundedMaterial布尔值false

在 Material 主题中使按钮圆角

segmented布尔值false

渲染分段按钮,与<SegmentedButton>相同

segmentedActive布尔值false

渲染分段活动按钮,与<SegmentedButton active>相同

segmentedStrong布尔值false

渲染分段强按钮,与<SegmentedButton strong>相同

small布尔值未定义

使按钮变小。覆盖smallIossmallMaterial属性

smallIos布尔值false

在 iOS 主题中使按钮变小

smallMaterial布尔值false

在 Material 主题中使按钮变小

tonal布尔值未定义

使按钮采用色调样式(带有半透明填充颜色)。覆盖tonalIostonalMaterial属性

tonalIos布尔值false

在 iOS 主题中使按钮采用色调样式(带有半透明填充颜色)

tonalMaterial布尔值false

在 Material 主题中使按钮采用色调样式(带有半透明填充颜色)

touchRipple布尔值true

在 Material 主题中启用触摸涟漪效果

示例

Buttons.jsx
import React from 'react';
import {
Page,
Navbar,
NavbarBackLink,
Button,
Block,
BlockTitle,
} from 'konsta/react';
export default function ButtonsPage() {
return (
<Page>
<Navbar
title="Buttons"
/>
<BlockTitle>Default Buttons</BlockTitle>
<Block strong outlineIos className="space-y-2">
<div className="grid grid-cols-3 gap-x-4">
<Button>Button</Button>
<Button className="k-color-brand-red">Button</Button>
<Button>Button</Button>
</div>
<div className="grid grid-cols-3 gap-x-4">
<Button outline>Outline</Button>
<Button className="k-color-brand-red" outline>
Outline
</Button>
<Button outline>Outline</Button>
</div>
<div className="grid grid-cols-3 gap-x-4">
<Button clear>Clear</Button>
<Button className="k-color-brand-red" clear>
Clear
</Button>
<Button clear>Clear</Button>
</div>
<div className="grid grid-cols-3 gap-x-4">
<Button tonal>Tonal</Button>
<Button className="k-color-brand-red" tonal>
Tonal
</Button>
<Button tonal>Tonal</Button>
</div>
</Block>
<BlockTitle>Rounded Buttons</BlockTitle>
<Block strong outlineIos className="space-y-2">
<div className="grid grid-cols-3 gap-x-4">
<Button rounded>Button</Button>
<Button rounded className="k-color-brand-green">
Button
</Button>
<Button rounded>Button</Button>
</div>
<div className="grid grid-cols-3 gap-x-4">
<Button rounded outline>
Outline
</Button>
<Button rounded outline className="k-color-brand-green">
Outline
</Button>
<Button rounded outline>
Outline
</Button>
</div>
<div className="grid grid-cols-3 gap-x-4">
<Button rounded clear>
Clear
</Button>
<Button rounded clear className="k-color-brand-green">
Clear
</Button>
<Button rounded clear>
Clear
</Button>
</div>
</Block>
<BlockTitle>Large Buttons</BlockTitle>
<Block strong outlineIos className="space-y-2">
<div className="grid grid-cols-3 gap-x-4">
<Button large>Button</Button>
<Button large className="k-color-brand-yellow">
Button
</Button>
<Button large rounded>
Button
</Button>
</div>
<div className="grid grid-cols-3 gap-x-4">
<Button large outline>
Outline
</Button>
<Button large outline className="k-color-brand-yellow">
Outline
</Button>
<Button large rounded outline>
Outline
</Button>
</div>
<div className="grid grid-cols-3 gap-x-4">
<Button large clear>
Clear
</Button>
<Button large clear className="k-color-brand-yellow">
Clear
</Button>
<Button large rounded clear>
Clear
</Button>
</div>
</Block>
<BlockTitle>Small Buttons</BlockTitle>
<Block strong outlineIos className="space-y-2">
<div className="grid grid-cols-3 gap-x-4">
<Button small>Button</Button>
<Button small>Button</Button>
<Button small rounded>
Button
</Button>
</div>
<div className="grid grid-cols-3 gap-x-4">
<Button small outline>
Outline
</Button>
<Button small outline>
Outline
</Button>
<Button small rounded outline>
Outline
</Button>
</div>
<div className="grid grid-cols-3 gap-x-4">
<Button small clear>
Clear
</Button>
<Button small clear>
Clear
</Button>
<Button small rounded clear>
Clear
</Button>
</div>
</Block>
<BlockTitle>Raised Buttons</BlockTitle>
<Block strong outlineIos className="space-y-2">
<div className="grid grid-cols-3 gap-x-4">
<Button raised>Button</Button>
<Button raised>Button</Button>
<Button raised rounded>
Button
</Button>
</div>
<div className="grid grid-cols-3 gap-x-4">
<Button raised outline>
Outline
</Button>
<Button raised outline>
Outline
</Button>
<Button raised rounded outline>
Outline
</Button>
</div>
<div className="grid grid-cols-3 gap-x-4">
<Button raised clear>
Clear
</Button>
<Button raised clear>
Clear
</Button>
<Button raised rounded clear>
Clear
</Button>
</div>
</Block>
<BlockTitle>Disabled Buttons</BlockTitle>
<Block strong outlineIos className="space-y-2">
<div className="grid grid-cols-3 gap-x-4">
<Button disabled>Button</Button>
<Button disabled outline>
Outline
</Button>
<Button disabled clear>
Clear
</Button>
</div>
</Block>
</Page>
);
}
代码许可证: MIT.
2022 © Konsta UI by nolimits4web.