useSortedProperties (CSS)
Language CSS
Summary
Section titled “Summary”- Rule available since:
v2.0.0 - Diagnostic Category:
assist/source/useSortedProperties
How to enable in your editor
Section titled “How to enable in your editor”{ "editor.codeActionsOnSave": { "source.action.useSortedProperties.biome": "explicit", "source.fixAll.biome": "explicit" }}{ "code_actions_on_format": { "source.action.useSortedProperties.biome": true, "source.fixAll.biome": true }}
Use the source action code
source.action.useSortedProperties.biome How to configure
Section titled “How to configure”{ "assist": { "actions": { "source": { "useSortedProperties": "on" } } }}Description
Section titled “Description”Sort CSS properties and nested rules into a consistent order.
The action uses a predefined order that groups related properties by purpose.
Custom properties come first, and nested rules or at-rules such as @media come after
declarations.
The main groups are:
- Custom properties.
- Layout properties, including
display,visibility, flexbox, and grid. - Margin and padding properties.
- Typography properties, including
fontandcolor. - Interaction properties, including
pointer-events. - Background and border properties.
- Transition and animation properties.
- Nested rules, media queries, and other at-rules.
Biome skips blocks containing unknown properties because their correct position is not known. If sorting could change the result of a shorthand and longhand combination, Biome reports the block but does not offer the action.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”p { transition: opacity 1s ease; border: 1px solid black; pointer-events: none; color: black; margin: 8px; display: block; --custom: 100;}code-block.css ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ Source action diff:
1 1 │ p {
2 │ - ··transition:·opacity·1s·ease;
3 │ - ··border:·1px·solid·black;
4 │ - ··pointer-events:·none;
2 │ + ··--custom:·100;
3 │ + ··display:·block;
4 │ + ··margin:·8px;
5 5 │ color: black;
6 │ - ··margin:·8px;
7 │ - ··display:·block;
8 │ - ··--custom:·100;
6 │ + ··pointer-events:·none;
7 │ + ··border:·1px·solid·black;
8 │ + ··transition:·opacity·1s·ease;
9 9 │ }
10 10 │
p { span { color: blue; } color: red;}code-block.css ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ Source action diff:
1 1 │ p {
2 │ - ··span·{·color:·blue;·}
3 │ - ··color:·red;
2 │ + ··color:·red;
3 │ + ··span·{·color:·blue;·}
4 4 │ }
5 5 │
p { --custom: 100; display: block; margin: 8px; color: black; pointer-events: none; border: 1px solid black; transition: opacity 1s ease;}p { color: red; span { color: blue; }}Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.