modern-css
Specialized knowledge for writing modern high-quality CSS. Trigger this skill when starting a new CSS project/file, when the user asks about new CSS features (e.g. Masonry, View Transitions, Container Queries, Scroll-driven animations), or requests refactoring of legacy styles to modern standards.
Install
mkdir -p .claude/skills/modern-css && curl -L -o skill.zip "https://mcp.directory/api/skills/download/4582" && unzip -o skill.zip -d .claude/skills/modern-css && rm skill.zipInstalls to .claude/skills/modern-css
About this skill
Modern CSS
This skill provides a reference for writing modern, robust, and efficient CSS.
Layout & Responsive Design
Container Queries
.card {
container: --my-card / inline-size;
}
@container --my-card (width < 40ch) {
/* Component-based responsive design */
}
@container (20ch < width < 50ch) {
/* Range syntax */
}
Container units: cqi, cqb, cqw, cqh - size relative to container dimensions
Anchored container queries: Style positioned elements based on anchor fallback state
.tooltip {
container-type: anchored;
}
@container anchored(top) {
/* Styles when positioned at top */
}
Media Query Range Syntax
@media (width <= 1024px) { }
@media (360px < width < 1024px) { }
Grid Enhancements
- Subgrid: Inherit parent grid lines for nested layouts
- Masonry:
display: grid-lanesfor Pinterest-style layouts with logical tab order. (Previously proposed asgrid-template-rows: masonry).
Color & Theming
Color Scheme & Light-Dark Function
:root {
color-scheme: light dark;
--surface-1: light-dark(white, #222);
--text-1: light-dark(#222, #fff);
}
Modern Color Spaces
/* OKLCH: uniform brightness, P3+ colors */
.vibrant {
background: oklch(72% 75% 330);
}
/* Display-P3 for HDR displays */
@media (dynamic-range: high) {
.neon {
--neon-red: color(display-p3 1 0 0);
}
}
/* Better gradients with in oklch */
.gradient {
background: linear-gradient(
to right in oklch,
color(display-p3 1 0 .5),
color(display-p3 0 1 1)
);
}
Color Manipulation
/* color-mix() */
.lighten {
background: color-mix(in oklab, var(--brand), white);
}
/* Relative color syntax */
.lighter {
background: oklch(from blue calc(l + .25) c h);
background: oklch(from blue 75% c h); /* Set to specific lightness */
}
.semi-transparent {
background: oklch(from var(--color) l c h / 50%);
}
.complementary {
background: hsl(from blue calc(h + 180) s l);
}
Accent Color
:root {
accent-color: hotpink; /* Tints checkboxes, radios, range inputs */
}
Typography
Text Wrapping
h1 {
text-wrap: balance; /* Balanced multi-line headings */
max-inline-size: 25ch;
}
p {
text-wrap: pretty; /* No orphans */
max-inline-size: 50ch;
}
Text Box Trim
h1, p, button {
text-box: trim-both cap alphabetic; /* Optical vertical centering */
}
Fluid Typography
.heading {
font-size: clamp(1rem, 1rem + 0.5vw, 2rem); /* Respects user preferences */
}
Dynamic Viewport Units
dvh/dvw- Dynamic (accounts for mobile browser UI)svh/svw- Small (smallest possible viewport)lvh/lvw- Large (largest possible viewport)
Animations & Motion
Scroll-Driven Animation
/* Animate on scroll position */
.parallax {
animation: slide-up linear both;
animation-timeline: scroll();
}
/* Animate on viewport intersection */
.fade-in {
animation: fade linear both;
animation-timeline: view();
animation-range: cover -75cqi contain 20cqi;
}
View Transitions
Status: Baseline Newly Available (Same-document). Cross-document transitions are in Limited Availability (Chrome/Safari 18.2+).
@view-transition {
navigation: auto; /* Automatically animate page transitions (MPAs) */
}
nav {
view-transition-name: --persist-nav; /* Persist specific elements */
view-transition-class: --site-header; /* Group transitions with classes */
}
/* Style the active transition */
html:active-view-transition {
overflow: hidden;
}
Nested View Transition Groups: Preserve 3D transforms and clipping during transitions.
Advanced Easing with linear()
.springy {
--spring: linear(
0, 0.14 4%, 0.94 17%, 1.15 24% 30%, 1.02 43%, 0.98 51%, 1 77%, 1
);
transition: transform 1s var(--spring);
}
@starting-style
.dialog {
transition: opacity .5s, scale .5s;
@starting-style {
opacity: 0;
scale: 1.1;
}
}
Custom Properties & Advanced Features
@property
Type-safe, animatable custom properties:
@property --gradient-angle {
syntax: "<angle>";
inherits: false;
initial-value: 0deg;
}
.animate {
transition: --gradient-angle 1s ease;
&:hover {
--gradient-angle: 360deg;
}
}
Math Functions & calc-size()
Newly Available: calc-size() allows calculations and transitions on intrinsic sizes (auto, min-content).
/* Finally: Animate to auto height! */
.accordion-content {
height: 0;
overflow: hidden;
transition: height 0.3s ease;
}
.accordion-item.open .accordion-content {
height: calc-size(auto);
}
.radial-layout {
--_angle: calc(var(--sibling-index) * var(--_offset));
translate:
calc(cos(var(--_angle)) * var(--_circle-size))
calc(sin(var(--_angle)) * var(--_circle-size));
}
Tree Counting Functions (Coming Soon)
.staggered {
animation-delay: calc(sibling-index() * .1s);
background-color: hsl(sibling-count() 50% 50%);
}
Conditional CSS with if() (Coming Soon)
.dynamic {
color: if(
style(--theme: dark),
white,
black
);
}
Architecture & Organization
Cascade Layers
@layer reset, design-system, components, utilities;
@import "open-props/colors" layer(design-system);
@import "components/nav/base.css" layer(components.nav);
@layer components.nav.primary {
nav {
position: sticky;
inset-block-start: 0;
}
}
Benefits:
- Import third-party CSS with lower specificity
- Organize styles by concern, not selector weight
- Nested layers create clear hierarchies
Interactive Components
Dialog
<dialog id="modal">
<form method="dialog">
<button value="cancel">Cancel</button>
<button value="confirm">Confirm</button>
</form>
</dialog>
<button commandfor="modal" command="showModal">Open</button>
<button commandfor="modal" command="close">Close</button>
New: closedby attribute enables light-dismiss behavior
Popover
<button popovertarget="menu">Show Menu</button>
<div popover id="menu">...</div>
popover=hint: Ephemeral tooltips that don't dismiss other popovers
[popover] {
transition:
display .5s allow-discrete,
overlay .5s allow-discrete,
opacity .5s;
@starting-style {
&:popover-open {
opacity: 0;
}
}
}
Anchor Positioning
.tooltip-anchor {
anchor-name: --tooltip;
}
.tooltip[popover] {
position-anchor: --tooltip;
position-area: block-start;
position-try-fallbacks: flip-block;
position-try-order: most-height;
}
Pseudo-elements: anchor(), ::scroll-button(), ::scroll-marker()
Exclusive Accordion
<details name="accordion">...</details>
<details name="accordion">...</details>
<!-- Only one can be open at a time -->
Customizable Select
select {
appearance: base-select; /* Full CSS control */
}
/* Style options with rich HTML */
select option::before {
content: ""; /* Can include images, icons */
}
Search Element
<search>
<form>
<input type="search" name="q">
<button type="submit">Search</button>
</form>
</search>
Form Enhancements
Field Sizing
textarea, select, input {
field-sizing: content; /* Auto-grow to content */
}
textarea {
min-block-size: 3lh; /* Line-height units */
max-block-size: 80dvh;
}
Better Validation Pseudo-Classes
/* Wait for user interaction before showing errors */
:user-invalid {
outline-color: red;
}
:user-valid {
outline-color: green;
}
label:has(+ input:user-invalid) {
text-decoration: underline wavy red;
}
HR in Select
<select>
<option>Option 1</option>
<hr>
<option>Option 2</option>
</select>
Visual Effects
Scrollbar Styling
.custom-scrollbar {
scrollbar-color: hotpink transparent;
scrollbar-width: thin;
}
Shape Function
.complex-clip {
clip-path: shape(
from 0% 0%,
curve by 50% 25% via 25% 50%,
line to 100% 100%
);
}
Corner Shapes
.fancy-corners {
corner-shape: squircle;
corner-shape: notch;
corner-shape: scoop;
corner-shape: superellipse(0.7);
}
Progressive Enhancement Patterns
Feature Detection
@supports (animation-timeline: view()) {
.fade-in {
animation: fade linear both;
animation-timeline: view();
}
}
@supports (container-type: inline-size) {
.responsive-card {
container-type: inline-size;
}
}
Respect User Preferences
@media (prefers-reduced-motion: no-preference) {
.animated {
animation: slide 1s ease;
}
}
@media (prefers-color-scheme: dark) {
:root {
--surface: #222;
}
}
@media (prefers-contrast: more) {
.text {
font-weight: 600;
}
}
Checking Browser Support: Baseline
What is Baseline? A unified way to understand cross-browser feature availability. Features are marked as:
- Widely Availabl: Supported in the last 2.5 years of all major browsers
- Newly Availab: Available in all major browsers
- Limited Availability: Not yet in all browsers
How to Check Baseline Status
- BEST: Fetch https://web-platform-dx.github.io/web-features-explorer/groups/ and find the feature in there, then fetch it's detail page.
- Can I Use: caniuse.com shows Baseline badges at the top of each feature
- MDN: Look for the Baseline badge in the browser compatibility table
- web.dev: Feature articles include Baseline status
Remember: Always check Baseline status, use @supports for cutting-edge features, and respect user preferences with media queries. Modern CSS is about progressive enhancement and building resilient interfaces that work for everyone.
Real-World Example: Modern Component
Here's a card component using many modern CSS features:
/*
---
*Content truncated.*
More by paulirish
View all skills by paulirish →You might also like
flutter-development
aj-geddes
Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.
ui-ux-pro-max
nextlevelbuilder
"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."
drawio-diagrams-enhanced
jgtolentino
Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.
godot
bfollington
This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.
nano-banana-pro
garg-aayush
Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.
pdf-to-markdown
aliceisjustplaying
Convert entire PDF documents to clean, structured Markdown for full context loading. Use this skill when the user wants to extract ALL text from a PDF into context (not grep/search), when discussing or analyzing PDF content in full, when the user mentions "load the whole PDF", "bring the PDF into context", "read the entire PDF", or when partial extraction/grepping would miss important context. This is the preferred method for PDF text extraction over page-by-page or grep approaches.
Related MCP Servers
Browse all serversGistPad (GitHub Gists) turns gists into a powerful knowledge management system for daily notes and versioned content.
Generate lyrics, songs, and tracks instantly with Mureka.ai Music Generation, an AI music generator. No production skill
Comprehensive knowledge management platform with Elasticsearch, file operations, and version control for efficient knowl
Structured Workflow guides disciplined software engineering via refactoring, feature creation, and test driven developme
Contextual AI bridges AI interfaces with specialized agents for RAG-powered query processing, intelligent retrieval, and
Build persistent semantic networks for enterprise & engineering data management. Enable data persistence and memory acro
Stay ahead of the MCP ecosystem
Get weekly updates on new skills and servers.