Skip to content

fix(css): link: Style background, border, and padding regardless of default browser styles #4231#4302

Merged
Barsnes merged 1 commit intodigdir:mainfrom
AnInternetTroll:user/luca/button-as-link
Dec 10, 2025
Merged

fix(css): link: Style background, border, and padding regardless of default browser styles #4231#4302
Barsnes merged 1 commit intodigdir:mainfrom
AnInternetTroll:user/luca/button-as-link

Conversation

@AnInternetTroll
Copy link
Contributor

Summary

Fixes #4231 by setting background, border, and padding to a "default" value, which matches the <a> tag and more importantly overwrites the default <button> styles

Also added a story for it. Maybe not needed idk

Checks

@changeset-bot
Copy link

changeset-bot bot commented Dec 9, 2025

🦋 Changeset detected

Latest commit: 9b1fc02

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@digdir/designsystemet-css Patch
@digdir/designsystemet-react Patch
@digdir/designsystemet Patch
@digdir/designsystemet-theme Patch
@digdir/designsystemet-types Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR


export const AsButton: Story = {
args: {
children: <button>Gå til designsystemet</button>,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
children: <button>Gå til designsystemet</button>,
children: <button type='button'>Gå til designsystemet</button>,

/* Revert <button> styling */
background: none;
border: none;
padding: 0;
Copy link
Member

@Barsnes Barsnes Dec 10, 2025

Choose a reason for hiding this comment

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

<button> needs font: inherit, and I did also not get a pointer cursors when testing 🤔

Suggested change
padding: 0;
&:is(button) {
background: none;
border: none;
cursor: pointer;
font: inherit;
margin: 0;
padding: 0;
text-align: inherit;
}

@Barsnes
Copy link
Member

Barsnes commented Dec 10, 2025

And thanks for the PR! Looks great, just a few minor tweaks

@AnInternetTroll AnInternetTroll force-pushed the user/luca/button-as-link branch from b3d65e3 to 9b1fc02 Compare December 10, 2025 08:50
@AnInternetTroll
Copy link
Contributor Author

Thanks for the review! Really appreciate it

Copy link
Member

@Barsnes Barsnes left a comment

Choose a reason for hiding this comment

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

Great work 😄

@Barsnes Barsnes merged commit 6045e53 into digdir:main Dec 10, 2025
6 of 8 checks passed
@github-actions github-actions bot mentioned this pull request Dec 10, 2025
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.

Let ds-link be able to style <button>

2 participants