Skip to content
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "office-ui-fabric-react",
"comment": "Pivot: include className in props to override styles",
"type": "patch"
}
],
"packageName": "office-ui-fabric-react",
"email": "naethell@microsoft.com"
}
12 changes: 7 additions & 5 deletions packages/office-ui-fabric-react/src/components/Pivot/Pivot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export class Pivot extends BaseComponent<IPivotProps, IPivotState> {
return (
<FocusZone direction={ FocusZoneDirection.horizontal }>
<ul
className={ css('ms-Pivot', styles.root,
className={ css('ms-Pivot', styles.root, this.props.className,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is the wrong place to put the className.

It needs to live on the outmost div element. Otherwise the consumer can't make it flexGrow: 1.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See line 94.

I would recommend we use getNativeProps and mix native props into the root div.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

don't want this to go stale. :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes! So sorry about the delay. Just pushed the changes. Let me know what you think.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Working on the merge conflict.

{ ['ms-Pivot--large ' + styles.rootIsLarge]: this.props.linkSize === PivotLinkSize.large },
{ ['ms-Pivot--tabs ' + styles.rootIsTabs]: this.props.linkFormat === PivotLinkFormat.tabs }) }
role='tablist'
Expand All @@ -117,7 +117,7 @@ export class Pivot extends BaseComponent<IPivotProps, IPivotState> {
}

private _renderPivotLink = (link: IPivotItemProps): JSX.Element => {
const { itemKey } = link;
const { itemKey, className } = link;
const tabId = this._keyToTabIds[itemKey as string];
const { onRenderItemLink } = link;
let linkContent: JSX.Element | null;
Expand All @@ -137,7 +137,8 @@ export class Pivot extends BaseComponent<IPivotProps, IPivotState> {
styles.link,
{
['is-selected ' + styles.linkIsSelected]: this.state.selectedKey === itemKey
}
},
className
) }
onClick={ this._onLinkClick.bind(this, itemKey) }
onKeyPress={ this._onKeyPress.bind(this, itemKey) }
Expand All @@ -152,10 +153,10 @@ export class Pivot extends BaseComponent<IPivotProps, IPivotState> {
}

private _renderLinkContent = (link: IPivotItemProps): JSX.Element => {
const { itemCount, itemIcon, linkText } = link;
const { itemCount, itemIcon, linkText, className } = link;

return (
<span className={ css('ms-Pivot-link-content') }>
<span className={ css('ms-Pivot-link-content', className) }>
{ itemIcon !== undefined && (
<span className={ css('ms-Pivot-icon', styles.icon) }>
<Icon iconName={ itemIcon } />
Expand Down Expand Up @@ -206,6 +207,7 @@ export class Pivot extends BaseComponent<IPivotProps, IPivotState> {
links.push({
linkText: pivotItem.props.linkText,
ariaLabel: pivotItem.props.ariaLabel,
className: pivotItem.props.className,
itemKey: itemKey,
itemCount: pivotItem.props.itemCount,
itemIcon: pivotItem.props.itemIcon,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ export interface IPivotProps extends React.Props<Pivot> {
*/
initialSelectedIndex?: number;

/**
* Optional root classname for the root pivot element.
*/
className?: string;

/**
* The key of the pivot item initially selected.
*
Expand Down