Ihre Next.js-App stylen
Fügen Sie einer Next.js-15-Anwendung mit globalem CSS, CSS Modules und Tailwind CSS innerhalb des App Router Styles hinzu
Ihre Next.js-App stylen ist eine kostenlose Next.js 15 Fullstack (App Router + Server Actions)-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Next.js 15 Fullstack (App Router + Server Actions)-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Next.js 15 Fullstack (App Router + Server Actions)-Kurs umfasst insgesamt 4 Lektionen.
Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.
Styling Options Overview
Next.js supports several styling approaches out of the box: global CSS, scoped CSS Modules, utility-first Tailwind, and CSS-in-JS libraries.
Global Stylesheet
Global CSS is imported once in the root layout and applies to every page — ideal for resets and base typography.
import "./globals.css";
export default function RootLayout({ children }) {
return (<html lang="en"><body>{children}</body></html>);
}CSS Modules for Scope
A CSS Module (x.module.css) generates locally-scoped class names, so component styles never leak into each other.
import styles from "./button.module.css";
export default function Button() {
return <button className={styles.primary}>Click</button>;
}Inside the Module File
Inside a module you write class names normally — Next.js hashes them at build time to keep them unique.
.primary {
background: rebeccapurple;
color: white;
padding: 8px 16px;
}Tailwind CSS
Tailwind gives you utility classes you compose right in your markup. It's the most common styling choice in modern Next.js apps.
export default function Card() {
return <div className="rounded-lg bg-white p-4 shadow">Hello</div>;
}Setting Up Tailwind
To set up Tailwind, install it and add its three directives to your global stylesheet so the utility classes become available.
@tailwind base;
@tailwind components;
@tailwind utilities;Conditional Classes
Toggle classes by state for conditional styling. A helper like clsx keeps the logic clean and readable.
import clsx from "clsx";
<button className={clsx("btn", isActive && "btn-active")} />Fonts with next/font
The next/font module self-hosts fonts with zero layout shift and no extra request to a font provider — performant typography for free.
import { Inter } from "next/font/google";
const inter = Inter({ subsets: ["latin"] });Server vs Client Styling
Global CSS and CSS Modules work in Server Components. Some CSS-in-JS libraries need a Client Component boundary or special setup.
Responsive Design
Tailwind's responsive prefixes like md: and lg: apply styles at breakpoints, making mobile-first layouts effortless.
<div className="text-sm md:text-base lg:text-lg">Responsive text</div>Choosing an Approach
Pick by job: CSS Modules for component isolation, Tailwind for fast utility-driven UI, and global CSS for resets and base typography.
Quick Check
What does a CSS Module give you that a global stylesheet does not?
Recap
Recap: Next.js styling spans global CSS, scoped CSS Modules, and Tailwind utilities, plus next/font for fast type and responsive breakpoints.
Lerne TypeScript mit einem KI-Tutor — kostenlos
Schreibe und führe echten Code in deinem Browser aus, bekomme sofortige Hilfe von einem 24/7 KI-Tutor und setze dein Lernen im Web oder in der App fort.
- Kurse
- 22
- Lektionen
- 88
Häufig gestellte Fragen
Ist die Lektion „Ihre Next.js-App stylen“ kostenlos?
Ja — der vollständige Text von „Ihre Next.js-App stylen“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Next.js 15 Fullstack (App Router + Server Actions)-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Next.js 15 Fullstack (App Router + Server Actions)-Kurs umfasst insgesamt 4 Lektionen.
Was lerne ich in „Ihre Next.js-App stylen“?
Fügen Sie einer Next.js-15-Anwendung mit globalem CSS, CSS Modules und Tailwind CSS innerhalb des App Router Styles hinzu Du übst Next.js 15 Fullstack (App Router + Server Actions) mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.
Brauche ich Erfahrung, um Next.js 15 Fullstack (App Router + Server Actions) zu starten?
Keine Vorkenntnisse erforderlich. Next.js 15 Fullstack (App Router + Server Actions) auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.
Wie lange dauert die Lektion „Ihre Next.js-App stylen“?
Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.
Kann ich in dieser Next.js 15 Fullstack (App Router + Server Actions)-Lektion Code schreiben und ausführen?
Ja. Jede Next.js 15 Fullstack (App Router + Server Actions)-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.
Alle Lektionen in diesem Kurs
- Projekt einrichten und CLI
- Grundlagen des dateisystembasierten Routings
- Überblick über Seiten und Layouts
- Ihre Next.js-App stylen