DetailsList Fluent UI #28103
-
I followed https://developer.microsoft.com/en-us/fluentui#/controls/web/detailslist/compact to display details list. Is it possible to update the highlighted one: to: |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
Hi, @spmonahan, coukd you please add your input on that discussion? |
Beta Was this translation helpful? Give feedback.
-
Looks like you need to use const onRenderCheck = ({ isSelected }: { isSelected: boolean }) => {
return (
<span
key="check"
role="checkbox"
aria-label={'some-aria-label'}
data-selection-toggle={true}
aria-checked={isSelected}
>
<input type="checkbox" />
</span>
);
}; And then use it in the DataList: <DetailsList
onRenderCheckbox={onRenderCheck}
compact={true}
items={items}
columns={this._columns}
setKey="set"
layoutMode={DetailsListLayoutMode.justified}
selection={this._selection}
selectionPreservedOnEmptyClick={true}
onItemInvoked={this._onItemInvoked}
ariaLabelForSelectionColumn="Toggle selection"
ariaLabelForSelectAllCheckbox="Toggle selection for all items"
checkButtonAriaLabel="select row"
/> Example on codepen: |
Beta Was this translation helpful? Give feedback.
-
@ValentinaKozlova, @spmonahan
My Dom look like below: I'm rendering the customCheckBoxes like below
Note: above Checkbox is imported from Please let me know how to overcome this issue. Thanks! |
Beta Was this translation helpful? Give feedback.
-
Adding this as a separate answer for ease. @ValentinaKozlova's suggestion is essentially correct, except that the rendered UI inside of To render a custom icon instead of our default check icon, do the following: private _onRenderCheckbox = ({ checked }) => {
return <span className="your-custom-class">{checked ? '✅' : '⬜️'}</span>;
}
return (
<DetailsList
items={items}
columns={this._columns}
{...etc.}
onRenderCheckbox={this._onRenderCheckbox}
/>
); |
Beta Was this translation helpful? Give feedback.
Looks like you need to use
onRenderCheckbox
prop.Here's the example:
And then use it in the DataList: