Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(core): expand Slider track and Thumbnail remove hit areas to 24px on touch (#4963)

rubyycheung8b259e5372d1
diff --git a/packages/core/src/Slider/Slider.tsx b/packages/core/src/Slider/Slider.tsx
index 4ba8a505bc..b1d15d7dc5 100644
--- a/packages/core/src/Slider/Slider.tsx
+++ b/packages/core/src/Slider/Slider.tsx
@@ -174,6 +174,15 @@ const styles = stylex.create({
},
trackContainerHorizontal: {
height: THUMB_SIZE,
+ // The whole track is the tap target (a click anywhere on it moves the
+ // slider), but it is only THUMB_SIZE (20px) tall — under the WCAG 2.5.8 AA
+ // 24px minimum. Floor its block size to 24px on touch pointers only. The
+ // rail and thumb center on 50%, so they stay put; only the invisible
+ // tappable area grows. Desktop (fine pointer) is unchanged.
+ minBlockSize: {
+ default: null,
+ '@media (pointer: coarse)': '24px',
+ },
width: '100%',
cursor: 'pointer',
},
diff --git a/packages/core/src/Thumbnail/Thumbnail.tsx b/packages/core/src/Thumbnail/Thumbnail.tsx
index 4c329e7ae0..4f36f0095c 100644
--- a/packages/core/src/Thumbnail/Thumbnail.tsx
+++ b/packages/core/src/Thumbnail/Thumbnail.tsx
@@ -207,6 +207,7 @@ const styles = stylex.create({
},
removeButtonOverrides: {
'--_button-radius': `calc(${radiusVars['--radius-element']} - ${spacingVars['--spacing-1']})`,
+ position: 'relative',
height: 20,
minWidth: 20,
// Fixed colors instead of luminance-adapting theme: a translucent scrim
@@ -214,6 +215,15 @@ const styles = stylex.create({
// without sampling pixel brightness.
backgroundColor: colorVars['--color-overlay'],
color: colorVars['--color-on-dark'],
+ '--_thumbnail-hit-inset': {
+ default: '0px',
+ '@media (pointer: coarse)': '-2px',
+ },
+ '::after': {
+ content: '""',
+ position: 'absolute',
+ inset: 'var(--_thumbnail-hit-inset)',
+ },
},
disabled: {
opacity: 0.5,