Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/tasty-mangos-sin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cube-dev/ui-kit": patch
---

Add `size` prop for Label with `small` and `medium` (default) values.
5 changes: 5 additions & 0 deletions src/components/form/FieldWrapper/FieldWrapper.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ const Template: StoryFn<CubeFieldWrapperProps> = (args) => (

export const Default = Template.bind({});

export const Small = Template.bind({});
Small.args = {
labelProps: { size: 'small' },
};

export const WithTooltip = Template.bind({});
WithTooltip.args = {
tooltip: 'Long description',
Expand Down
8 changes: 7 additions & 1 deletion src/components/form/Label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ export const INLINE_LABEL_STYLES: Styles = {

export const LABEL_STYLES: Styles = {
display: 'block',
preset: 't3m',
preset: {
'': 't3m',
'[data-size="small"]': 't4',
},
color: {
'': '#dark',
invalid: '#danger-text',
Expand All @@ -86,6 +89,7 @@ export interface CubeLabelProps extends BaseProps, ContainerStyleProps {
htmlFor?: string;
for?: string;
validationState?: ValidationState;
size?: 'medium' | 'small';
}

function Label(props: CubeLabelProps, ref) {
Expand All @@ -102,6 +106,7 @@ function Label(props: CubeLabelProps, ref) {
htmlFor,
isDisabled,
validationState,
size = 'medium',
for: labelFor,
...otherProps
} = props;
Expand Down Expand Up @@ -132,6 +137,7 @@ function Label(props: CubeLabelProps, ref) {
ref={domRef}
styles={styles}
htmlFor={labelFor || htmlFor}
data-size={size}
mods={{
side: labelPosition === 'side',
disabled: isDisabled,
Expand Down
Loading