Skip to content

Commit 76cc770

Browse files
authored
Merge pull request #1628 from sheinsight/feat/checkbox-radio-vertical-align
feat: Checkbox、Radio 新增 verticalAlign 属性,支持指示器顶对齐
2 parents 6e84477 + 35fa24e commit 76cc770

File tree

20 files changed

+115
-47
lines changed

20 files changed

+115
-47
lines changed

docs/markdown/shineout/changelog-common.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
## 3.9.9-beta.10
2-
2026-02-03
3-
### 💅 Style
4-
- 优化 `Checkbox``Radio` 的文本对齐方式为顶对齐 ([#1612](https://github.com/sheinsight/shineout-next/pull/1612))
5-
61
## 3.9.9-beta.6
72
2026-01-30
83
### 💅 Style

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "sheinx",
33
"private": true,
4-
"version": "3.9.9-beta.14",
4+
"version": "3.9.9-beta.15",
55
"description": "A react library developed with sheinx",
66
"module": "dist/index.js",
77
"types": "dist/index.d.ts",

packages/base/src/checkbox/checkbox.type.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export interface CheckboxClasses {
2525
darkIndicatorWrapper: string;
2626
desc: string;
2727
input: string;
28+
wrapperTop: string;
2829
group: string;
2930
groupBlock: string;
3031
}
@@ -59,6 +60,14 @@ export interface SimpleCheckboxProps
5960
* @private 内部属性
6061
*/
6162
needStopPropagation?: boolean;
63+
64+
/**
65+
* @en Vertical align of checkbox indicator
66+
* @cn 勾选框指示器的垂直对齐方式
67+
* @default "middle"
68+
* @version 3.9.9
69+
*/
70+
verticalAlign?: 'middle' | 'top';
6271
}
6372

6473
export interface CheckboxProps<T>

packages/base/src/checkbox/simple-checkbox.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { FormFieldContext } from '../form/form-field-context';
77
const { getDataAttribute } = util;
88

99
const Checkbox = (props: SimpleCheckboxProps) => {
10-
const { jssStyle, className, style, children, renderFooter, size, theme, ...rest } = props;
10+
const { jssStyle, className, style, children, renderFooter, size, theme, verticalAlign, ...rest } = props;
1111
const mouseEvents = util.extractProps(rest, 'mouse');
1212
const { fieldId } = useContext(FormFieldContext);
1313
const checkboxStyle = jssStyle?.checkbox?.();
@@ -26,6 +26,7 @@ const Checkbox = (props: SimpleCheckboxProps) => {
2626
!!disabled && checkboxStyle?.wrapperDisabled,
2727
!!checked && checkboxStyle?.wrapperChecked,
2828
props.checked === 'indeterminate' && checkboxStyle?.wrapperIndeterminate,
29+
verticalAlign === 'top' && checkboxStyle?.wrapperTop,
2930
);
3031

3132
const indicatorClass = classNames(

packages/base/src/radio/radio.type.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export interface RadioClasses {
2424
indicatorWrapper: string;
2525
indicator: string;
2626
desc: string;
27+
wrapperTop: string;
2728
// 组
2829
group: string;
2930
groupBlock: string;
@@ -61,6 +62,14 @@ export interface SimpleRadioProps
6162
* @private 内部属性用于控制热区样式
6263
*/
6364
theme?: 'dark';
65+
66+
/**
67+
* @en Vertical align of radio indicator
68+
* @cn 单选框指示器的垂直对齐方式
69+
* @default "middle"
70+
* @version 3.9.9
71+
*/
72+
verticalAlign?: 'middle' | 'top';
6473
}
6574

6675
export interface RadioProps<T> extends Omit<SimpleRadioProps, 'onChange' | 'checked' | 'theme' | 'disabled'> {

packages/base/src/radio/simple-radio.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { SimpleRadioProps } from './radio.type';
55
import { FormFieldContext } from '../form/form-field-context';
66

77
const Radio = (props: SimpleRadioProps) => {
8-
const { jssStyle, className, style, children, renderWrapper, size, theme, ...rest } = props;
8+
const { jssStyle, className, style, children, renderWrapper, size, theme, verticalAlign, ...rest } = props;
99
const mouseEvents = util.extractProps(rest, 'mouse');
1010
const { fieldId } = useContext(FormFieldContext);
1111
const radioClasses = jssStyle?.radio?.();
@@ -20,6 +20,7 @@ const Radio = (props: SimpleRadioProps) => {
2020
!!checked && radioClasses?.wrapperChecked,
2121
size === 'small' && radioClasses?.wrapperSmall,
2222
size === 'large' && radioClasses?.wrapperLarge,
23+
verticalAlign === 'top' && radioClasses?.wrapperTop,
2324
]);
2425

2526
const indicatorClass = classNames(

packages/shineout-style/src/checkbox/checkbox.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const checkboxStyle: JsStyles<keyof CheckboxClasses> = {
99
wrapper: {
1010
display: 'inline-flex',
1111
position: 'relative',
12-
alignItems: 'var(--soui-checkbox-align-items, flex-start)',
12+
alignItems: 'center',
1313
cursor: 'pointer',
1414
boxSizing: 'border-box',
1515
marginRight: token.checkboxGap,
@@ -20,6 +20,12 @@ const checkboxStyle: JsStyles<keyof CheckboxClasses> = {
2020
},
2121
wrapperSmall: {},
2222
wrapperLarge: {},
23+
wrapperTop: {
24+
alignItems: 'flex-start',
25+
'& $indicatorWrapper': {
26+
marginTop: token.checkboxIndicatorMarginTop,
27+
},
28+
},
2329
input: {},
2430
wrapperChecked: {},
2531
wrapperIndeterminate: {},
@@ -32,7 +38,7 @@ const checkboxStyle: JsStyles<keyof CheckboxClasses> = {
3238
boxSizing: 'border-box',
3339
width: token.checkboxIconSize,
3440
height: token.checkboxIconSize,
35-
marginTop: 'var(--soui-checkbox-indicator-margin-top, 4px)',
41+
// marginTop: token.checkboxIndicatorMarginTop,
3642
flexShrink: 0,
3743
'$wrapperSmall &': {
3844
width: token.checkboxSmallIconSize,

packages/shineout-style/src/list/list.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ const listStyle: JsStyles<ListClassType> = {
1212
maxHeight: '100%',
1313
display: 'flex',
1414
flexDirection: 'column',
15-
'--soui-checkbox-indicator-margin-top': 0,
16-
'--soui-checkbox-align-items': 'center',
1715
},
1816
wrapperBordered: {
1917
border: `${token.listBorderWidth} solid ${token.listBorderColor}`,

packages/shineout-style/src/radio/radio.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const radioStyle: JsStyles<keyof RadioClasses> = {
99
wrapper: {
1010
display: 'inline-flex',
1111
position: 'relative',
12-
alignItems: 'flex-start',
12+
alignItems: 'center',
1313
cursor: 'pointer',
1414
boxSizing: 'border-box',
1515
marginRight: token.radioGap,
@@ -36,6 +36,12 @@ const radioStyle: JsStyles<keyof RadioClasses> = {
3636
padding: `${token.radioLargeButtonPaddingY} ${token.radioLargeButtonPaddingX}`,
3737
}
3838
},
39+
wrapperTop: {
40+
alignItems: 'flex-start',
41+
'& $indicatorWrapper': {
42+
marginTop: token.radioIndicatorMarginTop,
43+
},
44+
},
3945
wrapperChecked: {},
4046
wrapperDisabled: {
4147
cursor: 'not-allowed',
@@ -47,7 +53,6 @@ const radioStyle: JsStyles<keyof RadioClasses> = {
4753
width: token.radioIconWidth,
4854
minWidth: token.radioIconWidth,
4955
height: token.radioIconWidth,
50-
marginTop: 4,
5156
'$wrapperSmall &': {
5257
width: token.radioSmallIconWidth,
5358
minWidth: token.radioSmallIconWidth,

packages/shineout-style/src/tree/tree.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,6 @@ const treeStyle: JsStyles<TreeClassType> = {
287287
checkbox: {
288288
'&[class*="checkbox-wrapper"]': {
289289
marginRight: Token.treeCheckboxMarginX,
290-
'--soui-checkbox-indicator-margin-top': '0px',
291290
},
292291
},
293292
text: {

0 commit comments

Comments
 (0)