Skip to main content

14 docs tagged with "shadcn"

View all tags

Advanced: Applying to Other Components

A chapter that applies the cva, cn, Slot, and design-token patterns learned with Button to Badge, Input, Card, and Alert. We summarize a pattern-selection guide per component and design best practices.

Design Systems and Design Tokens

A chapter that explains where the color of bg-primary comes from. You learn the two layers of design tokens (primitive / semantic), OKLCH colors, token definitions with Tailwind v4's @theme inline, and how light / dark themes work.

Designing a Design System with the shadcn/ui Button

Targets React 19 / Tailwind CSS v4 / the latest shadcn/ui. A 13-chapter guide that uses the Button to teach reusable component design aligned with a design system through design tokens, cva, cn, and Radix Slot.

Forwarding ref: The React 19 Way

In this chapter, you learn how to access DOM elements using ref. We focus on the new React 19 style where ref is a normal prop, and also cover the traditional forwardRef.

From Button to a Design System

The final chapter that brings the design-token, cva, cn, Slot, and type patterns learned with Button into a single design system made of three layers (design tokens / primitives / patterns). It also introduces points for team operation and the next steps.

Hands-On Practice: Building a Button Component from Scratch

A hands-on exercise that starts from a plain button and stacks Tailwind design tokens, cva, cn, asChild (Slot), and TypeScript types one step at a time to complete a shadcn/ui-style Button component from scratch. It includes bonus exercises for adding a success variant and a loading state.

How the cn function works: understanding clsx and tailwind-merge

A chapter that digs into the internal behavior of clsx and tailwind-merge, which make up the shadcn/ui cn function, along with actual results. You learn about excluding falsy values, conflict resolution via conflict groups, and why the order is clsx then twMerge.

Tailwind CSS basics: utility-first

A chapter that teaches the utility-first idea of Tailwind CSS by breaking down the actual class list of the shadcn/ui Button. It explains layout, state modifiers (hover / focus-visible / disabled), the spacing scale, and an entry point into design tokens.

The goal of this book and what you will learn

The introductory chapter of a guide that teaches design system design using the shadcn/ui Button. It explains the book's goal, who it is for, the structure of all 13 chapters, and why the Button is the ideal subject for component design.

TypeScript Integration: Type-Safe Components

In this chapter, you learn about the TypeScript types that power the shadcn/ui Button. We cover props definitions using React.ComponentProps, VariantProps, and intersection types, and why React 19 no longer needs forwardRef generics.