README.md

November 12, 2017 · View on GitHub

icon
Framer Input


banner

INTRODUCTION

From inputs in Design to fully functional ones in Code. A Framer module that allows you to create single-line and multi-line input fields in Code and Design. Complete with an interactive iOS keyboard simulator.

Watch the video.


Overview

All included properties and methods.

PropertiesTypeDescription
new InputLayerClassInitiate a new Input object.
InputLayer.wrapMethodWrap input object around two layers.
InputLayer.valueStringText value of input layer.
InputLayer.focusColorColorColor of input layer on focus.
InputLayer.multiLineBooleanSingle or multi-line input field.
InputLayer.onEnterKeyEventOn return key press.
InputLayer.onSpaceKeyEventOn space key press.
InputLayer.onBackSpaceKeyEventOn backspace key press.
InputLayer.onCapsLockKeyEventOn caps space key press.
InputLayer.onShiftKeyEventOn shift key press.
InputLayer.onValueChangeEventOn input key press.
InputLayer.onInputFocusEventOn input focus.
InputLayer.onInputBlurEventOn input blur.

Design Guide

First, grab the input.coffee file and place it within the /modules folder (located within your .framer folder). Then, to include the module, require the Input class:

{InputLayer} = require "input"

Once you have created a simple input field in Design, you can make the wrapper layer (background) and the placeholder copy (text) targetable, and wrap them in Code.

The InputLayer.wrap method takes two parameters:

  • background — The background layer of the input field.
  • text — The placeholder text layer of the input field.
input = InputLayer.wrap(background, text)

Now, the input field is functional. It automatically sets a focusColor for you (changes the color of the text), but this is completely customizable. The input object has its own onValueChange method. To use the text contents as you’re typing, simply reference the value property in combination with the event.

input.onValueChange ->
	print input.value 

The wrap method allows you to pass in optional properties, too. For instance, if you’d like to create a multiLine input field (also known as a textarea), you can simply pass it along:

input = InputLayer.wrap(bg, text, multiLine: true)

Code Guide

New InputLayers can be initiated in Code, too.

input = new InputLayer

This will create a functional input field, with its default placeholder. Note that the InputLayer class is based on the TextLayer class, and thus will inherit its properties and methods as well.

input = new InputLayer
	text: "Placeholder"

To style the placeholder text, you can use all of the TextLayer properties.

input.fontSize = 40
input.fontWeight = 600
input.color = "red"

The Input class has its own onValueChange method, too. To use the text contents as you’re typing, simply reference the value property in combination with the event.

input.onValueChange ->
	print input.value 

Examples

More Resources


Contact