Back to Fluentui

Button Migration

apps/public-docsite-v9/src/Concepts/Migration/FromV8/Components/Button.mdx

4.40.2-hotfix24.7 KB
Original Source

import { Meta } from '@storybook/addon-docs/blocks';

<Meta title="Concepts/Migration/from v8/Components/Button Migration" />

Button Migration

The v8 button variants share the IButtonProps. When using ButtonBase the resulting variant is rendered based on the buttonType (normal, primary, hero, compound, command, icon, or default) and when using a variant directly then props like primary and split change how the button is rendered.

In v9, there is not a shared button type. Variants have their own props although they may extend ButtonProps. There are not variants for primary and action buttons. This is controlled through the appearance prop.

To migrate a button replace the v8 usage with the corresponding v9 button variant. Use the property mapping to pass the right properties to the v9 button.

Button Variant Mapping

v8 Button variantv9 Button variant
DefaultButtonButton
ActionButtonButton appearance="transparent"
CommandButtonButton
CommandBarButtonButton
CompoundButtonCompoundButton
ContextualMenuButtonMenu / MenuButton
PrimaryButtonButton appearance="primary"
Button splitSplitButton
Button toggleToggleButton

Button Props Mapping

v8 IButtonPropsv9 ButtonProps (replacements)
allowDisabledFocusdisabledFocusable
ariaLabelHTML aria-label
ariaDescription(removed)
ariaHiddenHTML aria-hidden
checked(use ToggleButton checked)
classNameclassName
childrenchildren
componentRefref
data(removed)
defaultRender(removed)
disableddisabled
getClassNames
getSplitButtonClassNames(use SplitButton)
href(use Link)
iconPropsicon (slot)
disableddisabled
keykey
keyTipProps
menuAs(use Menu and HTML as)
menuIconProps(use MenuButton menuIcon slot)
menuProps(use Menu and MenuButton)
menuTriggerKeyCode
onMenuClickHTML onClick
onRenderAriaDescription(removed)
onRenderChildrenchildren
onRenderDescription(use CompoundButton secondaryContent slot)
onRenderIconicon (slot)
onRenderMenuIcon(use MenuButton icon)
onRenderTextchildren
persistMenu(use Menu)
primaryappearance=primary
primaryActionButtonProps(use SplitButton)
primaryDisabled(use SplitButton)
secondaryText(use CompoundButton secondaryContent)
split(use SplitButton)
splitButtonAriaLabelHTML aria-label
splitButtonMenuProps(use Menu and SplitButton)
styles(use makeStyles and className)
textchildren
theme(use FluentProvider)
toggle(use ToggleButton)
uniqueIdHTML key