mirror of
https://github.com/formbricks/formbricks.git
synced 2026-01-09 15:22:32 -06:00
update docs, react lib 0.1
This commit is contained in:
5
.changeset/silent-taxis-search.md
Normal file
5
.changeset/silent-taxis-search.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@formbricks/react": minor
|
||||
---
|
||||
|
||||
First release with Text, Textarea, Submit, simple validation and schema support
|
||||
22
README.md
22
README.md
@@ -1,6 +1,6 @@
|
||||
<p align="center">
|
||||
<a href="https://github.com/formbricks/formbricks">
|
||||
<img src="https://user-images.githubusercontent.com/675065/201035557-a94a6bde-dff0-4bd3-9693-ec9257a9b1b3.svg" alt="Logo" width="500">
|
||||
<img src="https://user-images.githubusercontent.com/675065/203262290-3c2bc5b8-839c-468a-b675-e26a369c7fe2.png" alt="Logo" width="500">
|
||||
</a>
|
||||
<h3 align="center">Formbricks</h3>
|
||||
|
||||
@@ -33,7 +33,7 @@ We're building all essential form functionality so you don't have to. Modular, c
|
||||
|
||||
We want to solve forms once and for all. If, in 10 years, a web developer rewrites core form functionality instead of building on top of our stack, we didn’t do our job. We want you to build your next big thing faster. Our big thing is the last form tool humanity needs. Hold us accountable!
|
||||
|
||||
[Read more in our blog](https://formbricks-com.vercel.app/blog/snoopforms-becomes-formbricks)
|
||||
[Read more in our blog](https://formbricks.com/blog/snoopforms-becomes-formbricks)
|
||||
|
||||
## Our Toolbox
|
||||
|
||||
@@ -46,6 +46,24 @@ Building React forms has never been quicker. But there is more...
|
||||
Loads of question types, validation, multi-page forms, logic jumps, i18n, custom styles - all the good stuff you want, but don't want to build yourself.
|
||||
Building forms fast is great, but where do you pipe your data? And what is it worth without a schema?"
|
||||
|
||||
```jsx
|
||||
import { Form, Text, Textarea, Submit } from "@formbricks/react";
|
||||
import "@formbricks/react/styles.css";
|
||||
|
||||
export default function WaitlistForm() {
|
||||
return (
|
||||
<Form onSubmit={({ data, schema }) => console.log("data:", data, "schema:", schema)}>
|
||||
<Text name="firstname" label="What's your first name?" validation="required" />
|
||||
<Text name="lastname" label="What's your last name?" />
|
||||
<Textarea name="about" label="About you" help="Please keep it short" />
|
||||
<Submit label="Submit" />
|
||||
</Form>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
[Get started with the React Library](https://formbricks.com/docs/react-form-library/introduction)
|
||||
|
||||
### Core API - The OS form engine
|
||||
|
||||
Your form looks perfect? Time to build integrations...
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import nextMDX from "@next/mdx";
|
||||
import { withPlausibleProxy } from "next-plausible";
|
||||
import remarkGfm from "remark-gfm";
|
||||
import rehypePrism from "@mapbox/rehype-prism";
|
||||
|
||||
const nextConfig = {
|
||||
reactStrictMode: true,
|
||||
@@ -34,7 +35,7 @@ const withMDX = nextMDX({
|
||||
// as the package is ESM only
|
||||
// https://github.com/remarkjs/remark-gfm#install
|
||||
remarkPlugins: [remarkGfm],
|
||||
rehypePlugins: [],
|
||||
rehypePlugins: [rehypePrism],
|
||||
// If you use `MDXProvider`, uncomment the following line.
|
||||
// providerImportSource: "@mdx-js/react",
|
||||
},
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
"@docsearch/react": "^3.3.0",
|
||||
"@headlessui/react": "^1.7.3",
|
||||
"@heroicons/react": "^2.0.13",
|
||||
"@mapbox/rehype-prism": "^0.8.0",
|
||||
"@mdx-js/loader": "^2.1.5",
|
||||
"@mdx-js/react": "^2.1.5",
|
||||
"@next/mdx": "^13.0.0",
|
||||
|
||||
@@ -15,7 +15,7 @@ In code terms, this means that it is up to you to decide what happens when the r
|
||||
In this example, we’re handing over the form _data_ and the form _schema_ to the onSubmit function. In the function itself we use the _data_ and the _schema_ and log it in the browser console:
|
||||
|
||||
```jsx
|
||||
onSubmit={({ data, schema }) => console.log("data:", data, “schema:”, schema)}
|
||||
onSubmit={({ data, schema }) => console.log("data:", data, "schema:", schema)}
|
||||
```
|
||||
|
||||
### Sending to API endpoint
|
||||
@@ -41,4 +41,10 @@ Here we’re sending the data to an API endpoint to receive and display out subm
|
||||
|
||||
[Join our Discord to suggest features 🤸](https://formbricks.com/discord)
|
||||
|
||||
### Props & Attributes
|
||||
|
||||
| Prop | Type | Default | Description |
|
||||
| -------- | -------- | ---------- | --------------------------------------------------------------------------------------------------------------- |
|
||||
| onSubmit | Function | `() => {}` | Gets passed on object with `{data, schema, event}` and is triggered when the form gets submitted without errors |
|
||||
|
||||
export default ({ children }) => <Layout meta={meta}>{children}</Layout>;
|
||||
|
||||
@@ -9,9 +9,32 @@ export const meta = {
|
||||
The submit button component is very straight forward:
|
||||
|
||||
```jsx
|
||||
<Submit name="submit" label="Submit" />
|
||||
<Submit label="Submit" />
|
||||
```
|
||||
|
||||
To keep it working make sure that there is **only one Submit button** per form.
|
||||
|
||||
### Props & Attributes
|
||||
|
||||
| Prop | Type | Default | Description |
|
||||
| ---------- | ---- | ------- | --------------------------- |
|
||||
| PrefixIcon | SVG | - | Icon displayed before label |
|
||||
| SuffixIcon | SVG | - | Icon displayed after label |
|
||||
|
||||
### Universal props all inputs have
|
||||
|
||||
| Prop | What is it? | Required? | Shown to respondent? | Comment |
|
||||
| ---------------- | --------------------------------------- | --------- | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| name | name of the field | no | no | It is not shown to respondents but important as a unique identifier to understand which field holds what content. You cannot have two fields with the same name. |
|
||||
| label | label of the field | yes | yes | The label above the input |
|
||||
| help | help text | no | yes | You can add a little help text to each field to provide more detail on how to fill out the field. |
|
||||
| validation | determines how field input is validated | no | depends on field input | If you want to validate the content of a field before the form is sent, you can do so with the validation prop. [read more](/docs/react-form-library/validation-errors) |
|
||||
| id | own identifier for input | no | no | To target your input with css or javascript directly |
|
||||
| outerClassName | append styling class | no | - | [read more](/docs/react-form-library/style-tailwind) |
|
||||
| wrapperClassName | append styling class | no | - | [read more](/docs/react-form-library/style-tailwind) |
|
||||
| innerClassName | append styling class | no | - | [read more](/docs/react-form-library/style-tailwind) |
|
||||
| inputClassName | append styling class | no | - | [read more](/docs/react-form-library/style-tailwind) |
|
||||
| helpClassName | append styling class | no | - | [read more](/docs/react-form-library/style-tailwind) |
|
||||
| |
|
||||
|
||||
export default ({ children }) => <Layout meta={meta}>{children}</Layout>;
|
||||
|
||||
@@ -25,26 +25,26 @@ In most cases, it looks something like this:
|
||||
|
||||
| Prop | Type | Default | Description |
|
||||
| ----------- | ------ | ------- | ------------------------------------------------ |
|
||||
| minLength | Number | - | Limits min length accepted in the field |
|
||||
| maxLength | Number | - | Limits max length accepted in the field |
|
||||
| minLength | Number | 0 | Limits min length accepted in the field |
|
||||
| maxLength | Number | 524288 | Limits max length accepted in the field |
|
||||
| placeholder | String | - | Placeholder before respondent clicks into field. |
|
||||
|
||||
### Universal props all inputs have
|
||||
|
||||
| Prop | What is it? | Required? | Shown to respondent? | Comment |
|
||||
| ----------------- | --------------------------------------- | ------------ | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| name | name of the field | required | no | It is not shown to respondents but important as a unique identifier to understand which field holds what content. You cannot have two fields with the same name. |
|
||||
| label | label of the field | required | yes | It is not shown to respondents but important as a unique identifier to understand which field holds what content. You cannot have two fields with the same name. |
|
||||
| help | help text | not required | yes | You can add a little help text to each field to provide more detail on how to fill out the field. |
|
||||
| validation | determines how field input is validated | not required | depends on field input | If you want to validate the content of a field before the form is sent, you can do so with the validation prop. |
|
||||
| id | own identifier for input | not required | no | |
|
||||
| outerClassName | append styling class (Tailwind) | not required | - | [read more](/docs/react-form-library/style-tailwind) |
|
||||
| wrapperClassName | append styling class (Tailwind) | not required | - | [read more](/docs/react-form-library/style-tailwind) |
|
||||
| innerClassName | append styling class (Tailwind) | not required | - | [read more](/docs/react-form-library/style-tailwind) |
|
||||
| inputClassName | append styling class (Tailwind) | not required | - | [read more](/docs/react-form-library/style-tailwind) |
|
||||
| helpClassName | append styling class (Tailwind) | not required | - | [read more](/docs/react-form-library/style-tailwind) |
|
||||
| messagesClassName | append styling class (Tailwind) | not required | - | [read more](/docs/react-form-library/style-tailwind) |
|
||||
| messageClassName | append styling class (Tailwind) | not required | - | [read more](/docs/react-form-library/style-tailwind) |
|
||||
| Prop | What is it? | Required? | Shown to respondent? | Comment |
|
||||
| ----------------- | --------------------------------------- | --------- | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| name | name of the field | yes | no | It is not shown to respondents but important as a unique identifier to understand which field holds what content. You cannot have two fields with the same name. |
|
||||
| label | label of the field | yes | yes | The label above the input |
|
||||
| help | help text | no | yes | You can add a little help text to each field to provide more detail on how to fill out the field. |
|
||||
| validation | determines how field input is validated | no | depends on field input | If you want to validate the content of a field before the form is sent, you can do so with the validation prop. [read more](/docs/react-form-library/validation-errors) |
|
||||
| id | own identifier for input | no | no | To target your input with css or javascript directly |
|
||||
| outerClassName | append styling class | no | - | [read more](/docs/react-form-library/style-tailwind) |
|
||||
| wrapperClassName | append styling class | no | - | [read more](/docs/react-form-library/style-tailwind) |
|
||||
| innerClassName | append styling class | no | - | [read more](/docs/react-form-library/style-tailwind) |
|
||||
| inputClassName | append styling class | no | - | [read more](/docs/react-form-library/style-tailwind) |
|
||||
| helpClassName | append styling class | no | - | [read more](/docs/react-form-library/style-tailwind) |
|
||||
| messagesClassName | append styling class | no | - | [read more](/docs/react-form-library/style-tailwind) |
|
||||
| messageClassName | append styling class | no | - | [read more](/docs/react-form-library/style-tailwind) |
|
||||
|
||||
### Styling with CSS
|
||||
|
||||
@@ -73,7 +73,7 @@ You can style your form with adding CSS to the pre-assigned classes. This is how
|
||||
You can also use Tailwind to extend the classes, like so:
|
||||
|
||||
```jsx
|
||||
<Text name="firstname" label="What's your first name?" outerClassName=”bg-gray-800 my-5” />
|
||||
<Text name="firstname" label="What's your first name?" outerClassName="bg-gray-800 my-5" />
|
||||
```
|
||||
|
||||
Here are the in-depth guides for [CSS](/docs/react-form-library/style-css) or [Tailwind](/docs/react-form-library/style-tailwind).
|
||||
|
||||
@@ -28,28 +28,30 @@ In most cases, it looks something like this:
|
||||
|
||||
### Props & Attributes
|
||||
|
||||
| Prop | Type | Default | Description |
|
||||
| ----------- | ------ | ------- | ------------------------------------------------ |
|
||||
| minLength | Number | - | Limits min length accepted in the field |
|
||||
| maxLength | Number | - | Limits max length accepted in the field |
|
||||
| placeholder | String | - | Placeholder before respondent clicks into field. |
|
||||
| Prop | Type | Default | Description |
|
||||
| ----------- | ------ | ------- | ----------------------------------------------- |
|
||||
| minLength | Number | 0 | Limits min length accepted in the field |
|
||||
| maxLength | Number | 524288 | Limits max length accepted in the field |
|
||||
| placeholder | String | - | Placeholder before respondent clicks into field |
|
||||
| cols | Number | - | Number of cols (width) of the textarea |
|
||||
| rows | Number | - | Number of rows (height) of the textarea |
|
||||
|
||||
### Universal props all inputs have
|
||||
|
||||
| Prop | What is it? | Required? | Shown to respondent? | Comment |
|
||||
| ----------------- | --------------------------------------- | ------------ | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| name | name of the field | required | no | It is not shown to respondents but important as a unique identifier to understand which field holds what content. You cannot have two fields with the same name. |
|
||||
| label | label of the field | required | yes | It is not shown to respondents but important as a unique identifier to understand which field holds what content. You cannot have two fields with the same name. |
|
||||
| help | help text | not required | yes | You can add a little help text to each field to provide more detail on how to fill out the field. |
|
||||
| validation | determines how field input is validated | not required | depends on field input | If you want to validate the content of a field before the form is sent, you can do so with the validation prop. |
|
||||
| id | own identifier for input | not required | no | |
|
||||
| outerClassName | append styling class (Tailwind) | not required | - | [read more](/docs/react-form-library/style-tailwind) |
|
||||
| wrapperClassName | append styling class (Tailwind) | not required | - | [read more](/docs/react-form-library/style-tailwind) |
|
||||
| innerClassName | append styling class (Tailwind) | not required | - | [read more](/docs/react-form-library/style-tailwind) |
|
||||
| inputClassName | append styling class (Tailwind) | not required | - | [read more](/docs/react-form-library/style-tailwind) |
|
||||
| helpClassName | append styling class (Tailwind) | not required | - | [read more](/docs/react-form-library/style-tailwind) |
|
||||
| messagesClassName | append styling class (Tailwind) | not required | - | [read more](/docs/react-form-library/style-tailwind) |
|
||||
| messageClassName | append styling class (Tailwind) | not required | - | [read more](/docs/react-form-library/style-tailwind) |
|
||||
| Prop | What is it? | Required? | Shown to respondent? | Comment |
|
||||
| ----------------- | --------------------------------------- | --------- | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| name | name of the field | yes | no | It is not shown to respondents but important as a unique identifier to understand which field holds what content. You cannot have two fields with the same name. |
|
||||
| label | label of the field | yes | yes | The label above the input |
|
||||
| help | help text | no | yes | You can add a little help text to each field to provide more detail on how to fill out the field. |
|
||||
| validation | determines how field input is validated | no | depends on field input | If you want to validate the content of a field before the form is sent, you can do so with the validation prop. [read more](/docs/react-form-library/validation-errors) |
|
||||
| id | own identifier for input | no | no | To target your input with css or javascript directly |
|
||||
| outerClassName | append styling class | no | - | [read more](/docs/react-form-library/style-tailwind) |
|
||||
| wrapperClassName | append styling class | no | - | [read more](/docs/react-form-library/style-tailwind) |
|
||||
| innerClassName | append styling class | no | - | [read more](/docs/react-form-library/style-tailwind) |
|
||||
| inputClassName | append styling class | no | - | [read more](/docs/react-form-library/style-tailwind) |
|
||||
| helpClassName | append styling class | no | - | [read more](/docs/react-form-library/style-tailwind) |
|
||||
| messagesClassName | append styling class | no | - | [read more](/docs/react-form-library/style-tailwind) |
|
||||
| messageClassName | append styling class | no | - | [read more](/docs/react-form-library/style-tailwind) |
|
||||
|
||||
### Styling with CSS
|
||||
|
||||
@@ -78,7 +80,7 @@ You can style your form with adding CSS to the pre-assigned classes. This is how
|
||||
You can also use Tailwind to extend the classes, like so:
|
||||
|
||||
```jsx
|
||||
<Text name="firstname" label="What's your first name?" outerClassName=”bg-gray-800 my-5” />
|
||||
<Text name="firstname" label="What's your first name?" outerClassName="bg-gray-800 my-5" />
|
||||
```
|
||||
|
||||
Here are the in-depth guides for [CSS](/docs/react-form-library/style-css) or [Tailwind](/docs/react-form-library/style-tailwind).
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Layout } from "@/components/docs/Layout";
|
||||
import { Callout } from "@/components/shared/Callout";
|
||||
import Image from "next/image";
|
||||
import UnstyledForm from "./plain-form-no-css-formbricks-react-form-survey-library-builder-v1.png";
|
||||
import SimpleForm from "./simple-form-basic-theme-formbricks-react-form-survey-library-builder-v1.png";
|
||||
import LogData from "./data output console for open source form made with react library for free.png";
|
||||
|
||||
export const meta = {
|
||||
@@ -12,7 +12,7 @@ This is a step-by-step guide on how to get started with Formbricks React.
|
||||
|
||||
### Preparation: Create React App
|
||||
|
||||
To use Formbricks React, you need a React application. Please follow these guides to either create a React or a Next.js app:
|
||||
To use Formbricks React, you need a React application. If you don't have your application already, please follow these guides to either create a React or a Next.js app:
|
||||
|
||||
- [Create new React app](https://reactjs.org/docs/create-a-new-react-app.html)
|
||||
- [Create new Next.js app](https://nextjs.org/docs/api-reference/create-next-app)
|
||||
@@ -22,7 +22,7 @@ To use Formbricks React, you need a React application. Please follow these guide
|
||||
Install Formbricks React using the package manager of your choice:
|
||||
|
||||
```bash
|
||||
npm install @formbricks/react
|
||||
npm install -s @formbricks/react
|
||||
# or
|
||||
yarn add @formbricks/react
|
||||
# or
|
||||
@@ -31,7 +31,7 @@ pnpm add @formbricks/react
|
||||
|
||||
### 2. Create new form component
|
||||
|
||||
Since React is based on components, we will create a new component for your form. To do so, create a file called “Form.js” - if you work with JSX or TypeScript you need to change the suffix.
|
||||
Since React is based on components, we will create a new component for your form. To do so, create a file called `Form.jsx` - if you work with TypeScript you need to change the suffix to `.tsx`.
|
||||
|
||||
### 3. Import form components
|
||||
|
||||
@@ -53,28 +53,26 @@ import { Form, Text, Textarea, Submit } from "@formbricks/react";
|
||||
Now we’re getting to the fun part: Coding your form. This is the full form code you can copy and play around with. Below we go through it step-by-step:
|
||||
|
||||
```jsx
|
||||
import { Form , Text, Textarea, Submit } from "@formbricks/react";
|
||||
import “@formbricks/react/styles.css”
|
||||
import { Form, Text, Textarea, Submit } from "@formbricks/react";
|
||||
import "@formbricks/react/styles.css";
|
||||
|
||||
export default function WaitlistForm() {
|
||||
return (
|
||||
<Form
|
||||
onSubmit={({ data, schema }) =>
|
||||
console.log("data:", data, “schema:”, schema)}>
|
||||
<Text name="firstname" label="What's your first name?" validation="required" />
|
||||
<Text name="lastname" label="What's your last name?" />
|
||||
<Textarea name="about" label="About you" help="Please keep it short" />
|
||||
<Submit label="Submit" />
|
||||
</Form>
|
||||
<Form onSubmit={({ data, schema }) => console.log("data:", data, "schema:", schema)}>
|
||||
<Text name="firstname" label="What's your first name?" validation="required" />
|
||||
<Text name="lastname" label="What's your last name?" />
|
||||
<Textarea name="about" label="About you" help="Please keep it short" />
|
||||
<Submit label="Submit" />
|
||||
</Form>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
The form comes unstyled by default, we cover [styling](/docs/react-form-library/style-css) later.
|
||||
This form imports the default formbricks theme for styling, we cover [styling](/docs/react-form-library/style-css) later.
|
||||
|
||||
Your browser window should look like this now:
|
||||
|
||||
<Image src={UnstyledForm} alt="Unstyled form created with best react form library" className="rounded-lg" />
|
||||
<Image src={SimpleForm} alt="Unstyled form created with best react form library" className="rounded-lg" />
|
||||
|
||||
### 5. Test if it works
|
||||
|
||||
@@ -94,7 +92,7 @@ Congratulations, your React form works!
|
||||
|
||||
To get to the desired outcome, there are three more things on your list:
|
||||
|
||||
[→ Receive and manage form submissions](//docs/react-form-library/link-formbricks-hq)
|
||||
[→ Receive and manage form submissions](/docs/react-form-library/link-formbricks-hq)
|
||||
|
||||
[→ Explore all input types and how props define them](/docs/react-form-library/work-with-components)
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
@@ -14,25 +14,24 @@ We make building - and maintaining - forms easier than ever in the React world.
|
||||
### Formbricks React Example:
|
||||
|
||||
```jsx
|
||||
import { Form , Text, Textarea, Submit } from "@formbricks/react";
|
||||
import “@formbricks/react/styles.css”
|
||||
import { Form, Text, Textarea, Submit } from "@formbricks/react";
|
||||
import "@formbricks/react/styles.css";
|
||||
|
||||
export default function WaitlistForm() {
|
||||
return (
|
||||
<Form
|
||||
onSubmit={({ data, schema }) =>
|
||||
console.log("data:", data, “schema:”, schema)}>
|
||||
<Text name="firstname" label="What's your first name?" validation="required" />
|
||||
<Text name="lastname" label="What's your last name?" />
|
||||
<Textarea name="about" label="About you" help="Please keep it short" />
|
||||
<Submit label="Submit" />
|
||||
</Form>
|
||||
<Form onSubmit={({ data, schema }) => console.log("data:", data, "schema:", schema)}>
|
||||
<Text name="firstname" label="What's your first name?" validation="required" />
|
||||
<Text name="lastname" label="What's your last name?" />
|
||||
<Textarea name="about" label="About you" help="Please keep it short" />
|
||||
<Submit label="Submit" />
|
||||
</Form>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
### Why is this easier already?
|
||||
|
||||
- One easy to use syntax for input types including labels, validation and help texts
|
||||
- HTML & non-HTML input types available out of the box
|
||||
- Easily maintainable with component-based approach
|
||||
- All characteristics adjustable via props
|
||||
|
||||
@@ -12,8 +12,8 @@ Giving your form the right look and feel is very likely why you chose to use cod
|
||||
|
||||
### Creating custom style sheet
|
||||
|
||||
1. Create a new style.css file in your project folder.
|
||||
2. Import it into your form component (e.g. “Form.js”)
|
||||
1. Create a new `style.css` file in your project folder.
|
||||
2. Import it into your form component (e.g. `Form.jsx`)
|
||||
|
||||
```jsx
|
||||
import style from "./style.css";
|
||||
@@ -21,7 +21,8 @@ import style from "./style.css";
|
||||
|
||||
3. Add styles to it. You can copy this template as a quick start
|
||||
|
||||
```css.formbricks-form {
|
||||
```css
|
||||
.formbricks-form {
|
||||
background-color: #e2e8f0;
|
||||
padding: 1em;
|
||||
margin: 2em;
|
||||
@@ -63,7 +64,6 @@ import style from "./style.css";
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
When you copied the style above to your styles.css you form should look like this now:
|
||||
@@ -99,10 +99,9 @@ Each form element component follows the same naming convention. This means that
|
||||
### In React app, a simple form with one field looks like this:
|
||||
|
||||
```jsx
|
||||
<Form
|
||||
onSubmit={({ data, schema }) => {}>
|
||||
<Text name="firstname" label="What's your first name?" validation="required" />
|
||||
<Submit name="submit" label="Submit" />
|
||||
<Form onSubmit={() => {}>
|
||||
<Text name="firstname" label="What's your first name?" validation="required" />
|
||||
<Submit name="submit" label="Submit" />
|
||||
</Form>
|
||||
```
|
||||
|
||||
@@ -116,8 +115,7 @@ In your browser, it is interpreted as follows:
|
||||
<div class="formbricks-wrapper">
|
||||
<label class="formbricks-label" for="firstname-JCc">What's your first name?</label>
|
||||
<div class="formbricks-inner">
|
||||
<input
|
||||
class="formbricks-input"
|
||||
<input class="formbricks-input"
|
||||
type="text"
|
||||
id="firstname=JCc"
|
||||
placeholder=""
|
||||
|
||||
@@ -9,7 +9,7 @@ export const meta = {
|
||||
We love Tailwind! This is why Formbricks React natively supports Tailwind. All you have to do is target the classes using props. For example, to extend “formbricks-outer” class:
|
||||
|
||||
```jsx
|
||||
<Text name="firstname" label="What's your first name?" outerClassName=”bg-gray-800 my-5” />
|
||||
<Text name="firstname" label="What's your first name?" outerClassName="bg-gray-800 my-5" />
|
||||
```
|
||||
|
||||
### Overview of props to target CSS classes
|
||||
|
||||
@@ -61,7 +61,12 @@ to style the message wrapper and the message itself:
|
||||
### Message styling with Tailwind
|
||||
|
||||
```jsx
|
||||
REPLACE;
|
||||
<Text
|
||||
name="email"
|
||||
label="Email"
|
||||
messagesClassName="bg-gray-100 rounded"
|
||||
messageClassName="text-base sm:text-sm text-red-500"
|
||||
/>
|
||||
```
|
||||
|
||||
Here are the in-depth guides for [CSS](/docs/react-form-library/style-css) or [Tailwind](/docs/react-form-library/style-tailwind).
|
||||
|
||||
@@ -11,11 +11,11 @@ We adopt the component-based approach many front-end libraries popularized over
|
||||
For performance reasons, we do not automatically import all available form components. This is why you have to import components before you can use them, like so:
|
||||
|
||||
```jsx
|
||||
import Text from "@formbricks/react";
|
||||
import { Text } from "@formbricks/react";
|
||||
|
||||
# or several at once
|
||||
// or several at once
|
||||
|
||||
import { Form , Text, Textarea, Submit } from "@formbricks/react";
|
||||
import { Form, Text, Textarea, Submit } from "@formbricks/react";
|
||||
```
|
||||
|
||||
<Callout title="Only import inputs you use" type="warning">
|
||||
@@ -25,11 +25,27 @@ All imported components will be included in the production build - even when you
|
||||
|
||||
### Components available
|
||||
|
||||
| Component | Details | Use |
|
||||
| ------------ | ------------------- | ------------------------------------------- |
|
||||
| `<Form>` | Form Wrapper | Handles the onSubmit action, wraps the form |
|
||||
| `<Text>` | HTML Text Input | Single line of text input |
|
||||
| `<Textarea>` | HTML Textarea Input | Multiple lines of text |
|
||||
| `<Submit>` | Submit Button | Submits the form |
|
||||
| Component | Details | Use |
|
||||
| -------------- | ------------------- | ------------------------------------------- |
|
||||
| `<Form />` | Form Wrapper | Handles the onSubmit action, wraps the form |
|
||||
| `<Text />` | HTML Text Input | Single line of text input |
|
||||
| `<Textarea />` | HTML Textarea Input | Multiple lines of text |
|
||||
| `<Submit />` | Submit Button | Submits the form |
|
||||
|
||||
---
|
||||
|
||||
### Coming soon 🚧
|
||||
|
||||
| Component | Details | Use |
|
||||
| ------------------ | ----------------------------- | ----------------------- |
|
||||
| `<Radio />` | Radio Buttons | Single choice |
|
||||
| `<Checkbox />` | Checkboxes | Multiple choice |
|
||||
| `<Rating />` | Star-Rating | Simple rating in steps |
|
||||
| `<Nps />` | Nps Score | Evaluate experience |
|
||||
| `<Color />` | Color-Picker | Let user choose a color |
|
||||
| `<Slider />` | Slider | Stepless rating |
|
||||
| `<Autocomplete />` | Autocomplete possible options | e.g. Tags |
|
||||
|
||||
and many more...
|
||||
|
||||
export default ({ children }) => <Layout meta={meta}>{children}</Layout>;
|
||||
|
||||
1181
pnpm-lock.yaml
generated
1181
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user