Make every component and the landing page responsive (v0.3.1)

Every story and the landing page now fit from a 320px phone to a wide
desktop without scrolling sideways.

- Inputs in flex rows (Input, FeaturedInput, NumberInput, Combobox) shrink
  instead of holding their native width
- Tab rows and ToggleGroup scroll within themselves on narrow screens;
  vertical tabs stack above their panel on phones
- Positioned popups cap at Base UI's --available-width
- Landing page: tablet header no longer crowds; code sample fits at 1024px
- Storybook a11y panel skips page-level rules that can't apply to a story
- check-stories.mjs gains --width and fails on horizontal overflow; all
  423 stories pass at 320, 375, 768 and desktop widths in both modes
This commit is contained in:
thekhalidsha committed 2026-09-28 22:47:26 +05:30
1 parent f01de83733
commit 23e67006d3
24 files changed
+136 -31

No files matched your search

+2 -2
View File
@@ -93,7 +93,7 @@ export const Fallbacks: Story = {
export const WithStatus: Story = {
render: (args) => (
<div className="grid gap-5">
<div className="flex items-center gap-5">
<div className="flex flex-wrap items-center gap-5">
{AVATAR_STATUSES.map((status) => (
<div key={status} className="flex flex-col items-center gap-2">
<Avatar {...args} status={status} />
@@ -101,7 +101,7 @@ export const WithStatus: Story = {
</div>
))}
</div>
<div className="flex items-end gap-4">
<div className="flex flex-wrap items-end gap-4">
{AVATAR_SIZES_LIST.map((size) => (
<Avatar key={size} name="John Smith" src={PORTRAITS.john} size={size} status="online" />
))}
+2 -2
View File
@@ -156,7 +156,7 @@ export function Combobox<Multiple extends boolean | undefined = false>({
aria-invalid={invalid || undefined}
aria-busy={loading || undefined}
className={cn(
'min-w-0 flex-1 bg-transparent text-fg outline-none placeholder:text-fg-muted disabled:cursor-not-allowed',
'w-0 min-w-0 flex-1 bg-transparent text-fg outline-none placeholder:text-fg-muted disabled:cursor-not-allowed',
multiple ? cn('min-w-16 px-1', CHIP_INPUT_HEIGHT[size]) : cn('h-full', controlPaddingX[size]),
!multiple && startIcon != null && 'pl-2',
inputClassName,
@@ -206,7 +206,7 @@ export function Combobox<Multiple extends boolean | undefined = false>({
</span>
)}
{multiple ? (
<BaseCombobox.Chips className="flex min-w-0 flex-1 flex-wrap items-center gap-1 py-1 pl-1.5">
<BaseCombobox.Chips className="flex w-0 min-w-0 flex-1 flex-wrap items-center gap-1 py-1 pl-1.5">
{selectedOptions.map((option) => (
<BaseCombobox.Chip
key={option.value}
+1 -1
View File
@@ -125,7 +125,7 @@ export function FeaturedInput({
{startIcon}
</span>
)}
<div className="relative min-w-0 flex-1">
<div className="relative w-0 min-w-0 flex-1">
<BaseInput
ref={setRefs}
type={isPassword && revealed ? 'text' : type}
+1 -1
View File
@@ -92,7 +92,7 @@ export function Input({
disabled={disabled}
onValueChange={onValueChange ? (value) => onValueChange(value) : undefined}
className={cn(
'min-w-0 flex-1 bg-transparent text-fg outline-none placeholder:text-fg-subtle disabled:cursor-not-allowed',
'w-0 min-w-0 flex-1 bg-transparent text-fg outline-none placeholder:text-fg-subtle disabled:cursor-not-allowed',
variant === 'underline' ? 'px-0.5' : controlPaddingX[size],
startIcon != null && 'pl-2',
endIcon != null && 'pr-2',
+1 -1
View File
@@ -99,7 +99,7 @@ export const AlignedWithInput: Story = {
render: (args) => (
<div className="grid gap-4">
{SIZES.map((size) => (
<div key={size} className="flex items-end gap-3">
<div key={size} className="flex flex-wrap items-end gap-3">
<Input label={`Name (${size})`} size={size} placeholder="Jane Doe" className="w-56" />
<NativeSelect {...args} size={size} className="w-56" />
</div>
+1 -1
View File
@@ -110,7 +110,7 @@ export function NumberInput({
{startAddon != null && <span className={cn(NUMBER_ADDON, 'border-r')}>{startAddon}</span>}
<NumberField.Input
className={cn(
'min-w-0 flex-1 bg-transparent text-fg tabular-nums outline-none placeholder:text-fg-subtle disabled:cursor-not-allowed',
'w-0 min-w-0 flex-1 bg-transparent text-fg tabular-nums outline-none placeholder:text-fg-subtle disabled:cursor-not-allowed',
controlPaddingX[size],
inputClassName,
)}
+1 -1
View File
@@ -119,7 +119,7 @@ export const Sides: Story = {
docs: { ...ownFrame(460).docs, description: { story: 'Each side, open. A popover flips when the preferred side has no room.' } },
},
render: (args) => (
<div className="mx-auto grid w-fit grid-cols-3 grid-rows-3 place-items-center gap-x-56 gap-y-24 py-6">
<div className="mx-auto grid w-fit grid-cols-3 grid-rows-3 place-items-center gap-x-12 gap-y-24 py-6 sm:gap-x-56">
{POPUP_SIDES.map((side) => (
<div
key={side}
+1 -1
View File
@@ -125,7 +125,7 @@ export const AlignedWithInput: Story = {
render: (args) => (
<div className="grid gap-4">
{SIZES.map((size) => (
<div key={size} className="flex items-end gap-3">
<div key={size} className="flex flex-wrap items-end gap-3">
<Input label={`Search (${size})`} size={size} placeholder="Jane Doe" className="w-56" />
<Select {...args} size={size} label="Department" className="w-56" />
<Button size={size}>Filter</Button>
+1 -1
View File
@@ -31,7 +31,7 @@ export const Playground: Story = {}
export const Shapes: Story = {
render: () => (
<div className="flex items-center gap-6">
<div className="flex flex-wrap items-center gap-6">
<Skeleton variant="circle" />
<Skeleton variant="circle" width={56} height={56} />
<Skeleton width={160} height={96} className="rounded-xl" />
+18 -1
View File
@@ -100,11 +100,13 @@ function TabsRoot({
function TabsList({ className, children, ...props }: TabsListProps) {
const { variant, orientation, fullWidth } = useContext(TabsStyleContext)
return (
const list = (
<BaseTabs.List
className={cn(
TABS_LIST_STYLES[variant][orientation],
orientation === 'horizontal' && 'min-w-max',
fullWidth ? 'w-full' : orientation === 'horizontal' && variant !== 'underline' && 'w-fit',
orientation === 'horizontal' && variant === 'underline' && 'min-w-full',
orientation === 'vertical' && 'shrink-0 self-start',
className,
)}
@@ -114,6 +116,21 @@ function TabsList({ className, children, ...props }: TabsListProps) {
<BaseTabs.Indicator className={TABS_INDICATOR_STYLES[variant][orientation]} />
</BaseTabs.List>
)
if (orientation === 'vertical') return list
// When the tabs don't fit (phones), the row scrolls sideways instead of
// widening the page. The padding keeps focus rings and the underline
// indicator, which sits 1px below the list, from being clipped.
return (
<div
className={cn(
'-m-1 min-w-0 max-w-[calc(100%+0.5rem)] overflow-x-auto overscroll-x-contain p-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden',
!fullWidth && variant !== 'underline' && 'w-fit',
)}
>
{list}
</div>
)
}
function TabsTab({ value, icon, badge, className, children, ...props }: TabsTabProps) {
+1 -1
View File
@@ -101,7 +101,7 @@ export const Variants: Story = {
export const Sizes: Story = {
render: (args) => (
<div className="grid justify-items-start gap-4">
<div className="grid grid-cols-[minmax(0,1fr)] gap-4">
{SIZES.map((size) => (
<div key={size} className="flex flex-wrap items-center gap-4">
<ToggleGroup {...args} size={size} aria-label={`Date range, size ${size}`} />
+4 -1
View File
@@ -150,6 +150,8 @@ export function ToggleGroup({
'items-stretch',
fullWidth ? 'flex' : 'inline-flex',
orientation === 'vertical' && 'flex-col',
// Scrolls within itself on narrow screens instead of widening the page.
orientation === 'horizontal' && 'max-w-full overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden',
TOGGLE_GROUP_FRAME[variant],
TOGGLE_GROUP_HEIGHTS[size],
className,
@@ -164,7 +166,8 @@ export function ToggleGroup({
aria-label={iconOnly ? item.label : undefined}
className={cn(
itemBase,
'outline-hidden focus-visible:relative focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary-500',
// Inset ring: the group can scroll, which would clip an outer one.
'outline-hidden focus-visible:relative focus-visible:z-10 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary-500',
TOGGLE_GROUP_ITEM[variant],
TOGGLE_ITEM_SIZES[size],
iconOnly && TOGGLE_ICON_ITEM_SIZES[size],
+3 -3
View File
@@ -104,7 +104,7 @@ export const Sides: Story = {
export const Alignment: Story = {
parameters: pinnedOpen(),
render: (args) => (
<div className="flex gap-24 pt-10">
<div className="flex flex-wrap gap-x-24 gap-y-16 pt-10">
{POPUP_ALIGNS.map((align) => (
<Tooltip key={align} {...args} align={align} content={`align="${align}"`} open>
<Button variant="outline" color="neutral">
@@ -122,7 +122,7 @@ export const Colors: Story = {
'`neutral` inverts the page (dark in light mode), `primary` uses the brand colour, `light` is a bordered surface. Pinned open for reference.',
),
render: (args) => (
<div className="flex gap-16 pt-10">
<div className="flex flex-wrap gap-x-16 gap-y-14 pt-10">
{TOOLTIP_COLORS_LIST.map((color) => (
<Tooltip key={color} {...args} color={color} content={`${color[0].toUpperCase()}${color.slice(1)} tooltip`} open>
<Button variant="outline" color="neutral">
@@ -242,7 +242,7 @@ export const InfoTipNextToLabel: Story = {
export const InfoTipColors: Story = {
parameters: ownFrame(),
render: () => (
<div className="flex gap-24 pt-14">
<div className="flex flex-wrap gap-x-24 gap-y-16 pt-14">
{TOOLTIP_COLORS_LIST.map((color) => (
<span key={color} className="inline-flex items-center gap-1.5 text-sm text-fg">
{color}
+1 -1
View File
@@ -69,7 +69,7 @@ export type DropdownMenuItemData =
| DropdownMenuLabel
| DropdownMenuSubmenu
export const menuPopupClass = 'min-w-48 max-h-(--available-height) overflow-y-auto p-1'
export const menuPopupClass = 'min-w-[min(12rem,var(--available-width,12rem))] max-h-(--available-height) overflow-y-auto p-1'
export const menuDangerItem =
'text-danger-700 data-highlighted:bg-danger-50 dark:text-danger-300 dark:data-highlighted:bg-danger-500/15 ' +
+2 -1
View File
@@ -11,7 +11,8 @@ export type TabsOrientation = 'horizontal' | 'vertical'
export const TABS_VARIANTS: TabsVariant[] = ['underline', 'pills', 'enclosed']
export const tabsRoot = 'flex flex-col gap-4 data-[orientation=vertical]:flex-row data-[orientation=vertical]:gap-6'
/** Vertical tabs sit beside their panel from `sm` up; on phones they stack above it. */
export const tabsRoot = 'flex min-w-0 flex-col gap-4 sm:data-[orientation=vertical]:flex-row sm:data-[orientation=vertical]:gap-6'
/** variant → orientation → list classes. */
export const TABS_LIST_STYLES: Record<TabsVariant, Record<TabsOrientation, string>> = {
+3 -3
View File
@@ -25,9 +25,9 @@ export const TOOLTIP_ARROW_COLORS: Record<TooltipColor, string> = {
}
export const TOOLTIP_SIZES: Record<TooltipSize, string> = {
sm: 'max-w-56 rounded-md px-2 py-1 text-xs leading-4',
md: 'max-w-72 rounded-lg px-2.5 py-1.5 text-[0.8125rem] leading-5',
lg: 'max-w-80 rounded-lg px-3.5 py-2.5 text-sm leading-5',
sm: 'max-w-[min(14rem,var(--available-width,14rem))] rounded-md px-2 py-1 text-xs leading-4',
md: 'max-w-[min(18rem,var(--available-width,18rem))] rounded-lg px-2.5 py-1.5 text-[0.8125rem] leading-5',
lg: 'max-w-[min(20rem,var(--available-width,20rem))] rounded-lg px-3.5 py-2.5 text-sm leading-5',
}
/** Help icon button next to a label. */
+15
View File
@@ -152,6 +152,7 @@
}
.brand-by {
white-space: nowrap;
padding-left: 0.6rem;
border-left: 1px solid var(--line-strong);
font-size: 0.8125rem;
@@ -805,6 +806,20 @@
/* ---------- Responsive ---------- */
/* Tablets: the nav needs the room the tagline was using. */
@media (max-width: 900px) {
.brand-by {
display: none;
}
}
/* Three narrow "Why" cards: keep the longest code line inside its card. */
@media (min-width: 961px) and (max-width: 1199px) {
.code-sample pre {
font-size: 0.6875rem;
}
}
@media (max-width: 960px) {
.hero,
.playground-grid {
+6 -2
View File
@@ -54,9 +54,13 @@ export const controlBox =
'data-disabled:cursor-not-allowed data-disabled:opacity-55 disabled:cursor-not-allowed disabled:opacity-55'
/** Popups: menus, selects, popovers, dialogs. */
/** In dark mode popups sit a step lighter than the card behind them. */
/**
* In dark mode popups sit a step lighter than the card behind them.
* `--available-width` comes from Base UI's positioner, so a menu or select never
* grows past the screen edge; where it isn't set (dialogs) the cap is ignored.
*/
export const popupSurface =
'rounded-xl border border-border bg-surface text-fg shadow-popup outline-hidden dark:bg-surface-muted'
'rounded-xl border border-border bg-surface text-fg shadow-popup outline-hidden dark:bg-surface-muted max-w-(--available-width)'
/** Enter and exit motion for popups that grow from their trigger. */
export const popupMotion =