Skip to content

feat(button): [button] add custom-style attribute #3535

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions examples/sites/demos/apis/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,21 @@ export default {
pcDemo: 'dynamic-disabled',
mfDemo: ''
},
{
name: 'custom-style',
type: 'object',
defaultValue: '',
desc: {
'zh-CN': '设置 custom-style 属性按钮样式',
'en-US': 'Set the custom-style attribute to customize the button style'
},
meta: {
stable: '3.25.0'
},
mode: ['pc', 'mobile-first'],
pcDemo: 'icon',
mfDemo: 'type'
},
Comment on lines +66 to +80
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix the defaultValue inconsistency.

The API documentation shows defaultValue: '' but the actual implementation in index.ts uses default: () => ({}) which returns an empty object, not an empty string.

Apply this fix to match the implementation:

-          defaultValue: '',
+          defaultValue: '{}',

Otherwise, the API documentation is comprehensive and well-structured with proper bilingual descriptions and version metadata.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{
name: 'custom-style',
type: 'object',
defaultValue: '',
desc: {
'zh-CN': '设置 custom-style 属性按钮样式',
'en-US': 'Set the custom-style attribute to customize the button style'
},
meta: {
stable: '3.25.0'
},
mode: ['pc', 'mobile-first'],
pcDemo: 'icon',
mfDemo: 'type'
},
{
name: 'custom-style',
type: 'object',
defaultValue: '{}',
desc: {
'zh-CN': '设置 custom-style 属性按钮样式',
'en-US': 'Set the custom-style attribute to customize the button style'
},
meta: {
stable: '3.25.0'
},
mode: ['pc', 'mobile-first'],
pcDemo: 'icon',
mfDemo: 'type'
},
🤖 Prompt for AI Agents
In examples/sites/demos/apis/button.js around lines 66 to 80, the defaultValue
for the 'custom-style' property is set to an empty string '', but the actual
implementation in index.ts uses a default function returning an empty object.
Update the defaultValue in this file to be a function returning an empty object
to match the implementation and ensure consistency between documentation and
code.

{
name: 'ghost',
type: 'boolean',
Expand Down
2 changes: 1 addition & 1 deletion examples/sites/demos/mobile-first/app/button/type.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<tiny-button type="primary"> 主要按钮 </tiny-button>
<tiny-button type="success"> 成功按钮 </tiny-button>
<tiny-button type="info"> 信息按钮 </tiny-button>
<tiny-button type="warning"> 警告按钮 </tiny-button>
<tiny-button type="warning" :custom-style="{ maxWidth: 'none' }"> 警告按钮 警告按钮警告按钮警告按钮</tiny-button>
<tiny-button type="danger"> 危险按钮 </tiny-button>
<tiny-button type="text"> 文本按钮 </tiny-button>
</div>
Expand Down
4 changes: 2 additions & 2 deletions examples/sites/demos/mobile-first/app/button/webdoc/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ export default {
},
desc: {
'zh-CN':
'<p>通过 <code>type</code> 属性可以设置不同的主题样式,主要包括 primary、success、info、warning、danger、text。<p>',
'<p>通过 <code>type</code> 属性可以设置不同的主题样式,主要包括 primary、success、info、warning、danger、text。设置 <code>custom-style</code> 属性按钮样式<p>',
'en-US':
'<p>You can use the <code>type</code> attribute to set different theme styles, including primary, success, info, warning, danger, and text.</p>'
'<p>You can use the <code>type</code> attribute to set different theme styles, including primary, success, info, warning, danger, and text. The <code>custom-style</code> property sets the button style.</p>'
},
codeFiles: ['type.vue']
},
Expand Down
4 changes: 3 additions & 1 deletion examples/sites/demos/pc/app/button/icon-composition-api.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
<tiny-layout>
<tiny-row>
<tiny-button type="primary" :icon="TinyIconEdit"> 图标按钮 </tiny-button>
<tiny-button :icon="TinyIconSearch"> 图标按钮 </tiny-button>
<tiny-button :icon="TinyIconSearch" :custom-style="{ maxWidth: 'none' }">
图标按钮图标按钮图标按钮图标按钮
</tiny-button>
<tiny-button type="success" :icon="TinyIconYes"> 图标按钮 </tiny-button>
<tiny-button type="info" :icon="TinyIconMail"> 图标按钮 </tiny-button>
<tiny-button type="warning" :icon="TinyIconStarO"> 图标按钮 </tiny-button>
Expand Down
4 changes: 3 additions & 1 deletion examples/sites/demos/pc/app/button/icon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
<tiny-layout>
<tiny-row>
<tiny-button type="primary" :icon="IconEdit"> 图标按钮 </tiny-button>
<tiny-button :icon="IconSearch"> 图标按钮 </tiny-button>
<tiny-button :icon="IconSearch" :custom-style="{ maxWidth: 'none' }">
图标按钮图标按钮图标按钮图标按钮
</tiny-button>
<tiny-button type="success" :icon="IconYes"> 图标按钮 </tiny-button>
<tiny-button type="info" :icon="IconMail"> 图标按钮 </tiny-button>
<tiny-button type="warning" :icon="IconStarO"> 图标按钮 </tiny-button>
Expand Down
5 changes: 3 additions & 2 deletions examples/sites/demos/pc/app/button/webdoc/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ export default {
'en-US': 'Icon Button'
},
desc: {
'zh-CN': '通过 <code>icon</code> 属性,设置按钮展示图标。',
'en-US': 'Display icons and receive an icon component through the <code>icon</code> settings button'
'zh-CN': '通过 <code>icon</code> 属性,设置按钮展示图标。<code>custom-style</code>属性设置按钮样式。',
'en-US':
'Display icons and receive an icon component through the <code>icon</code> settings button. The <code>custom-style</code> property sets the button style.'
},
codeFiles: ['icon.vue']
},
Expand Down
5 changes: 5 additions & 0 deletions packages/vue/src/button/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ export const buttonProps = {
type: Boolean,
default: false
},
/** 自定义样式 */
customStyle: {
type: Object,
default: () => ({})
},
/** 是否幽灵按钮 */
ghost: Boolean,
/** 点击事件 */
Expand Down
4 changes: 3 additions & 1 deletion packages/vue/src/button/src/mobile-first.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
customClass
)
"
:style="customStyle"
:tabindex="tabindex"
v-bind="a($attrs, ['class', 'style', 'id'], true)"
>
Expand Down Expand Up @@ -62,7 +63,8 @@ export default defineComponent({
'tabindex',
'href',
'customClass',
'banner'
'banner',
'customStyle'
],
components: { IconLoading: iconLoading() },
setup(props, context): any {
Expand Down
4 changes: 3 additions & 1 deletion packages/vue/src/button/src/pc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
'is-only-icon': icon && !loading && !(text || slots.default)
}
]"
:style="customStyle"
:tabindex="tabindex"
v-bind="a($attrs, ['class', 'style', 'title', 'id'], true)"
>
Expand Down Expand Up @@ -66,7 +67,8 @@ export default defineComponent({
'circle',
'tabindex',
'customClass',
'ghost'
'ghost',
'customStyle'
],
components: { IconLoading: iconLoadingShadow() },
setup(props, context) {
Expand Down
Loading