Work in progress

Android Buttons

Buttons are used to help users carry out an action.

Screenshot of 6 buttons: a green 'Primary' button, a white 'Secondary' button with a blue border, a red 'Warning' button, and a 'Tertiary' button with blue text only, followed by a white 'Reverse' button and a 'Outlined reverse' button with a white border on a blue background

How it works

There are 6 styles:

The reverse styles are for use on dark backgrounds, such as the NHS blue.

Follow the NHS design system button guidance for when to use primary, secondary and warning buttons.

Buttons are built on Material 3 buttons. They use the bold labelLarge text style, and are sized to their label by default. Use a Modifier such as fillMaxWidth() to make a button fill the width of its container.

When pressed, buttons scale down slightly and give haptic feedback.

How to use

Use the NHS…Button composables from the NHS App design system. Each takes a text label and an onClick function.

Primary button

Screenshot of a green button with white text labelled 'Continue'

A filled green button with white text.

NHSPrimaryButton(
    text = "Continue",
    onClick = { /* handle tap */ }
)

Secondary button

Screenshot of a button with a blue border and blue text labelled 'Cancel'

A button with a blue label and a 2dp blue outline.

NHSSecondaryButton(
    text = "Cancel",
    onClick = { /* handle tap */ }
)

Warning button

Screenshot of a red button with white text labelled 'Delete account'

Use it sparingly, only for destructive actions.

NHSWarningButton(
    text = "Delete account",
    onClick = { /* handle tap */ }
)

Tertiary button

Screenshot of a text-only button with blue text labelled 'Skip'

A low-emphasis text button with blue text and no outline or background. It has no horizontal padding, so it sits flush with surrounding content, but it keeps a touch target of at least 48dp.

NHSTertiaryButton(
    text = "Skip",
    onClick = { /* handle tap */ }
)

Reverse button

Screenshot of a white button with black text labelled 'Log in' on a blue background

Use this on a dark background, such as the NHS blue:

NHSReverseButton(
    text = "Log in",
    onClick = { /* handle tap */ }
)

Outlined reverse button

Screenshot of a button with a white border and white text labelled 'Register' on a blue background

A button with a white outline and white text, for use on a dark background. Use it for a lower-emphasis action, for example next to a standard reverse button:

NHSOutlinedReverseButton(
    text = "Register",
    onClick = { /* handle tap */ }
)

Full width

Screenshot of a green 'Continue' button stretched to fill the width of the screen

Pass a modifier to make a button fill the available width:

NHSPrimaryButton(
    text = "Continue",
    onClick = { /* handle tap */ },
    modifier = Modifier.fillMaxWidth()
)

With an icon

Screenshot of a button with a blue border, sized to fit an information icon and the label 'App help'

Pass an ImageVector as icon to show an 18dp icon before the label. Icons are decorative, so the label should describe the action.

NHSSecondaryButton(
    text = "App help",
    onClick = { /* handle tap */ },
    icon = Icons.Filled.Info
)

Icon only buttons

Screenshot of 4 icon-only buttons: a blue search icon with no background, a white plus icon on a green circle, a blue pencil icon in a circle with a light blue outline, and a dark close (X) icon on a white circle on a blue background

For actions represented only by an icon, use one of 4 icon button styles. These require a contentDescription so the button has an accessible name.

  • NHSIconButton is a plain icon with no background
  • NHSFilledIconButton is an icon on a filled green circle
  • NHSOutlinedIconButton is an icon in an outlined circle
  • NHSReverseIconButton is an icon on a white circle, for blue backgrounds
NHSIconButton(
    icon = Icons.Filled.Search,
    contentDescription = "Search",
    onClick = { /* handle tap */ }
)

NHSFilledIconButton(
    icon = Icons.Filled.Add,
    contentDescription = "Add",
    onClick = { /* handle tap */ }
)

NHSOutlinedIconButton(
    icon = Icons.Filled.Edit,
    contentDescription = "Edit",
    onClick = { /* handle tap */ }
)

NHSReverseIconButton(
    icon = Icons.Filled.Close,
    contentDescription = "Close",
    onClick = { /* handle tap */ }
)

Grouped buttons

Screenshot of a 'Cancel' button with a blue border next to a green 'Confirm' button, sharing the available width equally

Place buttons side by side in a Row, or stacked in a Column:

Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) {
    NHSSecondaryButton(text = "Cancel", onClick = { }, modifier = Modifier.weight(1f))
    NHSPrimaryButton(text = "Confirm", onClick = { }, modifier = Modifier.weight(1f))
}

Accessibility

Button labels should describe the action and make sense out of context. Wrapping text is supported, so labels are not truncated when the font size is increased.

Icon-only buttons must have a contentDescription for TalkBack.