Skip to content

Add frameless option to image component#2002

Open
anandamaryon1 wants to merge 3 commits into
support/10.xfrom
frameless-image
Open

Add frameless option to image component#2002
anandamaryon1 wants to merge 3 commits into
support/10.xfrom
frameless-image

Conversation

@anandamaryon1

Copy link
Copy Markdown
Contributor

Description

Our image component adds a visible border-bottom and a background colour by default. This option removes those so that images can be added more flexibly and to dark backgrounds, for example, in our hero component.

Current:
Screenshot 2026-07-13 at 17 12 49

Frameless:
Screenshot 2026-07-13 at 17 13 25

Checklist

@anandamaryon1 anandamaryon1 added this to the 10.6.0 milestone Jul 13, 2026
@colinrotherham
colinrotherham temporarily deployed to nhsuk-frontend-pr-2002 July 13, 2026 16:14 Inactive
Comment thread packages/nhsuk-frontend/src/nhsuk/components/images/macro-options.mjs Outdated
@anandamaryon1
anandamaryon1 temporarily deployed to nhsuk-frontend-pr-2002 July 16, 2026 08:19 Inactive
released: '10.6.0'
},
background: {
type: 'boolean',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since the default is the card background colour, this should be a string

But like other components, overriding this with background: false would remove it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah ok, will this mean we can add other colours in future, eg. page-background or NHS blue?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah if necessary, but also because we do this in the code component already 😊

type: 'boolean',
required: false,
description:
'If set to `false`, sets the background colour to transparent for the image container.',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe something like this?

Suggested change
'If set to `false`, sets the background colour to transparent for the image container.',
'Background colour for the image component – `"card"` or `false`. Defaults to `"card"`. To remove the background colour, set `background` to `false`.',


{%- if params.frameless %}
{% set classNames = classNames ~ " nhsuk-image--frameless" %}
{%- if params.border === false %}

@colinrotherham colinrotherham Jul 16, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We support both classes and border: true

So we'll need to check for both here, i.e. to skip the class if already set

Suggested change
{%- if params.border === false %}
{%- if params.border === false and (not params.classes or not "nhsuk-image--no-border" in params.classes) %}

{% set classNames = classNames ~ " nhsuk-image--no-border" %}
{% endif -%}

{%- if params.background === false %}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
{%- if params.background === false %}
{%- if params.background === false and (not params.classes or not "nhsuk-image--no-background" in params.classes) %}

@anandamaryon1

Copy link
Copy Markdown
Contributor Author

Thanks for the review @colinrotherham I've had a go at amending based on your comments.

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.

2 participants