Skip to content

fix(toggle): keep the track width when the toggle is full-width - #230

Open
shkomg wants to merge 1 commit into
untitleduico:mainfrom
userstoriesbot-showcase:fix/toggle-full-width-track
Open

shkomg wants to merge 1 commit into
untitleduico:mainfrom
userstoriesbot-showcase:fix/toggle-full-width-track

Conversation

@shkomg

@shkomg shkomg commented Nov 3, 2026

Copy link
Copy Markdown

Description

ToggleBase had no shrink-0, so in a full-width Toggle (className="w-full") with a long hint the flex row squeezed the track: the sm track went from 36px to about 25px and the md track from 44px to about 26px. This adds shrink-0 to the track, like the Checkbox and Radio bases already have, and a "Toggles full width" story with long and short hints side by side.

Related issues

Closes #226

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Style/UI change (visual improvements, no functional changes)
  • Accessibility improvement
  • Refactoring (code changes that neither fix a bug nor add a feature)
  • Performance improvement
  • Chore (dependency updates, tooling changes, etc.)

Testing

Measured the track widths in the new story in headless Chromium: before, 24.7px and 26.3px for the long-hint toggles against 36px and 44px for the short-hint ones; after, all four tracks are 36px (sm) and 44px (md). The existing toggle stories are unchanged, since w-max never squeezed the track. bun run test (tsc, eslint, prettier) passes.

Testing checklist

  • Functionality: Component works as expected
  • TypeScript: No TypeScript errors
  • Storybook: Stories render correctly
  • Accessibility:
    • Keyboard navigation works
    • Screen reader compatible
    • Focus management is correct
    • Color contrast meets WCAG AA standards
  • Responsive: Works on mobile, tablet, and desktop
  • Browser testing: Tested in multiple browsers
  • Performance: No performance regressions

Manual testing steps

  1. Run bun run storybook and open Base components / Toggles / Toggles full width.
  2. Compare the track of each long-hint toggle with the short-hint toggle below it.
  3. Both have the same width (36px for sm, 44px for md).

Screenshots/Videos

Before

before

before, zoomed

After

after

after, zoomed

The video shows the new story in this branch, with the long-hint and short-hint tracks at the same width.

untitledui-react.mp4

Code quality checklist

  • Code style: Follows project conventions
  • ESLint: No linting errors
  • Prettier: Code is properly formatted
  • TypeScript: Full type coverage
  • Imports: Uses correct import paths (@/components/...)
  • Performance: No unnecessary re-renders or heavy computations
  • Error handling: Appropriate error boundaries and validation

📚 Documentation

  • Component props are documented with TypeScript interfaces
  • Storybook stories cover all variants
  • Usage examples are provided

Breaking changes

None.

Additional context

#218 also edits the first class string of ToggleBase, so whichever lands second needs a one-word rebase.

Fix written with Claude Code; video is an automated browser run of this branch recorded by User Stories Bot.

With className="w-full" and a long hint, the flex row squeezed the
ToggleBase track (sm 36px became about 25px). Add shrink-0 to the track,
the same way Checkbox and Radio bases already do, and add a "Toggles full
width" story that shows long and short hints side by side.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Toggle track shrinks when the component is full-width

1 participant