Rounded corners make boxes and buttons look softer and friendlier. They improve the look and feel of a website.
Border radius (rounded corners) in Tailwind
Start learning this pattern below
Jump into concepts and practice - no test required
rounded rounded-sm rounded-md rounded-lg rounded-xl rounded-2xl rounded-3xl rounded-full rounded-t rounded-b rounded-l rounded-r rounded-tl rounded-tr rounded-bl rounded-br
Use rounded classes to add different sizes of rounded corners.
Use directional classes like rounded-tl to round only specific corners.
<div class="rounded bg-blue-500 p-4 text-white">Rounded corners</div><div class="rounded-lg bg-green-500 p-4 text-white">Large rounded corners</div><div class="rounded-tl-full bg-red-500 p-4 text-white">Only top-left corner rounded fully</div><div class="rounded-full bg-purple-500 p-4 text-white">Fully rounded (circle shape)</div>This page shows four boxes with different rounded corners using Tailwind CSS classes. Each box has a background color, padding, and white text for contrast. The boxes are stacked vertically with space between them.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>Tailwind Border Radius Example</title> <script src="https://cdn.tailwindcss.com"></script> </head> <body class="flex flex-col items-center gap-6 p-8 bg-gray-100 min-h-screen"> <div class="rounded bg-blue-500 p-6 text-white w-64 text-center">Default rounded corners</div> <div class="rounded-lg bg-green-500 p-6 text-white w-64 text-center">Large rounded corners</div> <div class="rounded-tl-full bg-red-500 p-6 text-white w-64 text-center">Top-left fully rounded</div> <div class="rounded-full bg-purple-500 p-6 text-white w-64 text-center">Fully rounded (pill shape)</div> </body> </html>
Rounded corners improve user experience by making elements look friendlier.
Use rounded-full to create circles or pills, but ensure width and height match for perfect circles.
Combine with shadows and colors for modern UI design.
Use Tailwind's rounded classes to add rounded corners easily.
Different sizes and directions let you customize which corners are rounded.
Rounded corners make your website look modern and approachable.
Practice
rounded do to an element?Solution
Step 1: Understand the purpose of
Theroundedclassroundedclass in Tailwind CSS is used to add rounded corners to elements.Step 2: Identify what
It affects the border radius, making the corners curved instead of sharp.roundedaffectsFinal Answer:
Adds rounded corners to all sides of the element -> Option AQuick Check:
Rounded corners =roundedclass [OK]
rounded class [OK]- Confusing rounded corners with borders
- Thinking it changes colors
- Assuming it adds padding
Solution
Step 1: Recall Tailwind border radius sizes
Tailwind usesrounded-smfor small,rounded-mdfor medium,rounded-lgfor large, androunded-xlfor extra large radius.Step 2: Identify the medium size class
The medium border radius class isrounded-md.Final Answer:
rounded-md -> Option BQuick Check:
Medium radius =rounded-md[OK]
rounded-md class [OK]- Choosing
rounded-lgorrounded-xlfor medium - Confusing
rounded-smas medium - Misspelling class names
<div class="w-32 h-32 bg-blue-500 rounded-tl-lg rounded-br-lg"></div>
Solution
Step 1: Understand the classes used
The classesrounded-tl-lgandrounded-br-lgapply large rounding to the top-left and bottom-right corners respectively.Step 2: Visualize the effect on the box
Only these two corners will be rounded large; the other corners remain sharp (no rounding).Final Answer:
The top-left and bottom-right corners are large rounded; others are sharp -> Option DQuick Check:
Specific corners rounded =rounded-tl-lgandrounded-br-lg[OK]
- Assuming all corners round with these classes
- Mixing corner abbreviations
- Ignoring the size suffix like -lg
<button class="rounded-top-md bg-green-400 p-4">Click</button>
Solution
Step 1: Check the border radius class syntax
Tailwind usesrounded-tfor top corners, notrounded-top.Step 2: Confirm other classes
p-4andbg-green-400are valid Tailwind classes, and buttons can have rounded corners.Final Answer:
The classrounded-top-mdis invalid in Tailwind -> Option AQuick Check:
Correct top rounding class =rounded-t-md[OK]
rounded-t-md for top corners, not rounded-top-md [OK]- Using non-existent class names
- Confusing padding with border radius
- Thinking buttons can't have rounded corners
Solution
Step 1: Understand bottom corner rounding classes
rounded-b-xlrounds both bottom-left and bottom-right corners to extra large size.Step 2: Compare with other options
rounded-bl-xlandrounded-br-xlindividually round corners butrounded-b-xlis simpler and correct.rounded-xlrounds all corners, androunded-bottom-xlis invalid.Final Answer:
rounded-b-xl -> Option CQuick Check:
Bottom corners extra large =rounded-b-xl[OK]
rounded-b-xl for both bottom corners [OK]- Using invalid class
rounded-bottom-xl - Using separate classes when shorthand exists
- Choosing
rounded-xlwhich rounds all corners
