MCPcopy Index your code
hub / github.com/adobe/react-spectrum / TableColumnHeader

Function TableColumnHeader

packages/react-aria/stories/table/example.tsx:131–160  ·  view source on GitHub ↗
({column, state}: {column: any; state: any})

Source from the content-addressed store, hash-verified

129}
130
131export function TableColumnHeader({column, state}: {column: any; state: any}): JSX.Element {
132 let ref = useRef<HTMLTableCellElement | null>(null);
133 let {columnHeaderProps} = useTableColumnHeader({node: column}, state, ref);
134 let {isFocusVisible, focusProps} = useFocusRing();
135 let arrowIcon = state.sortDescriptor?.direction === 'ascending' ? '▲' : '▼';
136
137 return (
138 <th
139 {...mergeProps(columnHeaderProps, focusProps)}
140 style={{
141 textAlign: column.colSpan > 1 ? 'center' : 'left',
142 padding: '5px 10px',
143 outline: isFocusVisible ? '2px solid orange' : 'none',
144 cursor: 'default'
145 }}
146 ref={ref}>
147 {column.rendered}
148 {column.props.allowsSorting && (
149 <span
150 aria-hidden="true"
151 style={{
152 padding: '0 2px',
153 visibility: state.sortDescriptor?.column === column.key ? 'visible' : 'hidden'
154 }}>
155 {arrowIcon}
156 </span>
157 )}
158 </th>
159 );
160}
161
162export function TableRow({
163 item,

Callers

nothing calls this directly

Calls 3

useTableColumnHeaderFunction · 0.90
useFocusRingFunction · 0.90
mergePropsFunction · 0.90

Tested by

no test coverage detected