2.0.0 • Published 2 years ago

typeform-elements v2.0.0

Weekly downloads
76
License
MIT
Repository
github
Last release
2 years ago

typeform-elements

npm version

Custom elements for easy use of Typeform

Table of Contents

Downloading Typeform Elements

You can install Typeform Elements via npm:

npm install typeform-elements

Or you can use Typeform Elements via CDN:

<script src="https://unpkg.com/typeform-elements/dist/typeform-elements.js"></script>

If you do use this library from NPM be sure to import it somewhere in your JS code:

import 'typeform-elements';

// or

export { /* Whatever component(s) you want */ } from 'typeform-elements';

Elements

Login

Add the button code to your application and configure it to work with the link that redirects users to the Typeform login screen (https://api.typeform.com/oauth/authorize) so they can log in to their Typeform accounts and grant access to your app via OAuth 2.0 scopes.

CDN

You can use the login element via CDN without needing to import all of the Typeform Elements.

<script src="https://unpkg.com/typeform-elements/dist/login.js"></script>

Usage

<typeform-login client-id="{your_client_id}" scope="{comma_separated_scopes}" redirect-uri="{your_redirect_uri}" state="{optional_state}"></typeform-login>

Example

<typeform-login client-id="1234567890" scope="accounts:read,forms:read" redirect-uri="https://results-example.herokuapp.com/callback"></typeform-login>

TypeformLogin (<typeform-login>) Attributes

AttributeRequiredDescriptionTypeDefault
client-idtrueThe id of the application that asks for authorization.Stringnull
redirect-uritrueA successful response from results in a redirect to this URL.Stringnull
scopetrueList of permissions that the application requires. Ensure list is in comma separated format, like so: accounts:read,forms:readStringnull
statefalseAn opaque value, used for security purposes. If this request parameter is set in the request, then it is returned to the application as part of the redirect_uri.Stringnull

Embed

Easily display forms as elements on your page as a standard embeded form, a full page embeded form, and a pop up form.

CDN

You can use the login element via CDN without needing to import all of the Typeform Elements.

<script src="https://unpkg.com/typeform-elements/dist/embed.js"></script>

Usage

<typeform-widget url="{typeform_url}"></typeform-widget>

<typeform-popup url="{typeform_url}"></typeform-popup>

Example

<typeform-widget url="https://admin.typeform.com/to/PlBzgL"></typeform-widget>

<typeform-popup url="https://admin.typeform.com/to/PlBzgL"></typeform-popup>

TypeformWidget (<typeform-widget>) Attributes

AttributeRequiredDescriptionTypeDefault
urltrueURL of TypeformStringnull
heightfalseHeight of form. Accepts size in %, cm, em, ex, in, mm, pc, p, px, vh, or vw.String"500px"
widthfalseWidth of form. Accepts size in %, cm, em, ex, in, mm, pc, p, px, vh, or vw.String"100%"
opacityfalseYou can make your Typeform's background totally transparent, or opaque. (For example, to have a video as a background)Number100
button-textfalseThe button text that appears on mobile in order to open the Typeform.String"Start"
hide-scrollbarsfalseHide fixed scrollbars.Booleanfalse
hide-footerfalseHide Typeform footer, that appears showing the progress bar and the navigation buttons.Booleanfalse
hide-headersfalseHide Typeform header, that appears when you have a Question group, or a long question that you need to scroll through to answer, like a Multiple Choice block.Booleanfalse
onsubmitfalseCallback function that will be executed right after the Typeform is successfully submitted.Functionnull

TypeformPopup (<typeform-popup>) Attributes

AttributeRequiredDescriptionTypeDefault
urltrueURL of TypeformStringnull
modefalseThe way of showing the embed. Accepts "popup", "drawer_left", or "drawer_right".String"popup"
auto-openfalseYour Typeform will launch as soon as your web page is openedBooleanfalse
auto-closefalseTime until the embedded Typeform will automatically close after a respondent clicks the Submit button. The default time is 5 seconds. PRO+ users can change the auto-close time.Number5
hide-scrollbarsfalseHide fixed scrollbars.Booleanfalse
hide-footerfalseHide Typeform footer, that appears showing the progress bar and the navigation buttons.Booleanfalse
hide-headersfalseHide Typeform header, that appears when you have a Question group, or a long question that you need to scroll through to answer, like a Multiple Choice block.Booleanfalse
drawer-widthfalseSpecify the width, in pixels, of the drawer (only applies if using mode "drawer_left" or "drawer_right").Number800
custom-stylefalseApplies custom styling to button element. Use as you would style attribute.stringnull
onsubmitfalseCallback function that will be executed right after the Typeform is successfully submitted.Functionnull

Contributing

All code should pass tests, as well as be well documented. Please open PRs into the dev branch. Please also see the Commit Message Guidelines for how commit messages should be structured.

2.0.0

2 years ago

1.2.0

3 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.1

4 years ago

1.0.0

5 years ago

0.6.0

5 years ago

0.5.0

5 years ago

0.4.2

5 years ago

0.4.1

5 years ago

0.4.0

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago