FgFileGrab

Form Embed SDK

Customize embedded forms to match your website's design.

Quick Start

Add a FileGrab form to any website with two lines of HTML. No backend, no API keys, no build step required.

<div id="filegrab-form"></div>
<script src="https://filegrab.link/widget/filegrab-widget.umd.js"></script>
<script>
  FileGrabWidget.form({
    formId: 'YOUR_FORM_ID',
    container: '#filegrab-form',
  });
</script>

Replace YOUR_FORM_ID with the ID from your form's settings panel. The form renders inside an iframe with full CSS isolation, so your site's styles won't conflict with the form and vice versa.

Colors

Pass a theme object to override the default colors. All color values should be valid CSS colors (hex, rgb, hsl).

<script>
  FileGrabWidget.form({
    formId: 'YOUR_FORM_ID',
    container: '#filegrab-form',
    theme: {
      primaryColor: '#0d9488',
      backgroundColor: 'transparent',
      textColor: '#1a2e35',
    },
  });
</script>
PropertyTypeDescription
primaryColorstringAccent color for the submit button, focus rings, and active states. Default: #F97316 (orange).
backgroundColorstringForm card background. Use 'transparent' to inherit the host page's background. Default: white.
textColorstringPrimary text color for labels, inputs, and descriptions. Default: near-black.

Fonts

Load custom fonts inside the embedded form's iframe. Use fontCssUrlto point to a stylesheet (like Google Fonts), then set fontFamilyand headingFontFamily.

<script>
  FileGrabWidget.form({
    formId: 'YOUR_FORM_ID',
    container: '#filegrab-form',
    theme: {
      fontCssUrl: 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap',
      fontFamily: "'Inter', sans-serif",
      headingFontFamily: "'Inter', sans-serif",
    },
  });
</script>
PropertyTypeDescription
fontFamilystringCSS font-family for body text, labels, and inputs.
headingFontFamilystringCSS font-family for the form title.
fontCssUrlstringHTTPS URL to a font stylesheet. Loaded inside the iframe before the form renders.

Since the form renders in an iframe, fonts loaded on your host page are not automatically available inside the form. You must provide fontCssUrlso the iframe loads the fonts independently.

Spacing & Layout

Control the spacing, padding, and sizing of form elements to match your site's design language.

<script>
  FileGrabWidget.form({
    formId: 'YOUR_FORM_ID',
    container: '#filegrab-form',
    theme: {
      borderRadius: '8px',
      inputPadding: '16px 24px',
      fieldGap: '32px',
      labelFontWeight: '600',
      labelFontSize: '15px',
      inputFontSize: '16px',
    },
  });
</script>
PropertyTypeDescription
borderRadiusstringBorder radius for the form card and input controls. Default: 10px.
inputPaddingstringCSS padding for text inputs, selects, and textareas. Example: '14px 16px'.
fieldGapstringVertical gap between form fields. Example: '24px'.
labelFontWeightstringFont weight for field labels. Example: '600' for semi-bold.
labelFontSizestringFont size for field labels. Example: '15px'.
inputFontSizestringFont size for input controls. Example: '16px'.

Submit Button

Customize the submit button's shape and typography independently from the rest of the form. The button automatically inherits the font family from the form's fontFamily setting.

<script>
  FileGrabWidget.form({
    formId: 'YOUR_FORM_ID',
    container: '#filegrab-form',
    theme: {
      primaryColor: '#0d9488',
      buttonPadding: '24px 64px',
      buttonFontSize: '16px',
      buttonFontWeight: '600',
      buttonBorderRadius: '9999px',
    },
  });
</script>
PropertyTypeDescription
buttonPaddingstringCSS padding for the submit button. Example: '20px 48px'.
buttonFontSizestringFont size for the submit button text. Example: '16px'.
buttonFontWeightstringFont weight for the submit button text. Example: '600'.
buttonBorderRadiusstringBorder radius for the submit button. Use '9999px' for a pill shape. Default: matches borderRadius.

The button background color is controlled by primaryColor. To create a pill-shaped button, set buttonBorderRadius to '9999px'.

Form Title

Control the font size of the form title heading to match your site's heading scale. Accepts any CSS font-size value including clamp()for responsive sizing.

<script>
  FileGrabWidget.form({
    formId: 'YOUR_FORM_ID',
    container: '#filegrab-form',
    theme: {
      titleFontSize: 'clamp(1.75rem, 3vw, 2.25rem)',
    },
  });
</script>
PropertyTypeDescription
titleFontSizestringFont size for the form title. Example: '2rem' or 'clamp(1.75rem, 3vw, 2.25rem)'. Default: 1.5rem.

The title font family is controlled by headingFontFamily. If not set, it uses the form's display font.

Density Presets

Instead of setting each spacing value individually, use the densitypreset to apply a consistent spacing scale. Individual tokens always override preset values if both are set.

<script>
  FileGrabWidget.form({
    formId: 'YOUR_FORM_ID',
    container: '#filegrab-form',
    theme: {
      density: 'spacious',
    },
  });
</script>
PresetInput PaddingField GapLabel SizeInput SizeButton Padding
compact6px 10px12px12px13px8px 16px
normal(default)(default)(default)(default)(default)
spacious14px 16px28px14px16px20px 48px

You can combine a preset with individual overrides. For example, start withdensity: 'spacious' and override just the button radius:

theme: {
  density: 'spacious',
  buttonBorderRadius: '9999px',
}

Captcha Theme

Every form includes Cloudflare Turnstile bot protection. By default the captcha widget uses a light appearance. On dark backgrounds, switch to'dark' or 'auto' to follow the visitor's system preference.

<script>
  FileGrabWidget.form({
    formId: 'YOUR_FORM_ID',
    container: '#filegrab-form',
    captchaTheme: 'dark',
  });
</script>
ValueDescription
'light'Light captcha widget (default).
'dark'Dark captcha widget for dark-themed sites.
'auto'Follows the visitor's system color scheme preference.

Callbacks

React to form lifecycle events with callback functions.

<script>
  FileGrabWidget.form({
    formId: 'YOUR_FORM_ID',
    container: '#filegrab-form',
    onReady: function() {
      console.log('Form loaded');
    },
    onSubmit: function() {
      console.log('Form submitted successfully');
    },
    onError: function(error) {
      console.error('Submission failed:', error);
    },
  });
</script>
CallbackArgumentsDescription
onReady(none)Called when the form has loaded and is ready for interaction.
onSubmit(none)Called after a successful submission.
onErrorerror: stringCalled when submission fails. The error message is passed as an argument.

Full Example

Here is a complete example that matches a form to a host site using a serif heading font, sans-serif body, teal accent, spacious layout, and a pill-shaped submit button.

<div id="filegrab-form"></div>
<script src="https://filegrab.link/widget/filegrab-widget.umd.js"></script>
<script>
  FileGrabWidget.form({
    formId: 'YOUR_FORM_ID',
    container: '#filegrab-form',
    captchaTheme: 'light',
    theme: {
      // Colors
      primaryColor: '#0d9488',
      backgroundColor: 'transparent',
      textColor: '#1a2e35',

      // Fonts (loaded inside the iframe)
      fontCssUrl: 'https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@400;600&family=Nunito+Sans:wght@400;500;600&display=swap',
      fontFamily: "'Nunito Sans', sans-serif",
      headingFontFamily: "'Cormorant Garamond', Georgia, serif",

      // Spacing
      borderRadius: '8px',
      inputPadding: '16px 24px',
      fieldGap: '32px',
      labelFontWeight: '600',
      labelFontSize: '15px',
      inputFontSize: '16px',

      // Submit button
      buttonPadding: '24px 64px',
      buttonFontSize: '16px',
      buttonFontWeight: '600',
      buttonBorderRadius: '9999px',

      // Title
      titleFontSize: 'clamp(1.75rem, 3vw, 2.25rem)',
    },
    onReady: function() {
      console.log('Form ready');
    },
    onSubmit: function() {
      console.log('Submitted');
    },
  });
</script>

All Options Reference

Complete list of every option accepted by FileGrabWidget.form().

OptionTypeRequiredDescription
formIdstringYesYour form's unique ID (from the form settings panel).
containerstring | HTMLElementYesCSS selector or DOM element where the form renders.
themeobjectNoTheme override object (see sections above).
captchaTheme'light' | 'dark' | 'auto'NoCaptcha widget appearance. Default: 'light'.
onReadyfunctionNoCalled when form is loaded and interactive.
onSubmitfunctionNoCalled after successful submission.
onErrorfunction(error: string)NoCalled when submission fails.

Theme Properties

PropertyTypeCategoryDescription
primaryColorstringColorAccent color (buttons, focus rings).
backgroundColorstringColorForm card background or 'transparent'.
textColorstringColorPrimary text color.
fontFamilystringFontBody font-family.
headingFontFamilystringFontHeading font-family.
fontCssUrlstringFontURL to font stylesheet (loaded in iframe).
borderRadiusstringSpacingCard and input border radius.
inputPaddingstringSpacingInput/select/textarea padding.
fieldGapstringSpacingGap between form fields.
labelFontWeightstringSpacingLabel font weight.
labelFontSizestringSpacingLabel font size.
inputFontSizestringSpacingInput control font size.
buttonPaddingstringButtonSubmit button padding.
buttonFontSizestringButtonSubmit button font size.
buttonFontWeightstringButtonSubmit button font weight.
buttonBorderRadiusstringButtonSubmit button border radius.
titleFontSizestringTitleForm title font size.
density'compact' | 'normal' | 'spacious'PresetSpacing preset (individual tokens override).

ES Module Import

If your site uses a bundler (Vite, webpack, etc.), you can import the ESM build instead:

<script type="module">
  import { form } from 'https://filegrab.link/widget/filegrab-widget.esm.js';

  form({
    formId: 'YOUR_FORM_ID',
    container: '#filegrab-form',
    theme: { primaryColor: '#0d9488' },
  });
</script>

Need Help?

Build your form at /form/new, customize it visually in the form builder, then copy the embed code from the settings panel. Add a theme object to match your site's design.

Questions? Get in touch.