增加附加标签组件中水平排列的功能。

This commit is contained in:
徐涛 2025-01-15 13:27:08 +08:00
parent 8a55c73c83
commit a56d473148
2 changed files with 11 additions and 2 deletions

View File

@ -5,12 +5,19 @@
flex-direction: column;
align-items: stretch;
gap: var(--spacing-xs);
&.inline {
flex-direction: row;
gap: var(--spacing-s);
}
label {
width: 100%;
display: flex;
flex-direction: row;
align-items: baseline;
font-size: var(--font-size-xs);
.inline & {
width: fit-content;
}
}
}
}

View File

@ -1,13 +1,15 @@
import cx from 'clsx';
import styles from './Labeled.module.css';
type LabeledProps = {
label: string;
inline?: boolean;
children: React.ReactNode;
};
export function Labeled({ label, children }: LabeledProps) {
export function Labeled({ label, inline = false, children }: LabeledProps) {
return (
<div className={styles.labeled}>
<div className={cx(styles.labeled, inline && styles.inline)}>
<label>{label}</label>
{children}
</div>