การจัดรูปแบบและธีม
กำหนดสี ระยะห่าง และโหมดมืดด้วยพรอมป์
การจัดรูปแบบและธีม เป็นบทเรียน Vibe Coding ฟรีบน CoddyKit นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Vibe Coding และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Vibe Coding มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
From 'Works' to 'Wow'
You can generate a working UI in seconds — but the difference between an amateur and a polished app is styling: color, spacing, typography, and a cohesive theme.
In this lesson you'll learn to control all of it by prompt, set up a reusable theme, and add a slick dark mode — without touching a color picker if you don't want to.
A Theme Is a Shared Recipe
A theme is a small set of design decisions — your colors, fonts, and spacing — defined once and reused everywhere. Change the theme, and the whole app updates.
Ask the AI to set up design tokens: named values like 'primary color' or 'spacing-large' that components reference instead of hard-coding.
"Set up a theme with design tokens: a primary color, a secondary
color, a neutral grey scale, a base font, and consistent spacing
steps (4, 8, 16, 24, 32px). Make all my components use these tokens
instead of hard-coded values."Choosing a Color Palette by Prompt
You don't need color theory. Describe a feeling and let the AI propose a palette, then tweak.
Ask for a primary (your brand), an accent (for highlights), and neutrals (backgrounds and text). Request the actual hex codes so you can lock them in.
"Suggest a color palette for a healthy-eating app: fresh, calm,
and trustworthy. Give me a primary, an accent, and 5 neutral greys,
as hex codes. Then apply them across all my components."Spacing: The Secret to 'Clean'
Most amateur UIs look cramped. The fix is consistent spacing and whitespace. Designers use a spacing scale (multiples of 4 or 8px) so gaps feel intentional.
If something feels 'off,' it's usually spacing. Just say "more breathing room" and the AI knows what to do.
"Increase the whitespace throughout the page. Use a consistent
8px spacing scale. Add more padding inside cards and more gap
between sections so it feels calm and uncluttered."Typography That Feels Designed
Type carries a huge amount of personality. Ask for a type scale (clear sizes for h1, h2, body, captions) and good line height for readability.
Pairing a distinctive heading font with a clean body font instantly elevates a design.
"Set up typography: use 'Inter' for body text and a slightly bolder
geometric font for headings. Define a clear scale (h1 48px, h2 32px,
h3 24px, body 16px) with comfortable line height. Apply it everywhere."Meet Tailwind (Lightly)
Most AI UI tools style with Tailwind CSS — utility classes like p-4 (padding) or text-lg (large text) written right in the markup.
You rarely write these by hand, but recognizing them helps you give precise feedback like "use a larger text size here."
<button class="px-4 py-2 rounded-lg bg-blue-600
text-white text-sm font-semibold hover:bg-blue-700">
Save
</button>Adding Dark Mode
Dark mode is expected in modern apps. The right way is to define light and dark versions of your theme tokens, then let a toggle switch between them.
Ask the AI to make colors theme-aware rather than hard-coded, so dark mode 'just works' everywhere.
"Add dark mode. Create a dark version of my color tokens: dark
backgrounds, light text, and slightly muted accents. Add a toggle
in the navbar that switches themes, and remember the user's choice."Simulating a Theme Toggle
Under the hood, switching themes is just choosing a different set of color values. Here's a tiny JavaScript model of that idea — run it to see how a toggle picks colors from a theme object.
const themes = {
light: { bg: '#ffffff', text: '#111111' },
dark: { bg: '#111111', text: '#f5f5f5' }
};
let current = 'light';
function toggle() {
current = current === 'light' ? 'dark' : 'light';
const t = themes[current];
console.log(current + ' -> bg ' + t.bg + ', text ' + t.text);
}
toggle();
toggle();Consistency Beats Cleverness
A beautiful app isn't one with the fanciest button — it's one where everything matches. Same corner radius, same shadow style, same accent color, same spacing rhythm.
When you spot inconsistency, prompt the AI to unify it across the whole app in one pass.
"Audit my app for visual inconsistencies. Make all corner radii,
shadows, button styles, and spacing consistent. Use my theme tokens
everywhere and remove any one-off hard-coded colors."Polish Details: Motion and States
Small touches signal quality: subtle hover effects, smooth transitions, and clear focus states for accessibility. Ask for gentle animation — never overdo it.
These finishing moves make a generated UI feel handcrafted.
"Add subtle polish: smooth 150ms transitions on hover, a gentle
lift on cards, and clear keyboard focus rings on buttons and inputs.
Keep animations tasteful and quick, not flashy."Practice: Restyle in Two Prompts
Take any UI you've generated and give it a whole new identity with just a palette swap and a font change. Watch how a theme-driven design transforms instantly. This is the power of styling by tokens instead of by hand.
Prompt 1: "Switch the theme to a warm sunset palette:
deep orange primary, soft pink accent, cream backgrounds."
Prompt 2: "Change headings to a bold rounded font and add
dark mode with a matching warm-dark variant."Quick Check
Why is setting up a theme with design tokens better than styling each component with hard-coded colors?
Recap: Beautiful by Prompt
You learned to control the look of an app with words: define a theme with design tokens, choose a palette by feeling, fix 'cramped' with consistent spacing, set a type scale, and add dark mode by making colors theme-aware.
Polish with subtle motion and, above all, chase consistency. Next lesson: making your beautiful design look great on phones and desktops alike — responsive design by prompt.
คำถามที่พบบ่อย
บทเรียน “การจัดรูปแบบและธีม” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “การจัดรูปแบบและธีม” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Vibe Coding ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Vibe Coding มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “การจัดรูปแบบและธีม”
กำหนดสี ระยะห่าง และโหมดมืดด้วยพรอมป์ คุณปฏิบัติ Vibe Coding ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Vibe Coding หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Vibe Coding บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน
บทเรียน “การจัดรูปแบบและธีม” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Vibe Coding นี้ได้ไหม
ได้ บทเรียน Vibe Coding ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ