Skip to content

Commit 7634d58

Browse files
committed
fix: toggle title alignment
1 parent c11b0f8 commit 7634d58

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/components/Toggle/component.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ function Toggle ({
3838
return (
3939
<Styled.ToggleWrapper textPosition={textPosition}>
4040
{(label || helperText) && (
41-
<Styled.TextWrapper textPosition={textPosition} htmlFor={id} hasLabel={!!label}>
41+
<Styled.TextWrapper
42+
textPosition={textPosition}
43+
htmlFor={id}
44+
hasLabel={!!label}
45+
hasHelperText={!!helperText}
46+
>
4247
{label && <Styled.Title id={labelId}>{label}</Styled.Title>}
4348
{helperText && <Styled.HelperText id={helperTextId}>{helperText}</Styled.HelperText>}
4449
</Styled.TextWrapper>

src/components/Toggle/styles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export const TextWrapper = styled.label<StyledTextWrapperProps>`
4747
return 1;
4848
}};
4949
cursor: pointer;
50-
${({hasLabel}) => !hasLabel && `justify-content: center;`}
50+
${({hasLabel, hasHelperText}) => (!hasLabel || !hasHelperText) && `justify-content: center;`}
5151
${({ textPosition }) => {
5252
if (textPosition === TEXT_POSITIONS.TOP || textPosition === TEXT_POSITIONS.BOTTOM) {
5353
return css`

src/components/Toggle/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export interface StyledToggleWrapperProps {
1010

1111
export interface StyledTextWrapperProps extends StyledToggleWrapperProps{
1212
hasLabel: boolean;
13+
hasHelperText: boolean;
1314
}
1415

1516
export interface ToggleProps {

0 commit comments

Comments
 (0)