Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

3.8 KB
Raw Blame
import { TextArea as TextAreaComponent } from "./text-area";
import { StorySection, StoryGrid } from "./storybook";
import { useState } from "react";

export default {
  title: "Text Area",
};

const exampleValue =
  "This is an example value of a text area. It's long enough to show how it wraps.";

export const TextArea = () => {
  const [value, setValue] = useState(exampleValue);

  return (
    <>
      <StorySection title="Uncontrollable">
        <StoryGrid css={{ width: 200 }}>
          <TextAreaComponent placeholder="Enter value..." />
        </StoryGrid>
      </StorySection>

      <StorySection title="No AutoGrow, rows=3 (Manual resize only, no height limit)">
        <StoryGrid css={{ width: 200 }}>
          <TextAreaComponent value={value} onChange={setValue} />
        </StoryGrid>
      </StorySection>

      <StorySection title="No AutoGrow, rows=3, maxRows=6 (Manual resize up to 6 rows)">
        <StoryGrid css={{ width: 200 }}>
          <TextAreaComponent value={value} onChange={setValue} maxRows={6} />
        </StoryGrid>
      </StorySection>

      <StorySection title="AutoGrow, no max (Auto-resize with no height limit.)">
        <StoryGrid css={{ width: 200 }}>
          <TextAreaComponent value={value} onChange={setValue} autoGrow />
        </StoryGrid>
      </StorySection>

      <StorySection title="AutoGrow, maxRows=10 (Auto-resize up to 10 rows.)">
        <StoryGrid css={{ width: 200 }}>
          <TextAreaComponent
            value={value}
            onChange={setValue}
            autoGrow
            maxRows={10}
          />
        </StoryGrid>
      </StorySection>

      <StorySection title="With value">
        <StoryGrid css={{ width: 200 }}>
          <TextAreaComponent value={value} onChange={setValue} />
        </StoryGrid>
      </StorySection>
      <StorySection title="Error">
        <StoryGrid css={{ width: 200 }}>
          <TextAreaComponent value={value} onChange={setValue} color="error" />
        </StoryGrid>
      </StorySection>
      <StorySection title="Disabled">
        <StoryGrid css={{ width: 200 }}>
          <TextAreaComponent value={value} onChange={setValue} disabled />
        </StoryGrid>
      </StorySection>
      <StorySection title="Disabled error">
        <StoryGrid css={{ width: 200 }}>
          <TextAreaComponent
            value={value}
            onChange={setValue}
            color="error"
            disabled
          />
        </StoryGrid>
      </StorySection>
      <StorySection title="Focused (initialy)">
        <StoryGrid css={{ width: 200 }}>
          <TextAreaComponent value={value} onChange={setValue} autoFocus />
        </StoryGrid>
      </StorySection>
      <StorySection title="Rows test">
        <StoryGrid css={{ width: 200 }}>
          <TextAreaComponent value={value} onChange={setValue} rows={1} />
          <TextAreaComponent value={value} onChange={setValue} rows={5} />
        </StoryGrid>
      </StorySection>
      <StorySection title="Width test">
        <StoryGrid css={{ width: 250 }}>
          <TextAreaComponent value={value} onChange={setValue} />
        </StoryGrid>
      </StorySection>
      <StorySection title="Mono">
        <StoryGrid css={{ width: 250 }}>
          <TextAreaComponent variant="mono" value={value} onChange={setValue} />
        </StoryGrid>
      </StorySection>

      <StorySection title="Uncontrolled with default value">
        <StoryGrid css={{ width: 200 }}>
          <TextAreaComponent defaultValue="This is a default value for an uncontrolled text area" />
        </StoryGrid>
      </StorySection>

      <StorySection title="Grow (manual resize disabled)">
        <StoryGrid css={{ width: 200 }}>
          <TextAreaComponent value={value} onChange={setValue} grow />
        </StoryGrid>
      </StorySection>
    </>
  );
};