fix(carousel): use margin-auto centering and scale for nav button press effect#10271
Open
ktisakib wants to merge 3 commits into
Open
fix(carousel): use margin-auto centering and scale for nav button press effect#10271ktisakib wants to merge 3 commits into
ktisakib wants to merge 3 commits into
Conversation
…ss effect The carousel nav buttons used top-1/2 -translate-y-1/2 for vertical centering, which conflicts with the Button's active:translate-y-px. On click, translate-y-px overrides -translate-y-1/2, causing the button to jump ~50% of the carousel height instead of a subtle press. This also causes click misses on the button edges (see shadcn-ui#10084). Changes: - Replace translate-based centering with margin-auto centering (top-0 bottom-0 my-auto for horizontal, left-0 right-0 mx-auto for vertical) to eliminate the translate-y conflict entirely - Add scale-based press feedback (hover:scale-105 active:scale-95) via carousel CSS styles for all themes - Add missing MARK: Carousel section in style-lyra.css - Rebuild registry to propagate changes to all style variants Fixes shadcn-ui#10084
Contributor
|
@ktisakib is attempting to deploy a commit to the shadcn-pro Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The carousel navigation buttons (CarouselPrevious, CarouselNext) use `top-1/2 -translate-y-1/2` for vertical centering. The Button component applies `active:not-aria-[haspopup]:translate-y-px` for a press effect. On click, `translate-y: 1px` overrides `translate-y: -50%`, causing:
Reproduction
https://ui.shadcn.com/docs/components/radix/carousel
https://ui.shadcn.com/docs/components/base/carousel
Solution
1. Replace translate-based centering with margin-auto
```diff
Horizontal
-top-1/2 -left-12 -translate-y-1/2
+top-0 bottom-0 my-auto -left-12
Vertical
--top-12 left-1/2 -translate-x-1/2 rotate-90
+-top-12 left-0 right-0 mx-auto rotate-90
```
This eliminates the translate conflict entirely — no `translate-y` to override.
2. Add scale-based press feedback via CSS
```css
.cn-carousel-previous {
@apply rounded-full transition-transform duration-150 ease-out hover:scale-105 active:scale-95;
}
.cn-carousel-next {
@apply rounded-full transition-transform duration-150 ease-out hover:scale-105 active:scale-95;
}
```
Files changed
Fixes #10084