Good Css

vojtaholik/good-css/skills/good-css

作者 vojtaholik8db0b739bffdfcd218b60164e51546b2d52eab80無授權條款收錄於 2026年10月9日更新於 2026年10月9日

Modern CSS techniques that replace breakpoint ladders, wrapper elements and scripts. Use whenever you write, edit or review styles in any form, including plain CSS, Tailwind classes, StyleX, CSS-in-JS and inline styles, and whenever you build or restyle a page or component, even if the user never mentions CSS.

AI 產生的概覽

指導撰寫現代 CSS,以自我調適的宣告取代斷點階梯、包裝元素和指令碼。

功能
這個技能為在任何樣式系統中撰寫與審查 CSS 提供參考指引,包括原生 CSS、Tailwind、StyleX、CSS-in-JS 和行內樣式。內容涵蓋基礎、版面配置、間距與形狀、文字與媒體、互動狀態、動態效果、顯示與隱藏模式,以及捲動與視埠行為。它產出無須斷點階梯或額外包裝元素即可自我調適的 CSS 宣告與規則,並提示瀏覽器支援方面的注意事項。
適用情境
在撰寫、編輯或審查樣式時使用,也適用於建置或重新設計頁面與元件時,即使使用者沒有提到 CSS。它用來以現代 CSS 技術取代斷點、包裝元素或指令碼。
執行需求
無須指令碼或套件,僅包含說明與參考 Markdown 檔案。部分內容涉及 Tailwind 4.2 功能及可選的搭配動態效果技能,但除代理程式外沒有其他必要條件。

Good CSS

One declaration that adapts on its own beats a set of breakpoints, and a CSS feature beats a script. Use JavaScript only where it makes a result nicer that already works without it.

Each technique is a set of properties and values, so it works in any authoring system. Class names in the examples are placeholders. Write the declarations in what the project already uses, whether that is a stylesheet, Tailwind utilities or StyleX objects. Where that system has no shorthand for a declaration, write it the long way, as a Tailwind arbitrary property or a rule in the project's CSS file. Do not swap the technique for a breakpoint.

In all CSS

These need no file.

  • Write inline and block properties in place of left, right, top and bottom. Tailwind has them too, as in mbs-, pe- and inset-bs-, so never write mt-, pr- or top-. The block ones need Tailwind 4.2. Below it, write them as arbitrary properties, as in [margin-block-start:theme(spacing.4)].
  • Write colors in oklch(), with none as the hue of a gray, white or black. Derive a hover, tint or transparent version with color-mix(in oklch, …).
  • Put sizes that grow with the screen in one clamp() token.
  • Put every :hover rule inside @media (hover: hover) and (pointer: fine).
  • Style focus with :focus-visible and outline. Never write outline: none.
  • Give everything pressable an :active state.
  • Put a transition that moves or scales something inside @media (prefers-reduced-motion: no-preference). Name its properties, never all, and never use ease-in.
  • Cut off overflow with overflow: clip. Keep hidden for an element a script scrolls.

Read the entry before you write

Each file holds entries with the CSS and its rules. The rules are the conditions the CSS needs to work, so keep all of them. Read only the files whose row matches what you are about to write. One component matches two or three, and a whole page matches most of them.

ReadBefore you write
references/foundations.mda reset or base stylesheet, a set of color tokens, dark mode, a type or spacing scale
references/layout.mda page container or wrapper, a grid of cards, cards whose parts line up, a sidebar, a component placed in slots of different widths, overlapping layers, centered content that can overflow
references/spacing-and-shape.mdspacing between sections, elements stacked one above another, one item pushed to the far end of a row or column, nested rounded corners
references/text-and-media.mdtext or images that come from a user or a CMS, such as names, titles, excerpts, thumbnails, avatars and embeds, an icon next to a label, a label that looks off-center, numbers in a column
references/interaction.mdthe focus, hover and press states of a button, link, input or card, a small tap target, a clickable card, form validation, a textarea, a parent styled by what it contains, page scroll locked behind a modal
references/motion.mdeasing and duration tokens, one state change that drives several values, a shadow that changes on hover, a transition between pages, the indicator under an active tab
references/show-and-hide.mda dialog, popover, dropdown menu or accordion
references/scroll-and-viewport.mda carousel, a row that may overflow, a modal body, chat list or drawer that scrolls between a header and a footer, in-page links under a sticky header, an app shell on desktop or on a phone

Left out on purpose

Never add text-box trim on *, text-rendering: optimizeLegibility, or a reset that puts display: contents or one shared grid cell on every element. references/foundations.md has the reasons.

Browser support

Most entries end with a Support: line. This skill sets no browser floor. Weigh the line against the browsers the project targets, and tell the user when something you used is missing from one of them.

Motion

Whether something should animate, the design or review of motion, springs, gestures and drag, and checks on a real phone belong to Emil Kowalski's skills animate, review-animations, improve-animations, find-animation-opportunities and mobile-native. When they are installed, use them for those jobs, and where one disagrees with a value here, use its value. When they are not, use the entries as written and add no motion beyond what an entry or the task calls for.

來源與署名

來源:vojtaholik/good-css位於skills/good-css提交8db0b73

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架