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

Add documentation for new variants #1674

Closed
Changes from all commits
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
64 changes: 64 additions & 0 deletions src/pages/docs/hover-focus-and-other-states.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,30 @@ Tailwind also includes a `motion-safe` modifier that only adds styles when the u
</button>
```

### Prefers reduced transparency
Copy link
Author

Choose a reason for hiding this comment

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

Due to the fact this only works in Chrome i've not mentioned the transparency-safe modifier as that won't work across browsers.

I also think it's worth adding a note to say this is "experimental"?

Copy link

Choose a reason for hiding this comment

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

I suggest you add the matching documentation to the PR adding the feature instead of having a documentation PR for all four.


The `prefers-reduced-transparency` media query tells you if the user has requested that you minimize transparency.

Use the `transparency-reduce` modifier to conditionally add styles when the user has requested reduced transparency:

```html {{ example: { hint: 'Try emulating &#96;prefers-reduced-transparency: reduce&#96; in your developer tools to increase the opacity' } }}
<div class="flex items-center justify-center">
<div class="flex flex-col items-center shrink-0">
<div class="relative">
<div class="absolute inset-6 h-20 w-20 bg-white/30 transparency-reduce:bg-white/80"></div>
<img class="w-32 h-32 object-cover rounded-lg shadow-xl" src="https://images.unsplash.com/photo-1554629947-334ff61d85dc?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=320&h=320&q=80" />
<div class="absolute inset-0 ring-1 ring-inset ring-black/10 rounded-lg"></div>
</div>
</div>
</div>
```

```html
<div class="bg-white/30 **transparency-reduce:bg-white/80** ...">
<!-- ... -->
</div>
```

### Prefers contrast

The `prefers-contrast` media query tells you if the user has requested more or less contrast.
Expand Down Expand Up @@ -1020,6 +1044,46 @@ Use the `contrast-more` modifier to conditionally add styles when the user has r

Tailwind also includes a `contrast-less` modifier you can use to conditionally add styles when the user has requested less contrast.

Tailwind also includes a `contrast-custom` modifier you can use to conditionally add styles when the user has requested a custom contrast level.
This can be useful alongside `forced-colors`.

### Forced colors

The `forced-colors` media query tells you if the user has forced a specific color palette.

Use the `forced-colors` modifier to conditionally add styles when this media query is active.

### Inverted colors

The `inverted-colors` media query tells you if the user has inverted the colors of their display.

Use the `inverted-colors` modifier to conditionally add styles when this media query is active:

```html
<div class="shadow-xl inverted-colors:shadow-none">
<!-- ... -->
</div>
```

### Scripting

The `scripting` media query tells you if the user has disabled JavaScript or not.

Use the `noscript` modifier to conditionally add styles when JavaScript is disabled, or `scripting` when it's enabled:

```html
<div>
<div class="noscript:hidden">
<!-- Some interactive JavaScript experience -->
</div>
<div class="scripting:hidden">
<p>
This experience requires JavaScript to function. Please enable JavaScript.
</p>
</div>
</div>
```

### Viewport orientation

Use the `portrait` and `landscape` modifiers to conditionally add styles when the viewport is in a specific orientation:
Expand Down