Skills
AI agent skill for writing modern CSS styles
npx -y skills add SantosAlarcon/css-best-practices --skill skillsAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Skills for CSS3 best practices
SKILL.md
2.5 KB, 546 tokens by cl100k_base, as published. Nobody here has run it
css-best-practices
This skill consists in writing CSS styles using the latest CSS3 features
When to use
Use this skill when writing CSS files if the user defines it for the project
Instructions
- Instead of putting all the styles in one file, it is better to create a "styles" folder, and then create a CSS file for every component/part of the project
- Use CSS variables when defining the design system and later use them in its corresponding selector/classes using var(<variable>).
- Take into consideration good UX/UI practices when defining styles to avoid later issues.
- When defining light and dark mode, use the light-dark() function. For example: light-dark(<light color>,<dark color>).
- When using selectors or children/brother nodes, use native CSS nesting, putting the "&" following the selector inside the parent class/selector.
- Take as a high priority to make the responsive thing: mobile, tablet and desktop. Always use the "@media (width < <width in px>)".
- In the global style file, write a "reset CSS" to bypass the browser default styles to avoid styling problems.
- Also, in the same file, divide every set of styles with layers usign "@layer <layer name>", and inside put the classes corresponding that set.
- When defining background and foreground colors, make sure that the colors have AAA contrast color to fulfill accesibility requirements.
- When writing responsive media queries, use the clamp() function to adapt the text size in tablets and mobile devices.
- If a project has presence of modals, make the background blurry, darker and unscrollable when the modal is on. It would be better if the modal has open/exit animations.
- If the project uses a variable font, use the "font-variation-settings" to define the font weight depending on the contrast setting. Use the "@media (prefers-contrast)" queries when defining those settings.
- Try to use the rem/vw/vh units instead of px when possible.
- Control the size of the elements when defining the responsive styles, with the purpose of looking fine in responsive media queries and with user experience.
- If you use the grid on a component or part of the page which has cards/posters/etc..., use the auto-fill thing to make the grid adapt itself in every device.
About CSS Nestings
You have to write the CSS nesting like this example:
.class {
&:hover {
...
}
&::after {
...
}
& > descendent child {
...
}
}