diff --git a/packages/react-components/react-textarea/stories/Textarea/TextareaAppearance.stories.tsx b/packages/react-components/react-textarea/stories/Textarea/TextareaAppearance.stories.tsx
index 1dcace710fefa8..321e09aeb90a82 100644
--- a/packages/react-components/react-textarea/stories/Textarea/TextareaAppearance.stories.tsx
+++ b/packages/react-components/react-textarea/stories/Textarea/TextareaAppearance.stories.tsx
@@ -1,58 +1,44 @@
import * as React from 'react';
-import { makeStyles, shorthands, tokens, useId, Label, Textarea } from '@fluentui/react-components';
+import { Field, makeStyles, mergeClasses, shorthands, tokens, Textarea } from '@fluentui/react-components';
const useStyles = makeStyles({
base: {
display: 'flex',
flexDirection: 'column',
-
- '> div': {
- display: 'flex',
- flexDirection: 'column',
- marginTop: tokens.spacingVerticalMNudge,
- ...shorthands.padding(tokens.spacingHorizontalMNudge),
- },
-
- '> div > label': {
- marginBottom: tokens.spacingHorizontalXXS,
- marginLeft: tokens.spacingHorizontalMNudge,
- },
+ rowGap: tokens.spacingVerticalMNudge,
},
- filledLighter: {
+ inverted: {
backgroundColor: tokens.colorNeutralBackgroundInverted,
- '> label': {
- color: tokens.colorNeutralForegroundInverted2,
- },
},
- filledDarker: {
- backgroundColor: tokens.colorNeutralBackgroundInverted,
- '> label': {
- color: tokens.colorNeutralForegroundInverted2,
- },
+ invertedLabel: {
+ color: tokens.colorNeutralForegroundInverted2,
+ },
+ fieldWrapper: {
+ ...shorthands.padding(tokens.spacingVerticalMNudge, tokens.spacingHorizontalMNudge),
},
});
export const Appearance = () => {
- const outlineId = useId('textarea-outline');
- const filledDarkerId = useId('textarea-filleddarker');
- const filledLighterId = useId('textarea-filledlighter');
const styles = useStyles();
return (
-
-
Textarea with Outline appearance.
-
+
+
+
+
-
-
Textarea with Filled Darker appearance.
-
+
+
+
+
-
-
Textarea with Filled Lighter appearance.
-
+
+
+
+
);
diff --git a/packages/react-components/react-textarea/stories/Textarea/TextareaBestPractices.md b/packages/react-components/react-textarea/stories/Textarea/TextareaBestPractices.md
index 42c17c6a3ef3da..a614e71278779e 100644
--- a/packages/react-components/react-textarea/stories/Textarea/TextareaBestPractices.md
+++ b/packages/react-components/react-textarea/stories/Textarea/TextareaBestPractices.md
@@ -6,6 +6,7 @@
### Do
- **Consider using `Textarea` with outline appearance.** When the contrast ratio against the immediate surrounding color is less than 3:1, consider using outline styles which has a bottom border stroke. But please ensure the color of bottom border stroke has a sufficient contrast which is greater than 3 to 1 against the immediate surrounding.
+- Prefer using `
` instead of `` to handle accessibility automatically.
### Don't
diff --git a/packages/react-components/react-textarea/stories/Textarea/TextareaControlled.stories.tsx b/packages/react-components/react-textarea/stories/Textarea/TextareaControlled.stories.tsx
index 9673f7a2a85121..36a806b14426c8 100644
--- a/packages/react-components/react-textarea/stories/Textarea/TextareaControlled.stories.tsx
+++ b/packages/react-components/react-textarea/stories/Textarea/TextareaControlled.stories.tsx
@@ -1,21 +1,8 @@
import * as React from 'react';
-import { makeStyles, tokens, useId, Label, Textarea } from '@fluentui/react-components';
+import { Field, Textarea } from '@fluentui/react-components';
import type { TextareaProps } from '@fluentui/react-components';
-const useStyles = makeStyles({
- base: {
- display: 'flex',
- flexDirection: 'column',
- '& > label': {
- display: 'block',
- marginBottom: tokens.spacingVerticalMNudge,
- },
- },
-});
-
export const Controlled = () => {
- const textareaId = useId('textarea');
- const styles = useStyles();
const [value, setValue] = React.useState('initial value');
const onChange: TextareaProps['onChange'] = (ev, data) => {
@@ -25,9 +12,8 @@ export const Controlled = () => {
};
return (
-
- Controlled Textarea limiting the value to 50 characters.
-
-
+
+
+
);
};
diff --git a/packages/react-components/react-textarea/stories/Textarea/TextareaDefault.stories.tsx b/packages/react-components/react-textarea/stories/Textarea/TextareaDefault.stories.tsx
index 03f7b47b5b800a..b562c4106dec40 100644
--- a/packages/react-components/react-textarea/stories/Textarea/TextareaDefault.stories.tsx
+++ b/packages/react-components/react-textarea/stories/Textarea/TextareaDefault.stories.tsx
@@ -1,25 +1,9 @@
import * as React from 'react';
-import { makeStyles, tokens, useId, Label, Textarea } from '@fluentui/react-components';
+import { Field, Textarea } from '@fluentui/react-components';
import type { TextareaProps } from '@fluentui/react-components';
-const useStyles = makeStyles({
- base: {
- display: 'flex',
- flexDirection: 'column',
- '& > label': {
- marginBottom: tokens.spacingVerticalMNudge,
- },
- },
-});
-
-export const Default = (props: Partial) => {
- const textareaId = useId('textarea');
- const styles = useStyles();
-
- return (
-
- Default Textarea
-
-
- );
-};
+export const Default = (props: Partial) => (
+
+
+
+);
diff --git a/packages/react-components/react-textarea/stories/Textarea/TextareaDisabled.stories.tsx b/packages/react-components/react-textarea/stories/Textarea/TextareaDisabled.stories.tsx
index 469a388031bf21..6a339b1324a688 100644
--- a/packages/react-components/react-textarea/stories/Textarea/TextareaDisabled.stories.tsx
+++ b/packages/react-components/react-textarea/stories/Textarea/TextareaDisabled.stories.tsx
@@ -1,24 +1,8 @@
import * as React from 'react';
-import { makeStyles, tokens, useId, Label, Textarea } from '@fluentui/react-components';
+import { Field, Textarea } from '@fluentui/react-components';
-const useStyles = makeStyles({
- base: {
- display: 'flex',
- flexDirection: 'column',
- '& > label': {
- marginBottom: tokens.spacingVerticalMNudge,
- },
- },
-});
-
-export const Disabled = () => {
- const disabledId = useId('textarea-disabled');
- const styles = useStyles();
-
- return (
-
- Disabled Textarea.
-
-
- );
-};
+export const Disabled = () => (
+
+
+
+);
diff --git a/packages/react-components/react-textarea/stories/Textarea/TextareaHeight.stories.tsx b/packages/react-components/react-textarea/stories/Textarea/TextareaHeight.stories.tsx
deleted file mode 100644
index 90f4492c33a173..00000000000000
--- a/packages/react-components/react-textarea/stories/Textarea/TextareaHeight.stories.tsx
+++ /dev/null
@@ -1,38 +0,0 @@
-import * as React from 'react';
-import { makeStyles, tokens, useId, Label, Textarea } from '@fluentui/react-components';
-
-const useStyles = makeStyles({
- base: {
- display: 'flex',
- flexDirection: 'column',
- '& > label': {
- display: 'block',
- marginBottom: tokens.spacingVerticalMNudge,
- },
- },
- textarea: {
- height: '200px',
- },
-});
-
-export const Height = () => {
- const textareaId = useId('textarea');
- const styles = useStyles();
-
- return (
-
- Textarea with a height of 200px
-
-
- );
-};
-
-Height.parameters = {
- docs: {
- description: {
- story: `When changing a Textarea's height, the classname with the styling should be given to the textarea element.
- Textarea has a wrapper that adds all the styling for the borders and an inner textarea element that handles all
- the interaction, the wrapper is only in charge of surrounding the textarea element.`,
- },
- },
-};
diff --git a/packages/react-components/react-textarea/stories/Textarea/TextareaPlaceholder.stories.tsx b/packages/react-components/react-textarea/stories/Textarea/TextareaPlaceholder.stories.tsx
index d44d2fefa8d2f4..72223e794a5a5d 100644
--- a/packages/react-components/react-textarea/stories/Textarea/TextareaPlaceholder.stories.tsx
+++ b/packages/react-components/react-textarea/stories/Textarea/TextareaPlaceholder.stories.tsx
@@ -1,23 +1,8 @@
import * as React from 'react';
-import { makeStyles, tokens, useId, Label, Textarea } from '@fluentui/react-components';
+import { Field, Textarea } from '@fluentui/react-components';
-const useStyles = makeStyles({
- base: {
- display: 'flex',
- flexDirection: 'column',
- '& > label': {
- marginBottom: tokens.spacingVerticalMNudge,
- },
- },
-});
-
-export const Placeholder = () => {
- const styles = useStyles();
- const textareaId = useId('textarea');
- return (
-
- Textarea with placeholder.
-
-
- );
-};
+export const Placeholder = () => (
+
+
+
+);
diff --git a/packages/react-components/react-textarea/stories/Textarea/TextareaResize.stories.tsx b/packages/react-components/react-textarea/stories/Textarea/TextareaResize.stories.tsx
index 8de8e0bd6364b3..f48c510d1b74fc 100644
--- a/packages/react-components/react-textarea/stories/Textarea/TextareaResize.stories.tsx
+++ b/packages/react-components/react-textarea/stories/Textarea/TextareaResize.stories.tsx
@@ -1,60 +1,34 @@
import * as React from 'react';
-import { makeStyles, shorthands, tokens, useId, Label, Textarea } from '@fluentui/react-components';
+import { Field, makeStyles, Textarea, tokens } from '@fluentui/react-components';
const useStyles = makeStyles({
base: {
- '& > div': {
- marginTop: tokens.spacingVerticalMNudge,
- },
- '& > div > div': {
- display: 'flex',
- flexDirection: 'column',
- ...shorthands.borderRadius(tokens.borderRadiusMedium),
- ...shorthands.padding(tokens.spacingHorizontalMNudge),
- },
- '& > div > label': {
- marginBottom: tokens.spacingHorizontalXXS,
- marginLeft: tokens.spacingHorizontalMNudge,
- },
+ display: 'flex',
+ flexDirection: 'column',
+ rowGap: tokens.spacingVerticalMNudge,
},
});
export const Resize = () => {
- const noneId = useId('textarea-none');
- const verticalId = useId('textarea-vertical');
- const horizontalId = useId('textarea-horizontal');
- const bothId = useId('textarea-both');
const styles = useStyles();
return (
-
-
Textarea with resize set to "none".
-
-
-
-
+
+
+
-
-
Textarea with resize set to "vertical".
-
-
-
-
+
+
+
-
-
Textarea with resize set to "horizontal".
-
-
-
-
+
+
+
-
-
Textarea with resize set to "both".
-
-
-
-
+
+
+
);
};
diff --git a/packages/react-components/react-textarea/stories/Textarea/TextareaSize.stories.tsx b/packages/react-components/react-textarea/stories/Textarea/TextareaSize.stories.tsx
index ae66a91821af8e..9ff2b3be8003bc 100644
--- a/packages/react-components/react-textarea/stories/Textarea/TextareaSize.stories.tsx
+++ b/packages/react-components/react-textarea/stories/Textarea/TextareaSize.stories.tsx
@@ -1,52 +1,30 @@
import * as React from 'react';
-import { makeStyles, shorthands, tokens, useId, Label, Textarea } from '@fluentui/react-components';
+import { Field, makeStyles, Textarea, tokens } from '@fluentui/react-components';
const useStyles = makeStyles({
base: {
- '& > div': {
- marginTop: tokens.spacingVerticalMNudge,
- },
- '& > div > div': {
- display: 'flex',
- flexDirection: 'column',
- ...shorthands.borderRadius(tokens.borderRadiusMedium),
- ...shorthands.padding(tokens.spacingHorizontalMNudge),
- },
- '& > div > label': {
- marginBottom: tokens.spacingHorizontalXXS,
- marginLeft: tokens.spacingHorizontalMNudge,
- },
+ display: 'flex',
+ flexDirection: 'column',
+ rowGap: tokens.spacingVerticalMNudge,
},
});
export const Size = () => {
- const smallId = useId('textarea-small');
- const mediumId = useId('textarea-medium');
- const largeId = useId('textarea-large');
const styles = useStyles();
return (
-
-
Small Textarea.
-
-
-
-
+
+
+
-
-
Medium Textarea.
-
-
-
-
+
+
+
-
-
Large Textarea.
-
-
-
-
+
+
+
);
};
diff --git a/packages/react-components/react-textarea/stories/Textarea/TextareaUncontrolled.stories.tsx b/packages/react-components/react-textarea/stories/Textarea/TextareaUncontrolled.stories.tsx
index ead1c71649dd30..3ceed4b6c57536 100644
--- a/packages/react-components/react-textarea/stories/Textarea/TextareaUncontrolled.stories.tsx
+++ b/packages/react-components/react-textarea/stories/Textarea/TextareaUncontrolled.stories.tsx
@@ -1,31 +1,14 @@
import * as React from 'react';
-import { makeStyles, tokens, useId, Label, Textarea } from '@fluentui/react-components';
+import { Field, Textarea } from '@fluentui/react-components';
import type { TextareaProps } from '@fluentui/react-components';
-const useStyles = makeStyles({
- base: {
- display: 'flex',
- flexDirection: 'column',
- '& > label': {
- marginBottom: tokens.spacingVerticalMNudge,
- },
- },
-});
-
const onChange: TextareaProps['onChange'] = (ev, data) => {
// Uncontrolled inputs can be notified of changes to the value
console.log(`New value: "${data.value}"`);
};
-export const Uncontrolled = () => {
- const textareaId = useId('textarea');
- const styles = useStyles();
-
- return (
-
- Uncontrolled Textarea.
-
- Check console for new value.
-
- );
-};
+export const Uncontrolled = () => (
+
+
+
+);
diff --git a/packages/react-components/react-textarea/stories/Textarea/index.stories.tsx b/packages/react-components/react-textarea/stories/Textarea/index.stories.tsx
index 1aaf340a0d6319..ad03268d830d2b 100644
--- a/packages/react-components/react-textarea/stories/Textarea/index.stories.tsx
+++ b/packages/react-components/react-textarea/stories/Textarea/index.stories.tsx
@@ -11,7 +11,6 @@ export { Resize } from './TextareaResize.stories';
export { Size } from './TextareaSize.stories';
export { Uncontrolled } from './TextareaUncontrolled.stories';
export { Controlled } from './TextareaControlled.stories';
-export { Height } from './TextareaHeight.stories';
export default {
title: 'Components/Textarea',