Skip to content

Add details about hidden attribute preflight rules #2321

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 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions src/docs/preflight.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,17 @@ This prevents them from overflowing their containers and makes them responsive b
<img class="max-w-none" src="..." alt="..." />
```

#### Elements with a `hidden` attribute stay hidden

```css
/* [!code filename:CSS] */
[hidden]:where(:not([hidden='until-found'])) {
display: none !important;
}
```

This enfoces that elements with a `hidden` attribute stay invisible unless using `hidden="until-found"`. The should *remove* the `hidden` attribute if you want an element to be visible to the user.

## Extending Preflight

If you'd like to add your own base styles on top of Preflight, add them to the `base` CSS layer in your CSS using `@layer base`:
Expand Down
4 changes: 4 additions & 0 deletions src/docs/upgrade-guide.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,10 @@ If you still want dialogs to be centered by default, add this CSS to your projec
}
```

#### Hidden attribute takes priority

Display classes like `block` or `flex` no longer take priority over the `hidden` attribute on an element. You should *remove* the `hidden` attribute if you want an element to be visible to the user. Note that this does not apply to `hidden="until-found"`.

### Using a prefix

Prefixes now look like variants and are always at the beginning of the class name:
Expand Down