- iOS:
viewPickerin govuk-once/govuk-mobile-ios-app/Production/govuk_ios/Views/DVLA/DVLAAccountSummaryView.swift at 8f1fe5da - iOS:
topicPickerin govuk-once/govuk-mobile-ios-app/Production/govuk_ios/Views/Home/Topics/TopicsWidgetView.swift at 8f1fe5da - Figma: none linked yet
- Apple Human Interface Guidelines: Segmented controls
Segmented control
Switches between two or three views of the same thing, side by side, such as a driving account's Vehicles and Licence, or Your topics and All topics.
Native component
Known differences from the app
- The selected segment moves straight to the one pressed: iOS slides it across.
- Its labels don’t grow with the root’s text size, as iOS’s don’t, but iOS does make the control taller at the largest accessibility sizes.
Examples
Two segments
HTML
<govuk-app-segmented-control label="Driving">
<govuk-app-segmented-control-item name="vehicles" selected>Vehicles</govuk-app-segmented-control-item>
<govuk-app-segmented-control-item name="licence">Licence</govuk-app-segmented-control-item>
</govuk-app-segmented-control>
Three segments
HTML
<govuk-app-segmented-control label="Show">
<govuk-app-segmented-control-item name="day">Day</govuk-app-segmented-control-item>
<govuk-app-segmented-control-item name="week">Week</govuk-app-segmented-control-item>
<govuk-app-segmented-control-item name="month" selected>Month</govuk-app-segmented-control-item>
</govuk-app-segmented-control>
Segments that link to other pages
HTML
<govuk-app-segmented-control label="Topics">
<govuk-app-segmented-control-item href="#your-topics" selected>Your topics</govuk-app-segmented-control-item>
<govuk-app-segmented-control-item href="#all-topics">All topics</govuk-app-segmented-control-item>
</govuk-app-segmented-control>
Inputs
| Attribute | Type | Default | Description |
|---|---|---|---|
label |
string |
Its name for screen readers, such as Driving, as the app's picker's label. |
Content
Two or three <govuk-app-segmented-control-item> elements, left to right. Mark the one that's showing selected. Give each an href, to make it a link to another page, or name and value, to tell it apart as a button. Its label is what's written between its tags.
Outputs
click: From the link or button a segment draws, when it's pressed. A segment with an href goes to its page. A segment without one is a button, and pressing it selects it, as iOS's does; use event.target.closest('button').name to tell which was pressed and show its view.
Rules
- Use it to switch between views of the same thing, not to go somewhere new: for that, use a navigation row or the tab bar.
- Use two or three segments, each one short word or two, so they fit side by side.
- Select exactly one segment: the one whose view is showing.
- Put it at the top of what it switches, 16pt in from the screen's edges, as the app does.
When not to use it
| When | Use instead |
|---|---|
| To go to another screen | govuk-app-grouped-list-row type="navigation" |
| To move between the app's sections, Home, Chat and Settings | govuk-app-tab-bar |
| To switch a setting on or off | govuk-app-toggle |
| For more than three views | A grouped list of navigation rows, one for each, each going to its own screen. |
The iOS, Android and Figma sources it was built from
Screenshots of the app's own component, to compare the examples with
iOS