Skip to content

docs: Add docs for horizontal orientation#9843

Open
LFDanLu wants to merge 8 commits intomainfrom
docs_for_release
Open

docs: Add docs for horizontal orientation#9843
LFDanLu wants to merge 8 commits intomainfrom
docs_for_release

Conversation

@LFDanLu
Copy link
Member

@LFDanLu LFDanLu commented Mar 25, 2026

Part of audit

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

Check out the docs updates

🧢 Your Project:

RSP

@rspbot
Copy link

rspbot commented Mar 25, 2026

constructor(options: ListLayoutOptions = {}) {
super();
this.rowHeight = options.rowHeight ?? null;
this.rowHeight = options?.rowSize ?? options?.rowHeight ?? null;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also go ahead and change these height properties to be size as well, would just need to make it back compat with additional getters. Not sure if worth it if those would stick around for quite some time, but might reduce confusion

this.headingHeight = options.headingHeight ?? null;
this.estimatedHeadingHeight = options.estimatedHeadingHeight ?? null;
this.loaderHeight = options.loaderHeight ?? null;
this.estimatedRowHeight = options?.estimatedRowSize ?? options?.estimatedRowHeight ?? null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did we want to change all the internal variables to size as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

o, i think that's what you were saying here #9843 (comment)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, thats right. I might try and do it to see how bad it is

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, when working on this I was kind of unsure whether to use "size" here, since that typically refers to a 2-dimensional value in the context of our virtualizer package. I think it's fine, but wanted to share it for consideration - naming is hard 😅

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha yeah, I had a similar thought but couldn't think up of a better alternative either. I'll see about pushing up the full changes and then see if we can land on a better name

grid-template-columns: auto;
align-items: center;

&[data-orientation=horizontal] {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need this in the tailwind starter as well

selectionMode="multiple"
items={items}
style={{display: 'block', padding: 0, height: 100}}>
{(item) => <ListBoxItem style={{height: '100%'}}>{item.name}</ListBoxItem>}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add some styles to the items so that it's clear where one ends and the next begins. Right now it just looks like a long string of text with some random break in it.

It'd also be nice if this was an example I'd want to use, so if we can make them basically more like cards with a title and description, that'd be better

### List

`ListLayout` supports layout of items in a vertical stack. Rows can be fixed or variable height. When using variable heights, set the `estimatedRowHeight` to a reasonable guess for how tall the rows will be on average. This allows the size of the scrollbar to be calculated.
`ListLayout` places items along its orientation. Rows can be fixed or variable size. When using variable size, set the `estimatedRowSize` to a reasonable guess for how tall or wide the rows will be on average. This allows the size of the scrollbar to be calculated.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`ListLayout` places items along its orientation. Rows can be fixed or variable size. When using variable size, set the `estimatedRowSize` to a reasonable guess for how tall or wide the rows will be on average. This allows the size of the scrollbar to be calculated.
`ListLayout` places items along its orientation. Rows can be fixed or variable in size. When using a variable size, set the `estimatedRowSize` to a reasonable guess for how tall or wide the rows will be on average. This allows the size of the scrollbar to be calculated.

@rspbot
Copy link

rspbot commented Mar 26, 2026


Use the `orientation` option to arrange items horizontally or vertically. Provide the same `orientation` on the collection component so keyboard navigation matches the layout.

```tsx render docs={docs.exports.ListLayoutOptions} links={docs.links} props={['gap', 'padding']} initialProps={{estimatedRowSize: 300, gap: 8, padding: 8, orientation: 'horizontal'}} propsObject="layoutOptions" wide
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any chance we make the images a tad bit smaller

@rspbot
Copy link

rspbot commented Mar 26, 2026

@rspbot
Copy link

rspbot commented Mar 26, 2026

## API Changes

react-aria-components

/react-aria-components:TableLayout

 TableLayout <O extends TableLayoutProps = TableLayoutProps, T> {
-  constructor: (ListLayoutOptions) => void
+  constructor: (TableLayoutProps) => void
   getContentSize: () => Size
   getDropTargetFromPoint: (number, number, (DropTarget) => boolean) => DropTarget | null
   getDropTargetLayoutInfo: (ItemDropTarget) => LayoutInfo
   getLayoutInfo: (Key) => LayoutInfo | null
   shouldInvalidate: (Rect, Rect) => boolean
   shouldInvalidateLayoutOptions: (TableLayoutProps, TableLayoutProps) => boolean
   update: (InvalidationContext<TableLayoutProps>) => void
   updateItemSize: (Key, Size) => boolean
   useLayoutOptions: () => TableLayoutProps
   virtualizer: Virtualizer<{}, any> | null
 }

/react-aria-components:ListLayoutOptions

 ListLayoutOptions {
   dropIndicatorThickness?: number = 2
-  estimatedHeadingHeight?: number
-  estimatedRowHeight?: number
+  estimatedHeadingSize?: number
+  estimatedRowSize?: number
   gap?: number = 0
-  headingHeight?: number = 48
-  loaderHeight?: number = 48
+  headingSize?: number = 48
+  loaderSize?: number = 48
   orientation?: Orientation = 'vertical'
   padding?: number = 0
-  rowHeight?: number = 48
+  rowSize?: number = 48
 }

/react-aria-components:TableLayoutProps

+TableLayoutProps {
+  columnWidths?: Map<Key, number>
+  dropIndicatorThickness?: number = 2
+  estimatedHeadingHeight?: number
+  estimatedRowHeight?: number
+  gap?: number = 0
+  headingHeight?: number = 48
+  loaderHeight?: number = 48
+  padding?: number = 0
+  rowHeight?: number = 48
+}

@internationalized/date

/@internationalized/date:DateValue

-DateValue {
-  D: undefined
-}

@react-spectrum/s2

/@react-spectrum/s2:ListView

 ListView <T extends {}> {
   UNSAFE_className?: UnsafeClassName
   UNSAFE_style?: CSSProperties
   aria-describedby?: string
   aria-details?: string
   aria-label?: string
   aria-labelledby?: string
   autoFocus?: boolean | FocusStrategy
   children: ReactNode | ({}) => ReactNode
   defaultSelectedKeys?: 'all' | Iterable<Key>
   dependencies?: ReadonlyArray<any>
   disabledBehavior?: DisabledBehavior = "all"
   disabledKeys?: Iterable<Key>
   disallowEmptySelection?: boolean
   disallowTypeAhead?: boolean = false
   escapeKeyBehavior?: 'clearSelection' | 'none' = 'clearSelection'
   hideLinkOutIcon?: boolean
   id?: string
   isQuiet?: boolean
   items?: Iterable<T>
   loadingState?: LoadingState
   onAction?: (Key) => void
   onLoadMore?: () => void
   onSelectionChange?: (Selection) => void
-  orientation?: Orientation = 'vertical'
   overflowMode?: 'wrap' | 'truncate' = 'truncate'
   renderActionBar?: ('all' | Set<Key>) => ReactElement
   renderEmptyState?: (GridListRenderProps) => ReactNode
   selectedKeys?: 'all' | Iterable<Key>
   selectionStyle?: 'highlight' | 'checkbox' = 'checkbox'
   shouldSelectOnPressUp?: boolean
   slot?: string | null
   styles?: StylesPropWithHeight
 }

/@react-spectrum/s2:ListViewProps

 ListViewProps <T> {
   UNSAFE_className?: UnsafeClassName
   UNSAFE_style?: CSSProperties
   aria-describedby?: string
   aria-details?: string
   aria-label?: string
   aria-labelledby?: string
   autoFocus?: boolean | FocusStrategy
   children: ReactNode | (T) => ReactNode
   defaultSelectedKeys?: 'all' | Iterable<Key>
   dependencies?: ReadonlyArray<any>
   disabledBehavior?: DisabledBehavior = "all"
   disabledKeys?: Iterable<Key>
   disallowEmptySelection?: boolean
   disallowTypeAhead?: boolean = false
   escapeKeyBehavior?: 'clearSelection' | 'none' = 'clearSelection'
   hideLinkOutIcon?: boolean
   id?: string
   isQuiet?: boolean
   items?: Iterable<T>
   loadingState?: LoadingState
   onAction?: (Key) => void
   onLoadMore?: () => void
   onSelectionChange?: (Selection) => void
-  orientation?: Orientation = 'vertical'
   overflowMode?: 'wrap' | 'truncate' = 'truncate'
   renderActionBar?: ('all' | Set<Key>) => ReactElement
   renderEmptyState?: (GridListRenderProps) => ReactNode
   selectedKeys?: 'all' | Iterable<Key>
   selectionStyle?: 'highlight' | 'checkbox' = 'checkbox'
   shouldSelectOnPressUp?: boolean
   slot?: string | null
   styles?: StylesPropWithHeight
 }

@react-spectrum/toast

/@react-spectrum/toast:CloseFunction

-CloseFunction {
-  C: undefined
-}

@react-stately/data

/@react-stately/data:AsyncListLoadFunction

-AsyncListLoadFunction {
-  A: undefined
-}

/@react-stately/data:AsyncListLoadOptions

-AsyncListLoadOptions <C, T> {
-  cursor?: C
-  filterText?: string
-  items: Array<T>
-  loadingState?: LoadingState
-  selectedKeys: Selection
-  signal: AbortSignal
-  sortDescriptor?: SortDescriptor
-}

/@react-stately/data:AsyncListStateUpdate

-AsyncListStateUpdate <C, T> {
-  cursor?: C
-  filterText?: string
-  items: Iterable<T>
-  selectedKeys?: Iterable<Key>
-  sortDescriptor?: SortDescriptor
-}

@react-stately/layout

/@react-stately/layout:TableLayout

 TableLayout <O extends TableLayoutProps = TableLayoutProps, T> {
-  constructor: (ListLayoutOptions) => void
+  constructor: (TableLayoutProps) => void
   getContentSize: () => Size
   getDropTargetFromPoint: (number, number, (DropTarget) => boolean) => DropTarget | null
   getDropTargetLayoutInfo: (ItemDropTarget) => LayoutInfo
   getLayoutInfo: (Key) => LayoutInfo | null
   shouldInvalidate: (Rect, Rect) => boolean
   shouldInvalidateLayoutOptions: (TableLayoutProps, TableLayoutProps) => boolean
   update: (InvalidationContext<TableLayoutProps>) => void
   updateItemSize: (Key, Size) => boolean
   virtualizer: Virtualizer<{}, any> | null
 }

/@react-stately/layout:ListLayoutOptions

 ListLayoutOptions {
   dropIndicatorThickness?: number = 2
-  estimatedHeadingHeight?: number
-  estimatedRowHeight?: number
+  estimatedHeadingSize?: number
+  estimatedRowSize?: number
   gap?: number = 0
-  headingHeight?: number = 48
-  loaderHeight?: number = 48
+  headingSize?: number = 48
+  loaderSize?: number = 48
   orientation?: Orientation = 'vertical'
   padding?: number = 0
-  rowHeight?: number = 48
+  rowSize?: number = 48
 }

/@react-stately/layout:TableLayoutProps

 TableLayoutProps {
   columnWidths?: Map<Key, number>
   dropIndicatorThickness?: number = 2
   estimatedHeadingHeight?: number
   estimatedRowHeight?: number
   gap?: number = 0
   headingHeight?: number = 48
   loaderHeight?: number = 48
-  orientation?: Orientation = 'vertical'
   padding?: number = 0
   rowHeight?: number = 48
 }

Copy link
Member

@snowystinger snowystinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

smaller images in the cards would be nice, otherwise looks good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants