You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TableView supports resizable columns, allowing users to dynamically adjust the width of a column. To designate that a Column is resizable, provide it with the `allowsResizing` prop. This will render a draggable
566
+
resizer handle for each resizable column that becomes visible on hover. Keyboard, touch, and screen reader users can enter "resize" mode by interacting with the target column's header and selecting the "Resize column" option
567
+
from the dropdown.
568
+
569
+
### Width values
570
+
571
+
Columns support four different width props: `defaultWidth`, `width`, `minWidth`, and `maxWidth`. Each of these props accepts fixed values or percentages, with `width` and `defaultWidth` accepting fractional (`fr`) units as well.
572
+
Providing a `width` to a Column sets its width to the value provided to it, making it unaffected by any changes to other columns' widths unless a fractional value is provided. Providing a `defaultWidth` allows you
573
+
to specify a Column's initial width, but allows the column width to freely shrink and grow in response to changes in other columns' widths. `minWidth` and `maxWidth` allows you to restrict a Column's width to a minimum and
574
+
maximum value respectively. In general, TableView prioritizes columns with defined widths and divides the remaining space evenly amongst the other columns.
575
+
576
+
### Resize events
577
+
578
+
TableView accepts an `onResize` prop which is triggered whenever a column resizer is moved by the user. This can be used in combination with the `width` prop to update a Column's in a controlled fashion. TableView also accepts
579
+
an `onResizeEnd` prop as well, triggered when the user finishes a column resize operation. Both events receive a Map object containing the widths of every column.
580
+
581
+
The example below illustrates how each of the applied column width properties affects their resize behavior. It also demonstrates the difference between when `onResize` and `onResizeEnd` fires and the values
582
+
provided to both.
583
+
584
+
TODO: fix types for width props
585
+
```tsx example
586
+
function ResizableTable() {
587
+
let [widths, setWidths] =React.useState(newMap());
588
+
let [finalWidths, setFinalWidths] =React.useState(newMap());
589
+
// TODO: fix bug where null is returned when just clicking the column header
590
+
591
+
return (
592
+
<Flexdirection="column">
593
+
<TableViewaria-label="TableView with resizable columns"width={600}height={200}onResize={setWidths}onResizeEnd={setFinalWidths}>
Columns support three different width props: `minWidth`, `width`, and `maxWidth`. Each of these props accepts fixed values or percentages. TableView prioritizes columns with defined widths and divides the remaining space evenly amongst the other columns.
647
-
648
-
```tsx example
649
-
<TableViewaria-label="Example table for column widths">
0 commit comments