Responsive
In shadcn_ui the responsiveness is an important part of the library.
The ShadTheme
supports a customizable set of breakpoints.
Default
Current breakpoint
To get the current breakpoint you can use ShadResponsiveBuilder
or context.breakpoint
, eg:
which is equivalent to:
In Tailwind CSS, it’s common to say that sm is not for small screens, but will target also the largest sizes if you don’t provide a larger breakpoint.
That’s why I’m using the >=
operator.
If you just want to check if you’re in a specific breakpoint, use the ==
operator.
Sealed class
The breakpoint returned is a sealed class so you can switch any size.