Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(togglebutton component): fix togglebutton with long label in mobile #1199

Closed
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
7 changes: 7 additions & 0 deletions src/components/ToggleSwitch/ToggleSwitch.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,10 @@ LargeToggleSwitch.args = {
sizing: 'lg',
label: 'large toggle switch',
};

export const ToggleSwitchWithLongLabel = Template.bind({});
ToggleSwitchWithLongLabel.storyName = 'Toggle switch with long label';
ToggleSwitchWithLongLabel.args = {
sizing: 'lg',
label: 'Toggle switch with long label to check for problems if there are any',
};
8 changes: 4 additions & 4 deletions src/components/ToggleSwitch/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const toggleSwitchTheme: FlowbiteToggleSwitchTheme = {
label: 'ml-3 text-sm font-medium text-gray-900 dark:text-gray-300',
},
toggle: {
base: 'toggle-bg rounded-full border group-focus:ring-4 group-focus:ring-cyan-500/25',
base: 'relative shrink-0 toggle-bg rounded-full border group-focus:ring-4 group-focus:ring-cyan-500/25',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding just a relative is enough

Copy link
Contributor Author

@nikitadubyk nikitadubyk Apr 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without flex-shrink it will be broken (even with min-width values)
image

checked: {
on: 'after:translate-x-full after:border-white',
off: 'border-gray-200 bg-gray-200 dark:border-gray-600 dark:bg-gray-700',
Expand All @@ -35,9 +35,9 @@ export const toggleSwitchTheme: FlowbiteToggleSwitchTheme = {
},
},
sizes: {
sm: 'w-9 h-5 after:absolute after:top-[2px] after:left-[2px] after:h-4 after:w-4',
md: 'w-11 h-6 after:absolute after:top-[2px] after:left-[2px] after:h-5 after:w-5',
lg: 'w-14 h-7 after:absolute after:top-0.5 after:left-[4px] after:h-6 after:w-6',
sm: 'min-w-9 w-9 h-5 after:absolute after:top-[2px] after:left-[2px] after:h-4 after:w-4',
md: 'min-w-1 w-11 h-6 after:absolute after:top-[2px] after:left-[2px] after:h-5 after:w-5',
lg: 'min-w-14 w-14 h-7 after:absolute after:top-0.5 after:left-[4px] after:h-6 after:w-6',
},
},
};