npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@typeform/embed-react

v3.17.0

Published

Embed library for [React](https://reactjs.org/).

Downloads

539,601

Readme

⚛ 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.