Skip to content
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

How to reverse .visually-hidden on :focus #15

Closed
stowball opened this issue Sep 10, 2019 · 6 comments
Closed

How to reverse .visually-hidden on :focus #15

stowball opened this issue Sep 10, 2019 · 6 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed question Further information is requested

Comments

@stowball
Copy link
Owner

We have a .visually-hidden class to accessibly hide content from sighted users, but to keep it available to screen reader users which works well, and can be conditionally used with media queries etc as necessary.

However, in the case of "Skip To Content" links, we want to easily provide a way to undo the group of properties. See TurretCSS for prior art: https://github.com/turretcss/turretcss/blob/master/turret/accessibility/screen-reader.css#L23

My only worry is that depending on the design, undoing Skip To Content could need to be achieved in very different ways: slide in from off-screen, just appear at the top and push all content down etc, so there's no 1 way of supporting this.

@stowball stowball added enhancement New feature or request help wanted Extra attention is needed question Further information is requested labels Sep 10, 2019
@stowball stowball self-assigned this Sep 10, 2019
@joeldbirch
Copy link
Contributor

joeldbirch commented Oct 5, 2019

"Skip to content" links seem like an edge case that isn't suited to a .visually-hidden helper class. I think a class that reverses .visually-hidden is worthwhile even without it working for such cases.

@stowball
Copy link
Owner Author

stowball commented Oct 5, 2019

@joeldbirch What would you use the reversal class for? And is it something that would work constrained to media queries? For example:

@mq-upto-768--visually-hidden
@mq-1024--visually-hidden

The above is already possible and how I've "quarantined" the visually hiding to certain design states only.

@joeldbirch
Copy link
Contributor

joeldbirch commented Oct 5, 2019 via email

@stowball
Copy link
Owner Author

stowball commented Oct 5, 2019

Closing for now. Like you say, Skip to content is an edge case and is highky dependent on the design.

If we think of any real use case for reversing visually-hidden, we can re-open.

@stowball stowball closed this as completed Oct 5, 2019
@stowball
Copy link
Owner Author

It seems Tailwind added a not-sr-only class tailwindlabs/tailwindcss#964

@stowball
Copy link
Owner Author

I've now enabled another solution with the following commit: d622bbb

We can use pseudos:

$hu-visually-hidden-modules: (
  core: $hu-visually-hidden-modules,
  pseudos: (":not(:focus):not(:active)"),
);

to generate:

.\&\:not\(\:focus\)\:not\(\:active\)--visually-hidden:not(:focus):not(:active) {
  border: none ;
  clip: rect(0 0 0 0) ;
  height: 1px ;
  margin: -1px ;
  overflow: hidden ;
  padding: 0 ;
  position: absolute ;
  white-space: nowrap ;
  width: 1px ;
}

which could be used like so:

<a
  class="&:not(:focus):not(:active)--visually-hidden"
  href="#main"
>
  Skip to content
</a>

This allows it to only be visually-hidden when not focused or active 💪

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants