Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Conditionally Applying Styles | Basic Concepts
course content

Зміст курсу

Next.js 14

Conditionally Applying StylesConditionally Applying Styles

We can conditionally apply styles based on state or other factors with the clsx library. You can find its documentation here, but we'll cover the important concepts now.

Let's imagine that we need to change the color of an element based on the status inside the InvoiceStatus component. The following conditions apply:

  • If the status is awaiting, the background color should be red, and the text color should be white;
  • If the status is fulfilled, the background color should be yellow and the text color should be blue.
app/ui/invoices/status.tsx

Все було зрозуміло?

Секція 2. Розділ 7
course content

Зміст курсу

Next.js 14

Conditionally Applying StylesConditionally Applying Styles

We can conditionally apply styles based on state or other factors with the clsx library. You can find its documentation here, but we'll cover the important concepts now.

Let's imagine that we need to change the color of an element based on the status inside the InvoiceStatus component. The following conditions apply:

  • If the status is awaiting, the background color should be red, and the text color should be white;
  • If the status is fulfilled, the background color should be yellow and the text color should be blue.
app/ui/invoices/status.tsx

Все було зрозуміло?

Секція 2. Розділ 7
some-alt