### Default Input Example
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-input--docs
A basic example of how to render a default input component. This serves as a starting point for most input use cases.
```typescript
import * as React from 'react';
import { Input } from '@fluentui/react-components';
export const DefaultInput = () => ;
```
--------------------------------
### Install Motion Components Preview Package
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fmotion-components-preview-introduction--docs
Install the beta package for motion components. Note that APIs may change before the stable release.
```bash
npm install @fluentui/react-motion-components-preview
```
--------------------------------
### Persona Text Alignment Examples
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-persona--docs
Demonstrates the two text alignment options: 'start' (default) and 'center'. Use 'start' for standard alignment and 'center' for specific layout needs.
```typescript
import { Persona, PresenceBadge } from '@fluentui/react-components';
```
--------------------------------
### Default Textarea Example
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-textarea--docs
A basic example of the default Textarea component.
```jsx
```
--------------------------------
### SwatchPicker Default Example
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-swatchpicker--docs
Demonstrates the basic usage of the SwatchPicker component.
```typescript
import { SwatchPicker } from '@fluentui/react-components';
```
--------------------------------
### PresenceGroup Default Example
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fmotion-apis-presencegroup--docs
Demonstrates the default usage of the PresenceGroup component, showing how to add and remove users.
```javascript
Add user
Remove user
AM
Allan Munger
Available
AB
Amanda Brady
Available
AM
Ashley McCarthy
Available
```
--------------------------------
### Default List Example
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-list--docs
A basic example of a List component displaying a list of items. Native HTML attributes are supported.
```typescript
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { List } from '@fluentui/react';
const items = [
{ key: 'Asia', content: 'Asia' },
{ key: 'Africa', content: 'Africa' },
{ key: 'Europe', content: 'Europe' },
{ key: 'North America', content: 'North America' },
{ key: 'South America', content: 'South America' },
{ key: 'Australia/Oceania', content: 'Australia/Oceania' },
{ key: 'Antarctica', content: 'Antarctica' },
];
ReactDOM.render(, document.getElementById('root'));
```
--------------------------------
### URL Input Example
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-input--docs
Example of a URL input type. Browser-default styling may activate and not match the Fluent design language.
```typescript
import { Input } from '@fluentui/react-components';
```
--------------------------------
### Default Select Example
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-select--docs
Demonstrates a basic Select component with options for color.
```typescript
import * as React from 'react';
import { Select, Option } from '@fluentui/react-components';
export const Default = () => (
);
```
--------------------------------
### Password Input Example
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-input--docs
Example of a password input type. No custom styling is applied for alternative types.
```typescript
import { Input } from '@fluentui/react-components';
```
--------------------------------
### Collapse Component Example
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fmotion-components-preview-collapse--docs
Demonstrates the basic usage of the Collapse component for managing content visibility with expand/collapse motion.
```javascript
import * as React from 'react';
import { Collapse } from '@fluentui/react-motion-components';
export const Default = () => (
Visible
);
```
--------------------------------
### Toolbar with Popover Example
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-toolbar--docs
Illustrates a Toolbar that includes a Popover for displaying contextual actions or information.
```javascript
import * as React from 'react';
import { Toolbar } from '@fluentui/react-components';
export const WithPopover = () => ;
```
--------------------------------
### Textarea with Placeholder
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-textarea--docs
Illustrates how to use a placeholder to guide user input in a Textarea.
```typescript
import { Textarea } from '@fluentui/react-components';
function App() {
return (
<{
{
Textarea
}
}
placeholder="Enter text here..."
/>
);
}
```
--------------------------------
### Default Spinner Example
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-spinner--docs
A basic example of the Spinner component. It shows a default spinner with no label.
```jsx
import * as React from 'react';
import { Spinner } from '@fluentui/react-components';
export const Default = () => ;
```
--------------------------------
### Default Switch Example
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-switch--docs
Demonstrates the basic usage of the Switch component. It renders a switch with a default label and state.
```javascript
import * as React from 'react';
import { Switch } from '@fluentui/react-components';
export const Default = () => (
Default Switch
);
```
--------------------------------
### Toolbar Default Example
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-toolbar--docs
Demonstrates the default usage of the Toolbar component. It serves as a basic container for grouping controls.
```javascript
import * as React from 'react';
import { Toolbar } from '@fluentui/react-components';
export const Default = () => ;
```
--------------------------------
### Image Default Example
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-image--docs
Basic usage of the Image component. Ensure the 'src' prop is provided with the image path.
```javascript
import * as React from "react";
import { Image } from "@fluentui/react-components";
function ImageDefault() {
return (
);
}
export default ImageDefault;
```
--------------------------------
### Default Slider Example
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-slider--docs
A basic example of the Slider component. It demonstrates the default appearance and functionality.
```typescript
import * as React from 'react';
import { Slider } from '@fluentui/react-components';
export const DefaultSlider = () => ;
```
--------------------------------
### Switch Sizes Example
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-switch--docs
Demonstrates how to render the Switch component in different sizes using the `size` property. Available sizes are 'small' and 'medium'.
```javascript
import * as React from 'react';
import { Switch } from '@fluentui/react-components';
export const Size = () => (
Small SwitchMedium Switch
);
```
--------------------------------
### Email Input Example
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-input--docs
Example of an email input type. Note that custom styling for alternative types is not currently applied.
```typescript
import { Input } from '@fluentui/react-components';
```
--------------------------------
### Checkbox Default Example
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-checkbox--docs
Demonstrates the basic usage of the Checkbox component. It shows how to render a simple checkbox with a label.
```jsx
import { Checkbox } from '@fluentui/react-components';
function MyCheckbox() {
return ;
}
```
--------------------------------
### Grouped TagPicker Example
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-tagpicker--docs
An example of a TagPicker component with grouped options.
```typescript
import { TagPicker, TagPickerInput, TagPickerList, TagPickerOption, TagPickerGroup } from '@fluentui/react-components';
{(option: Option) => {option.text}}
{(option: Option) => {option.text}}
```
--------------------------------
### Transparent Toolbar Example
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-toolbar--docs
Shows a Toolbar with a transparent background, suitable for designs where the toolbar should blend with the background.
```javascript
import * as React from 'react';
import { Toolbar } from '@fluentui/react-components';
export const Transparent = () => ;
```
--------------------------------
### Basic Toast Example
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-toast--docs
Demonstrates the basic structure of a Toast with a title, body, and footer, rendered within a Toaster.
```typescript
import { Toaster, ToastTitle, ToastBody, ToastFooter } from '@fluentui/react-components';
{(toast) => (
{toast.title}{toast.body}
{toast.footer && {toast.footer}}
)}
```
--------------------------------
### Slide Component Example
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fmotion-components-preview-slide--docs
Demonstrates the basic usage of the Slide component for managing content presence with slide in/out transitions.
```javascript
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { Slide } from '@fluentui/react-motion-components-preview';
const App = () => {
return (
{state => (
)}
);
};
ReactDOM.render(, document.getElementById('root'));
```
--------------------------------
### Virtualized List with Actionable Items
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-list--docs
Shows how to use `react-window` for virtualizing lists that contain interactive elements. This example demonstrates a virtualized list where items are actionable.
```typescript
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { ListItem, List } from '@fluentui/react';
const items = [
'Afghanistan',
'Albania',
'Algeria',
'Andorra',
'Angola',
'Antigua & Deps',
'Argentina',
'Armenia',
'Australia',
'Austria',
'Azerbaijan',
'Bahamas',
'Bahrain',
'Bangladesh',
'Barbados',
'Belarus',
'Belgium',
'Belize',
'Benin',
'Bhutan',
'Bolivia',
'Bosnia Herzegovina',
];
const App = () => (
{items.map((item, index) => (
{item}
))}
);
ReactDOM.render(, document.getElementById('root'));
```
--------------------------------
### Basic Tooltip Example
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-tooltip--docs
Demonstrates a basic tooltip that appears on hover. The 'content' prop defines the tooltip's text.
```typescript
import * as React from 'react';
import { Tooltip } from '@fluentui/react-components';
export const DefaultTooltip = () => (
);
```
--------------------------------
### Toolbar with Tooltip Example
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-toolbar--docs
Shows a Toolbar integrated with Tooltip for providing additional information on hover for its controls.
```javascript
import * as React from 'react';
import { Toolbar } from '@fluentui/react-components';
export const WithTooltip = () => ;
```
--------------------------------
### Default SearchBox Example
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-searchbox--docs
This snippet shows the basic implementation of a SearchBox component. It is useful for standard search input functionality.
```typescript
import * as React from 'react';
import { SearchBox } from '@fluentui/react';
export const DefaultSearchBox = () => {
return ;
};
```
--------------------------------
### Fade Atom Example
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fmotion-components-preview-atoms--docs
Demonstrates how to use the `fadeAtom` to create an opacity transition. Specify direction, duration, and opacity values.
```typescript
fadeAtom({
direction: 'enter',
duration: 600,
outOpacity: 0,
inOpacity: 1,
})
```
--------------------------------
### Vertical Slider Example
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-slider--docs
Demonstrates how to render a slider in a vertical orientation. The maximum value is positioned at the top.
```javascript
import * as React from 'react';
import { Slider } from '@fluentui/react';
export const VerticalSliderExample: React.FunctionComponent = () => (
);
```
--------------------------------
### Toolbar Small Size Example
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-toolbar--docs
Shows a Toolbar with a 'small' size, which has no vertical padding and uses 4px for horizontal padding around controls.
```javascript
import * as React from 'react';
import { Toolbar } from '@fluentui/react-components';
export const Small = () => ;
```
--------------------------------
### Empty Swatch Example with Selected State
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-swatchpicker--docs
Shows an empty swatch that can be selected, often used for adding new items.
```typescript
import { SwatchPicker, SwatchPickerEmptySwatch } from '@fluentui/react-components';
```
--------------------------------
### Toolbar Medium Size Example
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-toolbar--docs
Illustrates a Toolbar with a 'medium' size, featuring 4px vertical padding and 8px horizontal padding around controls.
```javascript
import * as React from 'react';
import { Toolbar } from '@fluentui/react-components';
export const Medium = () => ;
```
--------------------------------
### Inline Input Example
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-input--docs
Demonstrates rendering an Input component inline with text. It's important to provide an `aria-label` for accessibility when used this way.
```typescript
import * as React from 'react';
import { Input } from '@fluentui/react-components';
export const InlineInput = () => (
This input is within a paragraph of text. Sample inline input{' '}
.
);
```
--------------------------------
### Flat Tree Component Example
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-tree--docs
Demonstrates the use of the FlatTree component for a simplified and efficient tree structure management. Requires specific ARIA properties for each TreeItem.
```typescript
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { FlatTree, FlatTreeItem, TreeItemLayout } from '@fluentui/react-components';
const App = () => {
return (
Item 1, level 1Item 1, level 1
);
};
ReactDOM.render(, document.querySelector('#root'));
```
--------------------------------
### TabList Default Example
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-tablist--docs
Demonstrates the default usage of the TabList component with multiple tabs. Use this for content-heavy pages where users need to switch between different sections.
```typescript
import { TabList, Tab } from '@fluentui/react-components';
First TabSecond TabThird TabFourth Tab
```
--------------------------------
### Create Presence Component
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fmotion-apis-createpresencecomponent--docs
Use createPresenceComponent to build custom motion components. This example shows the basic structure for defining enter and exit motions.
```typescript
import {
createPresenceComponent,
PresenceMotion,
} from "@react-motion/motion";
interface MyFadePresenceProps {
// Define any custom props here
}
const MyFade = createPresenceComponent({
enter: {
// Define enter motion properties
opacity: [0, 1],
scale: [0.8, 1],
},
exit: {
// Define exit motion properties
opacity: [1, 0],
scale: [1, 0.8],
},
});
// Usage:
// ...
```
--------------------------------
### Persona Presence Size Examples
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-persona--docs
Shows the Persona component with different size options. The 'medium' size is the default. Select the appropriate size for your content.
```typescript
import { Persona, PresenceBadge } from '@fluentui/react-components';
```
--------------------------------
### Custom Item Delay for Stagger
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fmotion-choreography-preview-stagger--docs
Control the time between each child's animation start using the 'itemDelay' prop. This example uses a 25ms delay.
```jsx
Hide
Item Delay: 25ms
1
2
3
4
5
6
7
8
Show code
```
--------------------------------
### TagPicker Medium Size
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-tagpicker--docs
Example of TagPicker with 'medium' size (default).
```typescript
import { TagPicker, TagPickerInput, TagPickerList, TagPickerOption } from '@fluentui/react-components';
{(option: Option) => {option.text}}
```
--------------------------------
### Input with Placeholder
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-input--docs
Shows how to use the `placeholder` prop for guiding users. It's recommended to use a label instead of relying solely on a placeholder for usability and accessibility.
```typescript
import * as React from 'react';
import { Input } from '@fluentui/react-components';
export const Placeholder = () => ;
```
--------------------------------
### TagPicker Extra Large Size
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-tagpicker--docs
Example of TagPicker with 'extra-large' size.
```typescript
import { TagPicker, TagPickerInput, TagPickerList, TagPickerOption } from '@fluentui/react-components';
{(option: Option) => {option.text}}
```
--------------------------------
### Toast with Error Intent
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-toast--docs
Provides an example of a toast with an 'error' intent to signal a problem.
```typescript
import { Toaster, ToastTitle, ToastBody, Toast } from '@fluentui/react-components';
import { useToastController } from '@fluentui/react-components';
function MyComponent() {
const { dispatchToast } = useToastController();
return (
);
}
```
--------------------------------
### Disabled TagPicker
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-tagpicker--docs
Example of a disabled TagPicker. The list is inaccessible, but selected options can still be modified.
```typescript
import { TagPicker, TagPickerInput, TagPickerList, TagPickerOption } from '@fluentui/react-components';
{(option: Option) => {option.text}}
```
--------------------------------
### TagPicker Default Usage
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-tagpicker--docs
Basic example of the TagPicker component for selecting employees. This is the default configuration.
```typescript
import { TagPicker, TagPickerInput, TagPickerList, TagPickerOption } from '@fluentui/react-components';
{(option: Option) => {option.text}}
```
--------------------------------
### Disabled Select Example
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-select--docs
Demonstrates how to disable a Select component using the native `disabled` prop.
```typescript
import * as React from 'react';
import { Select, Option } from '@fluentui/react-components';
export const Disabled = () => (
);
```
--------------------------------
### Infinite Scrolling Tree Example
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-tree--docs
Demonstrates how to implement infinite scrolling in a tree structure by loading additional items as the user navigates. This enhances responsiveness for large datasets.
```javascript
import * as React from 'react';
import { Tree, TreeItem, TreeItemLayout, useTree>}
```
--------------------------------
### Controlled Select Example
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-select--docs
Illustrates a controlled Select component where the selected option is managed by state.
```typescript
import * as React from 'react';
import { Select, Option, SelectOnChangeData } from '@fluentui/react-components';
export const Controlled = () => {
const [selectedValue, setSelectedValue] = React.useState('blue');
const handleChange = (
_event: React.ChangeEvent,
data: SelectOnChangeData
) => {
setSelectedValue(data.value);
};
return (
);
};
```
--------------------------------
### FluentProvider Default Usage
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-fluentprovider--docs
Demonstrates the default usage of FluentProvider with the Web Light theme. This is the most common way to set up theming for your application.
```jsx
import { FluentProvider, webLightTheme } from '@fluentui/react-components';
function App() {
return (
{/* Your app content */}
);
}
```
--------------------------------
### Layered Blur with Inverse Visibility
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fmotion-components-preview-blur--docs
Demonstrates using two Blur components with inverse visibility. The background stripes start blurred and become clear when revealed, while the overlay button starts clear and blurs away when clicked. The button fades away with `animateOpacity` set to true, while the background blur stays visible in both states with `animateOpacity` set to false.
```typescript
import * as React from 'react';
import { Button, Stack, Text } from '@fluentui/react';
import { Blur } from '@fluentui/react-motion-components';
export const LayeredBlurDemo = () => {
const [isRevealed, setIsRevealed] = React.useState(false);
return (
Background Stripes
);
};
```
--------------------------------
### Image Fit Options
Source: https://storybooks.fluentui.dev/react?path=%2Fdocs%2Fcomponents-image--docs
Demonstrates different ways to resize an image to fit its container using the 'fit' prop. Options include 'center', 'cover', and 'contain'.
```javascript
import * as React from "react";
import { Image } from "@fluentui/react-components";
function ImageFitContain() {
return (