Toolbar
View .mdA toolbar gives access to frequently used actions related to someone’s current view or task, like text formatting in an editor.
Default
Loading interactive example. Full source is available below.
View example source
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import type { ToolbarProps } from "@coreai-ds/react-components";
import type { JSXElement } from "@coreai-ds/react-components";
import { Toolbar } from "@coreai-ds/react-components";
import { ToolbarButton } from "@coreai-ds/react-components";
import { FontIncrease24Regular } from "@fluentui/react-icons";
import { FontDecrease24Regular } from "@fluentui/react-icons";
import { TextFont24Regular } from "@fluentui/react-icons";
import { ToolbarDivider } from "@coreai-ds/react-components";
import { Menu } from "@coreai-ds/react-components";
import { MenuTrigger } from "@coreai-ds/react-components";
import { MoreHorizontal24Filled } from "@fluentui/react-icons";
import { MenuPopover } from "@coreai-ds/react-components";
import { MenuList } from "@coreai-ds/react-components";
import { MenuItem } from "@coreai-ds/react-components";
import * as React from 'react';
export const Default = (props: Partial<ToolbarProps>): JSXElement => (<Toolbar aria-label="Default" {...props}>
<ToolbarButton aria-label="Increase Font Size" appearance="primary" icon={<FontIncrease24Regular />}/>
<ToolbarButton aria-label="Decrease Font Size" icon={<FontDecrease24Regular />}/>
<ToolbarButton aria-label="Reset Font Size" icon={<TextFont24Regular />}/>
<ToolbarDivider />
<Menu>
<MenuTrigger>
<ToolbarButton aria-label="More" icon={<MoreHorizontal24Filled />}/>
</MenuTrigger>
<MenuPopover>
<MenuList>
<MenuItem>New </MenuItem>
<MenuItem>New Window</MenuItem>
<MenuItem disabled>Open File</MenuItem>
<MenuItem>Open Folder</MenuItem>
</MenuList>
</MenuPopover>
</Menu>
</Toolbar>);
export default Default;
Resources
Best practices
Do
- Group related actions with dividers and white space.
- Give each toolbar an accessible label when an app contains multiple toolbars.
- Provide icon-only buttons with tooltip text and an accessible label.
Don't
- Place destructive or status-changing actions among unrelated options.
- Use icons that force people to guess their meaning.
- Add end punctuation to toolbar button or tooltip labels.
Behavior and states
- A toolbar grows to fit its parent container but never wraps to a second line.
- Use an overflow menu when all options don’t fit.
- Group related actions with dividers and white space.
- Separate destructive or status-changing actions from other options.
API referenceGenerated CoreAI prop and type summaries
API
Generated CoreAI prop summaries, not replacement type declarations. Most native DOM/event and ARIA props are omitted. ? means optional; JSDoc shows defaults, deprecations, and conditional requirements. Defaults assume the standard CoreAI provider.
Toolbar API
Toolbar component
interface ToolbarProps {
as?: "div";
/**
* Map of all checked values
*/
checkedValues?: Record<string, string[]>;
children?: any;
className?: string;
/**
* Default values to be checked on mount
*/
defaultCheckedValues?: Record<string, string[]>;
/**
* Callback when checked items change for value with a name
*/
onCheckedValueChange?: ((e: ToolbarCheckedValueChangeEvent, data: ToolbarCheckedValueChangeData) => void);
ref?: Ref<HTMLDivElement>;
/**
* Toolbar can have small or medium size
* @default medium
*/
size?: "small" | "medium" | "large";
style?: CSSProperties;
/**
* Toolbar can be vertical styled
* @default false
*/
vertical?: boolean;
}
ToolbarButton API
ToolbarButton component is a Button to be used inside Toolbar
which will respect toolbar props such as size
interface ToolbarButtonProps {
appearance?: "subtle" | "primary" | "transparent";
as?: "a" | "button";
children?: any;
className?: string;
/**
* A button can show that it cannot be interacted with.
* @default false
*/
disabled?: boolean;
/**
* When set, allows the button to be focusable even when it has been disabled.
* This is used in scenarios where it is important to keep a consistent tab order
* for screen reader and keyboard users. The primary example of this
* pattern is when the disabled button is in a menu or a commandbar and is seldom used for standalone buttons.
* When set, allows the button to be focusable even when it has been disabled. This is used in scenarios where it
* is important to keep a consistent tab order for screen reader and keyboard users. The primary example of this
* pattern is when the disabled button is in a menu or a commandbar and is seldom used for standalone buttons.
* @default false
* false
*/
disabledFocusable?: boolean;
/**
* Icon that renders either before or after the `children` as specified by the `iconPosition` prop.
*/
icon?: WithSlotShorthandValue<{ as?: "span"; } & Omit<Omit<DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & { ref?: ((instance: HTMLSpanElement | null) => void) | RefObject<HTMLSpanElement> | null; }, "children"> & { children?: any; }> | null | undefined;
ref?: Ref<HTMLAnchorElement | HTMLButtonElement>;
style?: CSSProperties;
vertical?: boolean;
}
ToolbarDivider API
ToolbarDivider component
interface ToolbarDividerProps {
as?: "div";
children?: any;
className?: string;
ref?: Ref<HTMLDivElement>;
style?: CSSProperties;
/**
* A divider can be horizontal or vertical (default).
* @default true
*/
vertical?: boolean;
/**
* Wrapper for content when presented.
*/
wrapper?: NonNullable<WithSlotShorthandValue<{ as?: "div"; } & Omit<Omit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & { ref?: ((instance: HTMLDivElement | null) => void) | RefObject<HTMLDivElement> | null; }, "children"> & { children?: any; }> | null> | undefined;
}
ToolbarGroup API
ToolbarGroup component is a Button to be used inside Toolbar
which will respect toolbar props such as size
interface ToolbarGroupProps {
as?: "div";
children?: any;
className?: string;
ref?: Ref<HTMLDivElement>;
style?: CSSProperties;
}
ToolbarRadioButton API
ToolbarRadioButton component
interface ToolbarRadioButtonProps {
appearance?: "subtle" | "primary" | "transparent";
as?: "a" | "button";
children?: any;
className?: string;
/**
* A button can show that it cannot be interacted with.
* @default false
*/
disabled?: boolean;
/**
* When set, allows the button to be focusable even when it has been disabled.
* This is used in scenarios where it is important to keep a consistent tab order
* for screen reader and keyboard users. The primary example of this
* pattern is when the disabled button is in a menu or a commandbar and is seldom used for standalone buttons.
* When set, allows the button to be focusable even when it has been disabled. This is used in scenarios where it
* is important to keep a consistent tab order for screen reader and keyboard users. The primary example of this
* pattern is when the disabled button is in a menu or a commandbar and is seldom used for standalone buttons.
* @default false
* false
*/
disabledFocusable?: boolean;
/**
* Icon that renders either before or after the `children` as specified by the `iconPosition` prop.
*/
icon?: WithSlotShorthandValue<{ as?: "span"; } & Omit<Omit<DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & { ref?: ((instance: HTMLSpanElement | null) => void) | RefObject<HTMLSpanElement> | null; }, "children"> & { children?: any; }> | null | undefined;
name?: string;
ref?: Ref<HTMLAnchorElement | HTMLButtonElement>;
/**
* A button supports different sizes.
* @default 'medium'
*/
size?: "small" | "medium" | "large";
style?: CSSProperties;
value?: string | (readonly string[] & string);
}
ToolbarRadioGroup API
ToolbarRadioGroup component is a Button to be used inside Toolbar
which will respect toolbar props such as size
interface ToolbarRadioGroupProps {
as?: "div";
children?: any;
className?: string;
ref?: Ref<HTMLDivElement>;
style?: CSSProperties;
}
ToolbarToggleButton API
ToolbarToggleButton component
interface ToolbarToggleButtonProps {
appearance?: "subtle" | "primary" | "transparent";
as?: "a" | "button";
children?: any;
className?: string;
/**
* A button can show that it cannot be interacted with.
* @default false
*/
disabled?: boolean;
/**
* When set, allows the button to be focusable even when it has been disabled.
* This is used in scenarios where it is important to keep a consistent tab order
* for screen reader and keyboard users. The primary example of this
* pattern is when the disabled button is in a menu or a commandbar and is seldom used for standalone buttons.
* When set, allows the button to be focusable even when it has been disabled. This is used in scenarios where it
* is important to keep a consistent tab order for screen reader and keyboard users. The primary example of this
* pattern is when the disabled button is in a menu or a commandbar and is seldom used for standalone buttons.
* @default false
* false
*/
disabledFocusable?: boolean;
/**
* Icon that renders either before or after the `children` as specified by the `iconPosition` prop.
*/
icon?: WithSlotShorthandValue<{ as?: "span"; } & Omit<Omit<DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & { ref?: ((instance: HTMLSpanElement | null) => void) | RefObject<HTMLSpanElement> | null; }, "children"> & { children?: any; }> | null | undefined;
name?: string;
ref?: Ref<HTMLAnchorElement | HTMLButtonElement>;
/**
* A button supports different sizes.
* @default 'medium'
*/
size?: "small" | "medium" | "large";
style?: CSSProperties;
value?: string | (readonly string[] & string);
}
Implementation
CoreAI 0.12.0; Fluent 9.74.9.
Import components from @coreai-ds/react-components. CoreAI guidance above takes precedence over API demonstration examples.
Controlled Radio
Loading interactive example. Full source is available below.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import type { ToolbarProps } from "@coreai-ds/react-components";
import type { JSXElement } from "@coreai-ds/react-components";
import * as React from 'react';
import { Toolbar } from "@coreai-ds/react-components";
import { ToolbarRadioGroup } from "@coreai-ds/react-components";
import { ToolbarRadioButton } from "@coreai-ds/react-components";
import { AlignLeft24Regular } from "@fluentui/react-icons";
import { AlignCenterHorizontal24Regular } from "@fluentui/react-icons";
import { AlignRight24Regular } from "@fluentui/react-icons";
export const ControlledRadio = (props: Partial<ToolbarProps>): JSXElement => {
const [checkedValues, setCheckedValues] = React.useState<Record<string, string[]>>({
textOptions: ['center'],
});
const onChange: ToolbarProps['onCheckedValueChange'] = (e, { name, checkedItems }) => {
setCheckedValues(s => {
return s ? { ...s, [name]: checkedItems } : { [name]: checkedItems };
});
};
return (<Toolbar aria-label="with controlled Radio Button" checkedValues={checkedValues} onCheckedValueChange={onChange}>
<ToolbarRadioGroup>
<ToolbarRadioButton aria-label="Align left" name="textOptions" value="left" icon={<AlignLeft24Regular />}/>
<ToolbarRadioButton aria-label="Align Center" name="textOptions" value="center" icon={<AlignCenterHorizontal24Regular />}/>
<ToolbarRadioButton aria-label="Align Right" name="textOptions" value="right" icon={<AlignRight24Regular />}/>
</ToolbarRadioGroup>
</Toolbar>);
};
export default ControlledRadio;
Controlled Toggle Button
Loading interactive example. Full source is available below.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import type { JSXElement } from "@coreai-ds/react-components";
import * as React from 'react';
import type { ToolbarProps } from "@coreai-ds/react-components";
import { Toolbar } from "@coreai-ds/react-components";
import { ToolbarToggleButton } from "@coreai-ds/react-components";
import { TextBold24Regular } from "@fluentui/react-icons";
import { TextItalic24Regular } from "@fluentui/react-icons";
import { TextUnderline24Regular } from "@fluentui/react-icons";
export const ControlledToggleButton = (): JSXElement => {
const [checkedValues, setCheckedValues] = React.useState<Record<string, string[]>>({
textOptions: ['bold', 'italic'],
});
const onChange: ToolbarProps['onCheckedValueChange'] = (e, { name, checkedItems }) => {
setCheckedValues(s => {
return s ? { ...s, [name]: checkedItems } : { [name]: checkedItems };
});
};
return (<Toolbar aria-label="with controlled Toggle Button" checkedValues={checkedValues} onCheckedValueChange={onChange}>
<ToolbarToggleButton aria-label="Bold" icon={<TextBold24Regular />} name="textOptions" value="bold"/>
<ToolbarToggleButton aria-label="Italic" icon={<TextItalic24Regular />} name="textOptions" value="italic"/>
<ToolbarToggleButton aria-label="Underline" icon={<TextUnderline24Regular />} name="textOptions" value="underline"/>
</Toolbar>);
};
export default ControlledToggleButton;
Far Group
Loading interactive example. Full source is available below.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import type { ToolbarProps } from "@coreai-ds/react-components";
import type { JSXElement } from "@coreai-ds/react-components";
import { makeStyles } from "@coreai-ds/react-components";
import { Toolbar } from "@coreai-ds/react-components";
import { ToolbarGroup } from "@coreai-ds/react-components";
import { ToolbarButton } from "@coreai-ds/react-components";
import { FontIncreaseRegular } from "@fluentui/react-icons";
import { FontDecreaseRegular } from "@fluentui/react-icons";
import { TextFontRegular } from "@fluentui/react-icons";
import { ToolbarDivider } from "@coreai-ds/react-components";
import * as React from 'react';
const useStyles = makeStyles({
toolbar: {
justifyContent: 'space-between',
},
});
export const FarGroup = (props: Partial<ToolbarProps>): JSXElement => {
const farGroupStyles = useStyles();
return (<Toolbar aria-label="with Separeted Groups" {...props} className={farGroupStyles.toolbar}>
<ToolbarGroup role="presentation">
<ToolbarButton aria-label="Increase Font Size" appearance="primary" icon={<FontIncreaseRegular />}/>
<ToolbarButton aria-label="Decrease Font Size" icon={<FontDecreaseRegular />}/>
<ToolbarButton aria-label="Reset Font Size" icon={<TextFontRegular />}/>
<ToolbarDivider />
<ToolbarButton aria-label="Increase Font Size" appearance="primary" icon={<FontIncreaseRegular />}/>
<ToolbarButton aria-label="Decrease Font Size" icon={<FontDecreaseRegular />}/>
<ToolbarButton aria-label="Reset Font Size" icon={<TextFontRegular />}/>
</ToolbarGroup>
<ToolbarGroup role="presentation">
<ToolbarButton aria-label="Increase Font Size" appearance="primary" icon={<FontIncreaseRegular />}/>
<ToolbarButton aria-label="Decrease Font Size" icon={<FontDecreaseRegular />}/>
<ToolbarButton aria-label="Reset Font Size" icon={<TextFontRegular />}/>
</ToolbarGroup>
</Toolbar>);
};
export default FarGroup;
Large
Loading interactive example. Full source is available below.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import type { ToolbarProps } from "@coreai-ds/react-components";
import type { JSXElement } from "@coreai-ds/react-components";
import { Toolbar } from "@coreai-ds/react-components";
import { ToolbarButton } from "@coreai-ds/react-components";
import { FontIncrease24Regular } from "@fluentui/react-icons";
import { FontDecrease24Regular } from "@fluentui/react-icons";
import { TextFont24Regular } from "@fluentui/react-icons";
import * as React from 'react';
export const Large = (props: Partial<ToolbarProps>): JSXElement => (<Toolbar aria-label="Large Toolbar" {...props} size="large" style={{
border: '2px solid black',
borderRadius: '8px',
}}>
<ToolbarButton aria-label="Increase Font Size" appearance="primary" icon={<FontIncrease24Regular />}/>
<ToolbarButton aria-label="Decrease Font Size" icon={<FontDecrease24Regular />}/>
<ToolbarButton aria-label="Reset Font Size" icon={<TextFont24Regular />}/>
</Toolbar>);
export default Large;
Medium
Loading interactive example. Full source is available below.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import type { ToolbarProps } from "@coreai-ds/react-components";
import type { JSXElement } from "@coreai-ds/react-components";
import { Toolbar } from "@coreai-ds/react-components";
import { ToolbarButton } from "@coreai-ds/react-components";
import { FontIncrease24Regular } from "@fluentui/react-icons";
import { FontDecrease24Regular } from "@fluentui/react-icons";
import { TextFont24Regular } from "@fluentui/react-icons";
import * as React from 'react';
export const Medium = (props: Partial<ToolbarProps>): JSXElement => (<Toolbar {...props} aria-label="Medium" size="medium" style={{
border: '2px solid black',
borderRadius: '8px',
}}>
<ToolbarButton aria-label="Increase Font Size" appearance="primary" icon={<FontIncrease24Regular />}/>
<ToolbarButton aria-label="Decrease Font Size" icon={<FontDecrease24Regular />}/>
<ToolbarButton aria-label="Reset Font Size" icon={<TextFont24Regular />}/>
</Toolbar>);
export default Medium;
Overflow Items
Loading interactive example. Full source is available below.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import type { ToolbarProps } from "@coreai-ds/react-components";
import type { JSXElement } from "@coreai-ds/react-components";
import { Overflow } from "@coreai-ds/react-components";
import { Toolbar } from "@coreai-ds/react-components";
import type { ToolbarButtonProps } from "@coreai-ds/react-components";
import { OverflowItem } from "@coreai-ds/react-components";
import { ToolbarButton } from "@coreai-ds/react-components";
import { FontIncrease24Regular } from "@fluentui/react-icons";
import { FontDecrease24Regular } from "@fluentui/react-icons";
import { useIsOverflowGroupVisible } from "@coreai-ds/react-components";
import { ToolbarDivider } from "@coreai-ds/react-components";
import { TextFont24Regular } from "@fluentui/react-icons";
import * as React from 'react';
import { useOverflowMenu } from "@coreai-ds/react-components";
import { Menu } from "@coreai-ds/react-components";
import { MenuTrigger } from "@coreai-ds/react-components";
import { Button } from "@coreai-ds/react-components";
import { MoreHorizontal20Filled } from "@fluentui/react-icons";
import { MenuPopover } from "@coreai-ds/react-components";
import { MenuList } from "@coreai-ds/react-components";
import type { MenuItemProps } from "@coreai-ds/react-components";
import { useIsOverflowItemVisible } from "@coreai-ds/react-components";
import { MenuItem } from "@coreai-ds/react-components";
import { MenuDivider } from "@coreai-ds/react-components";
type ToolbarOverflowMenuProps = {
overflowId: string;
overflowGroupId: string;
} & ToolbarButtonProps;
const ToolbarOverflowButton = ({ overflowId, overflowGroupId, ...props }: ToolbarOverflowMenuProps) => {
return (<OverflowItem id={overflowId} groupId={overflowGroupId}>
<ToolbarButton {...props}/>
</OverflowItem>);
};
type ToolbarOverflowDividerProps = {
groupId: string;
};
const ToolbarOverflowDivider = ({ groupId }: ToolbarOverflowDividerProps) => {
const groupVisibleState = useIsOverflowGroupVisible(groupId);
if (groupVisibleState !== 'hidden') {
return <ToolbarDivider />;
}
return null;
};
interface ToolbarOverflowMenuItemProps extends Omit<MenuItemProps, 'id'> {
id: string;
}
const ToolbarOverflowMenuItem: React.FC<ToolbarOverflowMenuItemProps> = props => {
const { id, ...rest } = props;
const isVisible = useIsOverflowItemVisible(id);
if (isVisible) {
return null;
}
if (id.includes('increase')) {
return <MenuItem icon={<FontIncrease24Regular />}>Increase Font Size</MenuItem>;
}
if (id.includes('decrease')) {
return <MenuItem icon={<FontDecrease24Regular />}>Decrease Font Size</MenuItem>;
}
if (id.includes('reset')) {
return <MenuItem icon={<TextFont24Regular />}>Reset Font Size</MenuItem>;
}
return <MenuItem {...(rest as MenuItemProps)}>Item {id}</MenuItem>;
};
const ToolbarMenuOverflowDivider: React.FC<{
id: string;
}> = props => {
const isGroupVisible = useIsOverflowGroupVisible(props.id);
if (isGroupVisible === 'visible') {
return null;
}
return <MenuDivider />;
};
const OverflowMenu: React.FC<{
itemIds: Array<Array<string>>;
}> = ({ itemIds }) => {
const { ref, isOverflowing } = useOverflowMenu<HTMLButtonElement>();
if (!isOverflowing) {
return null;
}
return (<Menu>
<MenuTrigger disableButtonEnhancement>
<Button ref={ref} icon={<MoreHorizontal20Filled />} aria-label="More items" appearance="subtle"/>
</MenuTrigger>
<MenuPopover>
<MenuList>
{itemIds.map((group, groupIndx) => {
const isLast = groupIndx === itemIds.length - 1;
return (<React.Fragment key={group.join()}>
{group.map(i => (<ToolbarOverflowMenuItem key={i} id={i}/>))}
{!isLast && <ToolbarMenuOverflowDivider id={`components-toolbar--overflow-items-${groupIndx + 1}`}/>}
</React.Fragment>);
})}
</MenuList>
</MenuPopover>
</Menu>);
};
export const OverflowItems = (props: Partial<ToolbarProps>): JSXElement => (<div style={{
resize: 'horizontal',
overflow: 'hidden',
}}>
<Overflow padding={90}>
<Toolbar {...props} aria-label="Overflow" size="small">
<ToolbarOverflowButton overflowId="increase-1" overflowGroupId="1" appearance="subtle" aria-label="Increase Font Size ( Group 1 )" icon={<FontIncrease24Regular />}/>
<ToolbarOverflowButton overflowId="decrease-1" overflowGroupId="1" appearance="subtle" aria-label="Decrease Font Size ( Group 1 )" icon={<FontDecrease24Regular />}/>
<ToolbarOverflowDivider groupId="1"/>
<ToolbarOverflowButton overflowId="increase-2" overflowGroupId="2" appearance="subtle" aria-label="Increase Font Size ( Group 2 )" icon={<FontIncrease24Regular />}/>
<ToolbarOverflowButton overflowId="decrease-2" overflowGroupId="2" appearance="subtle" aria-label="Decrease Font Size ( Group 2 )" icon={<FontDecrease24Regular />}/>
<ToolbarOverflowButton overflowId="reset-1" overflowGroupId="2" appearance="subtle" aria-label="Reset Font Size ( Group 2 )" icon={<TextFont24Regular />}/>
<ToolbarOverflowButton overflowId="increase-3" overflowGroupId="2" appearance="subtle" aria-label="Increase Font Size ( Group 2 )" icon={<FontIncrease24Regular />}/>
<ToolbarOverflowButton overflowId="decrease-3" overflowGroupId="2" appearance="subtle" aria-label="Decrease Font Size ( Group 2 )" icon={<FontDecrease24Regular />}/>
<ToolbarOverflowDivider groupId="2"/>
<ToolbarOverflowButton overflowId="increase-4" overflowGroupId="3" appearance="subtle" aria-label="Increase Font Size ( Group 3 )" icon={<FontIncrease24Regular />}/>
<ToolbarOverflowButton overflowId="decrease-4" overflowGroupId="3" appearance="subtle" aria-label="Decrease Font Size ( Group 3 )" icon={<FontDecrease24Regular />}/>
<ToolbarOverflowButton overflowId="reset-2" overflowGroupId="3" appearance="subtle" aria-label="Reset Font Size ( Group 3 )" icon={<TextFont24Regular />}/>
<OverflowMenu itemIds={[
['increase-1', 'decrease-1'],
['increase-2', 'decrease-2', 'reset-1', 'increase-3', 'decrease-3'],
['increase-4', 'decrease-4', 'reset-2'],
]}/>
</Toolbar>
</Overflow>
</div>);
export default OverflowItems;
Radio
Loading interactive example. Full source is available below.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import type { ToolbarProps } from "@coreai-ds/react-components";
import type { JSXElement } from "@coreai-ds/react-components";
import { Toolbar } from "@coreai-ds/react-components";
import { ToolbarRadioGroup } from "@coreai-ds/react-components";
import { ToolbarRadioButton } from "@coreai-ds/react-components";
import { AlignLeft24Regular } from "@fluentui/react-icons";
import { AlignCenterHorizontal24Regular } from "@fluentui/react-icons";
import { AlignRight24Regular } from "@fluentui/react-icons";
import * as React from 'react';
export const Radio = (props: Partial<ToolbarProps>): JSXElement => (<Toolbar {...props} aria-label="with Radio Buttons" defaultCheckedValues={{
textOptions: ['center'],
}}>
<ToolbarRadioGroup>
<ToolbarRadioButton aria-label="Align left" name="textOptions" value="left" icon={<AlignLeft24Regular />}/>
<ToolbarRadioButton aria-label="Align Center" name="textOptions" value="center" icon={<AlignCenterHorizontal24Regular />}/>
<ToolbarRadioButton aria-label="Align Right" name="textOptions" value="right" icon={<AlignRight24Regular />}/>
</ToolbarRadioGroup>
</Toolbar>);
export default Radio;
Small
Loading interactive example. Full source is available below.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import type { ToolbarProps } from "@coreai-ds/react-components";
import type { JSXElement } from "@coreai-ds/react-components";
import { Toolbar } from "@coreai-ds/react-components";
import { ToolbarButton } from "@coreai-ds/react-components";
import { FontIncrease24Regular } from "@fluentui/react-icons";
import { FontDecrease24Regular } from "@fluentui/react-icons";
import { TextFont24Regular } from "@fluentui/react-icons";
import * as React from 'react';
export const Small = (props: Partial<ToolbarProps>): JSXElement => (<Toolbar {...props} aria-label="Small" size="small" style={{
border: '2px solid black',
borderRadius: '8px',
}}>
<ToolbarButton aria-label="Increase Font Size" appearance="primary" icon={<FontIncrease24Regular />}/>
<ToolbarButton aria-label="Decrease Font Size" icon={<FontDecrease24Regular />}/>
<ToolbarButton aria-label="Reset Font Size" icon={<TextFont24Regular />}/>
</Toolbar>);
export default Small;
Subtle
Loading interactive example. Full source is available below.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import type { ToolbarProps } from "@coreai-ds/react-components";
import type { JSXElement } from "@coreai-ds/react-components";
import { Toolbar } from "@coreai-ds/react-components";
import { ToolbarToggleButton } from "@coreai-ds/react-components";
import { TextBold24Regular } from "@fluentui/react-icons";
import { TextItalic24Regular } from "@fluentui/react-icons";
import { TextUnderline24Regular } from "@fluentui/react-icons";
import * as React from 'react';
export const Subtle = (props: Partial<ToolbarProps>): JSXElement => (<Toolbar aria-label="Subtle" {...props}>
<ToolbarToggleButton appearance="subtle" aria-label="Bold" icon={<TextBold24Regular />} name="textOptions" value="bold"/>
<ToolbarToggleButton appearance="subtle" aria-label="Italic" icon={<TextItalic24Regular />} name="textOptions" value="italic"/>
<ToolbarToggleButton appearance="subtle" aria-label="Underline" icon={<TextUnderline24Regular />} name="textOptions" value="underline"/>
</Toolbar>);
export default Subtle;
Transparent
Loading interactive example. Full source is available below.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import type { ToolbarProps } from "@coreai-ds/react-components";
import type { JSXElement } from "@coreai-ds/react-components";
import { Toolbar } from "@coreai-ds/react-components";
import { ToolbarToggleButton } from "@coreai-ds/react-components";
import { TextBold24Regular } from "@fluentui/react-icons";
import { TextItalic24Regular } from "@fluentui/react-icons";
import { TextUnderline24Regular } from "@fluentui/react-icons";
import * as React from 'react';
export const Transparent = (props: Partial<ToolbarProps>): JSXElement => (<Toolbar aria-label="transparent" {...props}>
<ToolbarToggleButton appearance="transparent" aria-label="Bold" icon={<TextBold24Regular />} name="textOptions" value="bold"/>
<ToolbarToggleButton appearance="transparent" aria-label="Italic" icon={<TextItalic24Regular />} name="textOptions" value="italic"/>
<ToolbarToggleButton appearance="transparent" aria-label="Underline" icon={<TextUnderline24Regular />} name="textOptions" value="underline"/>
</Toolbar>);
export default Transparent;
Vertical
Loading interactive example. Full source is available below.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import type { ToolbarProps } from "@coreai-ds/react-components";
import type { JSXElement } from "@coreai-ds/react-components";
import { Toolbar } from "@coreai-ds/react-components";
import { ToolbarToggleButton } from "@coreai-ds/react-components";
import { TextBold24Regular } from "@fluentui/react-icons";
import { TextItalic24Regular } from "@fluentui/react-icons";
import { TextUnderline24Regular } from "@fluentui/react-icons";
import * as React from 'react';
export const Vertical = (props: Partial<ToolbarProps>): JSXElement => (<Toolbar vertical {...props} aria-label="Vertical">
<ToolbarToggleButton name="text" value="bold" aria-label="Bold" icon={<TextBold24Regular />}/>
<ToolbarToggleButton name="text" value="italic" aria-label="Italic" icon={<TextItalic24Regular />}/>
<ToolbarToggleButton name="text" value="underline" aria-label="Underline" icon={<TextUnderline24Regular />}/>
</Toolbar>);
export default Vertical;
Vertical Button
Loading interactive example. Full source is available below.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import type { ToolbarProps } from "@coreai-ds/react-components";
import type { JSXElement } from "@coreai-ds/react-components";
import { Toolbar } from "@coreai-ds/react-components";
import { ToolbarButton } from "@coreai-ds/react-components";
import { FontIncreaseRegular } from "@fluentui/react-icons";
import { FontDecreaseRegular } from "@fluentui/react-icons";
import { TextFontRegular } from "@fluentui/react-icons";
import * as React from 'react';
export const VerticalButton = (props: Partial<ToolbarProps>): JSXElement => (<Toolbar aria-label="Vertical Button" {...props}>
<ToolbarButton vertical appearance="primary" icon={<FontIncreaseRegular />}>
Increase
</ToolbarButton>
<ToolbarButton vertical icon={<FontDecreaseRegular />}>
Decrease
</ToolbarButton>
<ToolbarButton vertical icon={<TextFontRegular />}>
Reset
</ToolbarButton>
</Toolbar>);
export default VerticalButton;
With Popover
Loading interactive example. Full source is available below.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import type { ToolbarProps } from "@coreai-ds/react-components";
import type { JSXElement } from "@coreai-ds/react-components";
import * as React from 'react';
import { Toolbar } from "@coreai-ds/react-components";
import { Popover } from "@coreai-ds/react-components";
import { PopoverTrigger } from "@coreai-ds/react-components";
import { ToolbarButton } from "@coreai-ds/react-components";
import { Image24Regular } from "@fluentui/react-icons";
import { PopoverSurface } from "@coreai-ds/react-components";
import { Button } from "@coreai-ds/react-components";
import { Table24Filled } from "@fluentui/react-icons";
import { MathFormatLinear24Regular } from "@fluentui/react-icons";
import { ToolbarDivider } from "@coreai-ds/react-components";
export const WithPopover = (props: Partial<ToolbarProps>): JSXElement => {
const [open, setOpen] = React.useState<'first' | 'second' | 'third' | 'fourth' | undefined>();
return (<Toolbar aria-label="with Popover" {...props} size="small">
<Popover withArrow trapFocus open={open === 'first'} onOpenChange={(_, data) => setOpen(data.open ? 'first' : undefined)}>
<PopoverTrigger disableButtonEnhancement>
<ToolbarButton aria-label="Insert image" icon={<Image24Regular />}/>
</PopoverTrigger>
<PopoverSurface>
<div>
<h3>Insert Image</h3>
<Button onClick={() => setOpen(undefined)}>Close</Button>
</div>
</PopoverSurface>
</Popover>
<Popover withArrow trapFocus open={open === 'second'} onOpenChange={(_, data) => setOpen(data.open ? 'second' : undefined)}>
<PopoverTrigger disableButtonEnhancement>
<ToolbarButton appearance="primary" icon={<Table24Filled />} aria-label="Insert Table"/>
</PopoverTrigger>
<PopoverSurface>
<div>
<h3>Insert Table</h3>
<Button onClick={() => setOpen(undefined)}>Close</Button>
</div>
</PopoverSurface>
</Popover>
<Popover withArrow trapFocus open={open === 'third'} onOpenChange={(_, data) => setOpen(data.open ? 'third' : undefined)}>
<PopoverTrigger disableButtonEnhancement>
<ToolbarButton aria-label="Insert Formula" icon={<MathFormatLinear24Regular />}/>
</PopoverTrigger>
<PopoverSurface>
<div>
<h3>Insert Formula</h3>
<Button onClick={() => setOpen(undefined)}>Close</Button>
</div>
</PopoverSurface>
</Popover>
<ToolbarDivider />
<Popover withArrow trapFocus open={open === 'fourth'} onOpenChange={(_, data) => setOpen(data.open ? 'fourth' : undefined)}>
<PopoverTrigger disableButtonEnhancement>
<ToolbarButton>Quick Actions</ToolbarButton>
</PopoverTrigger>
<PopoverSurface>
<div>
<h3>Quick Actions</h3>
<Button onClick={() => setOpen(undefined)}>Close</Button>
</div>
</PopoverSurface>
</Popover>
</Toolbar>);
};
export default WithPopover;
With Tooltip
Loading interactive example. Full source is available below.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import type { ToolbarProps } from "@coreai-ds/react-components";
import type { JSXElement } from "@coreai-ds/react-components";
import { Toolbar } from "@coreai-ds/react-components";
import { Tooltip } from "@coreai-ds/react-components";
import { ToolbarToggleButton } from "@coreai-ds/react-components";
import { TextBoldRegular } from "@fluentui/react-icons";
import { TextItalicRegular } from "@fluentui/react-icons";
import { TextUnderlineRegular } from "@fluentui/react-icons";
import { ToolbarDivider } from "@coreai-ds/react-components";
import { ToolbarButton } from "@coreai-ds/react-components";
import { HighlightFilled } from "@fluentui/react-icons";
import * as React from 'react';
export const WithTooltip = (props: Partial<ToolbarProps>): JSXElement => (<Toolbar aria-label="with Tooltip" {...props} size="small">
<Tooltip content="Makes selected text Bold" relationship="description" withArrow>
<ToolbarToggleButton aria-label="Bold" icon={<TextBoldRegular />} name="textOptions" value="bold"/>
</Tooltip>
<Tooltip content="Makes selected text Italic" relationship="description" withArrow>
<ToolbarToggleButton aria-label="Italic" icon={<TextItalicRegular />} name="textOptions" value="italic"/>
</Tooltip>
<Tooltip content="Makes selected text Underline" relationship="description" withArrow>
<ToolbarToggleButton aria-label="Underline" icon={<TextUnderlineRegular />} name="textOptions" value="underline"/>
</Tooltip>
<ToolbarDivider />
<Tooltip content="Highlights the selected text" relationship="description" withArrow>
<ToolbarButton aria-label="Highlight" icon={<HighlightFilled />}/>
</Tooltip>
</Toolbar>);
export default WithTooltip;