Column header
Allow users to understand information in each table column and optionally sort column data for easier data discovery
#Examples
#Basic usage
The basic variant displays the column label in a concise and easily readable manner.
Use cases:
- When the column's content is readily apparent from its label (e.g., "Name," "Date,").
- When sorting or additional information is not required.
Table header
<ColumnHeader content="Table header" />
#Usage with tooltip
A variant with a tooltip provides supplemental information about the column's data. The tooltip appears on hover or focus.
Use cases:
- When the column label needs clarification or additional context.
- When explaining abbreviations or specialized terminology.
<ColumnHeader content="Table header" tooltip="Some extra info about the column" />
#Usage with sorting
A sortable variant allows users to sort table data in ascending or descending order by clicking on the header. Visual indicators (arrows) signify the current sorting state.
Use cases:
- When users need to quickly organize and analyze table data.
- When presenting large datasets that require flexible sorting options.
const [direction, setDirection] = useState<"asc" | "desc">("asc");
const currentSort = { property: "property-name", direction: direction };
return (
<ColumnHeader
content="Sortable header"
sort={currentSort}
onSort={() => setDirection(direction === "asc" ? "desc" : "asc")}
property="property-name"
/>
);
#Properties
Header
Property | Description | Defined | Value |
---|---|---|---|
contentRequired | string Content of the header cell | ||
propertyRequired | string Sortable property | ||
tooltipOptional | | string | object Tooltip to explain the column | ||
sortOptional | | object Property and direction the table is currently sorted by | ||
onSortOptional | function Callback for when a sort button is clicked | ||
defaultSortDirectionOptional | "asc" | "desc" Default direction for sorting the property | ||
data-observe-keyOptional | string Unique string, used by external script e.g. for event tracking | ||
classNameOptional | string Custom className that's applied to the outermost element (only intended for special cases) | ||
styleOptional | object Style object to apply custom inline styles (only intended for special cases) | ||
tabIndexOptional | number Tab index of the outermost HTML element of the component | ||
onKeyDownOptional | function Callback for onKeyDown event | ||
onMouseDownOptional | function Callback for onMouseDown event | ||
onMouseEnterOptional | function Callback for onMouseEnter event | ||
onMouseLeaveOptional | function Callback for onMouseLeave event | ||
onFocusOptional | function Callback for onFocus event | ||
onBlurOptional | function Callback for onBlur event |
#Guidelines
#Best practices
#Do not use when
#Accessibility
Explore detailed guidelines for this component: Accessibility Specifications