Skip to content

Commit 3650229

Browse files
authored
feat(tabs): add centered tab bar style (vueComponent#3501)
Co-authored-by: 李艺珅 <l>
1 parent 110304b commit 3650229

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

components/tabs/TabBar.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const TabBar = defineComponent({
1212
inheritAttrs: false,
1313
props: {
1414
prefixCls: PropTypes.string,
15+
centered: PropTypes.looseBool.def(false),
1516
tabBarStyle: PropTypes.style,
1617
tabBarExtraContent: PropTypes.VNodeChild,
1718
type: PropTypes.oneOf(tuple('line', 'card', 'editable-card')),
@@ -29,6 +30,7 @@ const TabBar = defineComponent({
2930
},
3031
render() {
3132
const {
33+
centered,
3234
tabBarStyle,
3335
animated = true,
3436
renderTabBar,
@@ -62,6 +64,7 @@ const TabBar = defineComponent({
6264
// Additional className for style usage
6365
const cls = {
6466
[this.$attrs.class as string]: this.$attrs.class,
67+
[`${prefixCls}-centered-bar`]: centered,
6568
[`${prefixCls}-${tabPosition}-bar`]: true,
6669
[`${prefixCls}-${size}-bar`]: !!size,
6770
[`${prefixCls}-card-bar`]: type && type.indexOf('card') >= 0,

components/tabs/style/index.less

+6
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,12 @@
243243
}
244244
}
245245

246+
.@{tab-prefix-cls}-centered-bar {
247+
.@{tab-prefix-cls}-nav-wrap {
248+
text-align: center;
249+
}
250+
}
251+
246252
// Create an empty element to avoid margin collapsing
247253
// https://github.com/ant-design/ant-design/issues/18103
248254
&-content::before {

components/tabs/tabs.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export default defineComponent({
2828
activeKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
2929
defaultActiveKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
3030
hideAdd: PropTypes.looseBool.def(false),
31+
centered: PropTypes.looseBool.def(false),
3132
tabBarStyle: PropTypes.object,
3233
tabBarExtraContent: PropTypes.any,
3334
destroyInactiveTabPane: PropTypes.looseBool.def(false),

0 commit comments

Comments
 (0)