Skip to content

Use ToggleButtonGroup for HtmlPreview width selection #353

Backlog

Description

@georgerichmond

Summary

Replace the width radio group in HtmlPreview with the reusable ToggleButtonGroup from #352 so tools can use the shared preview with the segmented selector shown in the newsletter layout design.

This is the second of two PRs and depends on #352. Stack this PR on the ToggleButtonGroup PR so reviewers can review the standalone control first and the preview integration separately. Context: guardian/newsletters-nx#1056 and guardian/newsletters-nx#1102.

Design reference

Newsletter Layout tab.

Use the connected segmented width selector, rather than circular radios. Keep the selector aligned to the right of the preview header.

Acceptance criteria

  • Use the shared ToggleButtonGroup from Add ToggleButtonGroup for segmented selection #352; do not duplicate its styling or selection behaviour inside HtmlPreview.
  • Keep exactly one width selected and prevent deselecting the current width without selecting another.
  • Selecting a segment changes the actual iframe width without re-fetching HTML or remounting the preview.
  • Preserve the existing widthOptions and defaultWidth API, including the default 320, 375, 425 and 650px options and support for custom widths.
  • Preserve the ability to omit the width selector with an empty widthOptions array.
  • Provide an accessible label for the width group and use the shared control for keyboard, focus, selected and disabled behaviour.
  • Keep the existing HTML fetching, loading, error/retry and sandbox behaviour unchanged; this PR is the width-control integration, not a preview lifecycle rewrite.
  • Update the preview Storybook examples, usage documentation and sandbox example.
  • Add focused integration coverage showing that selection updates the iframe width and the existing width configuration continues to work.

Activity

  1. added
    enhancement
    on Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions