3.17.0 • Published 17 days ago

@typeform/embed-react v3.17.0

Weekly downloads
-
License
MIT
Repository
github
Last release
17 days ago

⚛ Typeform React Embed Library

Embed library for React.

Installation

Requirements:

  • node >= 14 (for node v12 use v1.21.0)
  • yarn or npm

Install as NPM package using your favourite package manager:

yarn add @typeform/embed-react

or

npm install --save @typeform/embed-react

Usage

Import the component you want to use. Then render it in your React app:

import { Widget } from '@typeform/embed-react'

const MyComponent = () => {
  return <Widget id="<form-id>" style={{ width: '50%' }} className="my-form" />
}

Popup and slider components provide a button to open the embed:

import { PopupButton } from '@typeform/embed-react'

const MyComponent = () => {
  return (
    <PopupButton id="<form-id>" style={{ fontSize: 20 }} className="my-button">
      click to open form in popup
    </PopupButton>
  )
}

You can render popover and slider anywhere in your app (preferably at the end of the page):

import { Sidetab } from '@typeform/embed-react'

const MyComponent = () => {
  return <Sidetab id="<form-id>" buttonText="click to open" />
}

How to get form id of your form?

You can find <form-id> from the public URL of your form:

  • https://form.typeform.com/to/<form-id>

Or from admin panel URL:

  • https://admin.typeform.com/form/<form-id>/*

Configuration

Options

Pass options as props to the component.

<PopupButton
  id="<form-id>"
  size={60}
  hidden={{
    foo: 'Foo Value',
    bar: 'Bar Value',
  }}
  onReady={() => {
    console.log('form ready')
  }}
  enableSandbox
  transitiveSearchParams
>
  click to open
</PopupButton>

See all available options in Vanilla JavaScript Embed Library README file. Make sure to pass props in camel case without the data-tf- prefix.

CSP nonce support

If the global __webpack_nonce__ is set, its value will be used for a nonce attribute on the inline <style> block. See #458 for details.

Passing a custom ref

For some custom use cases it may be convenient to open the popup programmatically (without the button being clicked).

To do this, pass a ref to PopupButton, SliderButton, Popover and Sidetab components and then use ref.current.open() to trigger the popup to open.

Example:

const ref = useRef()
const openPopup = () => ref.current?.open()
// ...
<PopupButton
  id="<form-id>"
  ref={ref}
>
  click to open
</PopupButton>

Examples

You can find examples for specific use-cases with React in our demos:

Local setup and development

Fork and clone this Github repo: https://github.com/Typeform/embed

Requirements:

  • node >= 14 (for node 12 use v1.21.0)
  • yarn

Install dependencies:

yarn

We recommend you work in a branch:

git checkout -b cool-new-feature

Build, watch for changes (in both @typeform/embed and @typeform/embed-react packages) and start a demo server too (using demo-nextjs):

yarn demo

Build and watch for changes (in @typeform/embed-react only):

yarn dev

Run unit tests:

yarn test

See details on contributing to this repo.

3.17.0

17 days ago

3.16.0

2 months ago

3.15.0

2 months ago

3.12.0

2 months ago

3.14.0

2 months ago

3.13.0

2 months ago

3.11.0

3 months ago

3.10.0

4 months ago

2.29.0

10 months ago

2.25.0

10 months ago

2.27.0

10 months ago

2.30.0

9 months ago

3.9.0

5 months ago

3.4.0

6 months ago

3.2.0

7 months ago

3.8.0

6 months ago

3.6.0

6 months ago

3.0.0

8 months ago

2.28.0

10 months ago

2.26.0

10 months ago

2.31.0

8 months ago

3.3.0

7 months ago

3.1.0

7 months ago

3.7.0

6 months ago

3.5.0

6 months ago

2.24.0

10 months ago

2.23.0

11 months ago

2.22.0

11 months ago

2.21.0

12 months ago

2.19.0

1 year ago

2.20.0

1 year ago

2.18.0

1 year ago

2.17.0

1 year ago

2.16.0

1 year ago

2.15.0

1 year ago

2.11.0

1 year ago

2.8.0

1 year ago

2.13.0

1 year ago

2.12.0

1 year ago

2.10.0

1 year ago

2.7.0

1 year ago

2.9.0

1 year ago

2.14.1

1 year ago

2.14.0

1 year ago

2.2.0

1 year ago

2.4.0

1 year ago

2.6.0

1 year ago

2.0.0

2 years ago

2.3.0

1 year ago

2.5.0

1 year ago

2.1.0

2 years ago

1.21.0

2 years ago

1.20.0

2 years ago

1.19.0

2 years ago

1.18.0

2 years ago

1.17.0

2 years ago

1.15.0

2 years ago

1.14.0

2 years ago

1.16.0

2 years ago

1.13.0

2 years ago

1.12.0

2 years ago

1.11.0

2 years ago

1.10.0

2 years ago

1.9.0

2 years ago

1.8.0

2 years ago

1.2.6

2 years ago

1.7.0

2 years ago

1.6.1

2 years ago

1.2.5

2 years ago

1.6.0

2 years ago

1.5.0

2 years ago

1.4.0

2 years ago

1.3.0

2 years ago

1.2.0

2 years ago

1.2.4

2 years ago

1.1.5

2 years ago

1.2.3

2 years ago

1.1.4

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago