Skip to content

Style default buttons as links #497

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: 5.x-RC
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@

@use '00-config' as *;

a {
// Default buttons without classes are styled as links.
a,
button,
[type='button'],
[type='reset'],
[type='submit'] {
@include focus();
background-color: transparent;
color: gesso-color(text, link);
text-decoration: underline;
-webkit-text-decoration-skip: objects;
transition-duration: gesso-duration(short);
transition-property: background-color, border-color, color, outline-color;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<p><a href="{{ url }}">This is a text link</a></p>

<p>This <button>default button</button> doesn’t have any classes and should look like a link.</p>

<p>These inputs should look like links too: <input type="button" value="button">, <input type="submit" value="submit">, and <input type="reset" value="reset">.</p>

<p><strong>Strong is used to indicate strong importance</strong></p>

<p><em>This text has added emphasis</em></p>
Expand Down
12 changes: 6 additions & 6 deletions source/01-global/html-elements/25-forms/_forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

// Don’t style button elements, since they’re often styled as links for
// accessible widgets. Use the .button class in components/button.
button {
overflow: visible;
}

// button {}

// datalist {}

Expand All @@ -18,13 +17,14 @@ fieldset {

// form {}

// Don't style button, submit, or reset elements, since they're often styled as
// links for accessible widgets. Use the .button class in
// partials/components/button.
input {
line-height: normal;
}

// Don’t style inputs of type button, submit, or reset since they're often
// styled as links for accessible widgets. Use the .button class in
// partials/components/button.

// input[type='button'] {}
// input[type='checkbox'] {}
// input[type='color'] {}
Expand Down
13 changes: 12 additions & 1 deletion source/01-global/normalize/_normalize.scss
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,22 @@ select {
text-transform: none;
}

// Styled to look like a link.
button,
[type='button'],
[type='reset'],
[type='submit'] {
-webkit-appearance: button;
-webkit-appearance: none;
border: 0;
border-radius: 0;
box-shadow: none;
cursor: pointer;
font-weight: gesso-font-weight(regular);
margin: 0;
overflow: visible;
padding: 0;
text-align: left;
text-decoration: underline;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I added a text-button mixin that you can use here to make buttons look like regular text links: https://github.com/forumone/gesso_next/blob/main/source/00-config/mixins/_button.scss#L101-L119

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks! I switched to using that mixin to account for a bunch of the default button styles.

}

button::-moz-focus-inner,
Expand Down