1<button class="bg-blue-500 text-white p-2 sm:p-4 md:p-6 lg:p-8">
2 Responsive Button
3</button>
1/* Tailwind CSS Breakpoints */
2
3/* Small devices (640px and up) */
4@media (min-width: 640px) {
5 /* Your styles here */
6}
7
8/* Medium devices (768px and up) */
9@media (min-width: 768px) {
10 /* Your styles here */
11}
12
13/* Large devices (1024px and up) */
14@media (min-width: 1024px) {
15 /* Your styles here */
16}
17
18/* Extra large devices (1280px and up) */
19@media (min-width: 1280px) {
20 /* Your styles here */
21}
22
23/* 2 Extra large devices (1536px and up) */
24@media (min-width: 1536px) {
25 /* Your styles here */
26}
1/*
2SCSS Mixin for Tailwind CSS Responsive Breakpoints
3
4This mixin allows you to easily apply styles at specific breakpoints defined by Tailwind CSS.
5It supports the following breakpoints:
6- sm (640px)
7- md (768px)
8- lg (1024px)
9- xl (1280px)
10- 2xl (1536px)
11*/
12
13@mixin responsive($breakpoint) {
14 @if $breakpoint == sm {
15 @media (min-width: 640px) { @content; }
16 } @else if $breakpoint == md {
17 @media (min-width: 768px) { @content; }
18 } @else if $breakpoint == lg {
19 @media (min-width: 1024px) { @content; }
20 } @else if $breakpoint == xl {
21 @media (min-width: 1280px) { @content; }
22 } @else if $breakpoint == '2xl' {
23 @media (min-width: 1536px) { @content; }
24 } @else {
25 @warn "Invalid breakpoint: #{$breakpoint}.";
26 }
27}
28
29/*
30Usage Example:
31
32This demonstrates how to use the responsive mixin to apply different background colors
33at various breakpoints.
34*/
35
36.my-class {
37 background-color: blue; // Default background color
38
39 @include responsive(sm) {
40 background-color: green; // Change to green on small screens
41 }
42
43 @include responsive(md) {
44 background-color: yellow; // Change to yellow on medium screens
45 }
46
47 @include responsive(lg) {
48 background-color: orange; // Change to orange on large screens
49 }
50
51 @include responsive(xl) {
52 background-color: red; // Change to red on extra-large screens
53 }
54
55 @include responsive('2xl') {
56 background-color: purple; // Change to purple on 2 extra-large screens
57 }
58}