create-figma-plugin
- Add a
ui
template - Simplify the CLI; now, only a
name
,displayName
andtemplate
are necessary
- Add a
-
@create-figma-plugin/build
- Added the ability to override the esbuild configuration for the
main
bundle (via abuild-figma-plugin.main.js
file) and theui
bundle (via abuild-figma-plugin.ui.js
file) - Improve the UX of the
build-figma-plugin --watch --typecheck
terminal output
- Added the ability to override the esbuild configuration for the
-
@create-figma-plugin/monetization
- This is a new package that includes utilities for:
- Tracking the number of plugin runs
- Verifying a Gumroad license key
- This is a new package that includes utilities for:
-
@create-figma-plugin/ui
- New features:
- Added
Banner
andIconButton
components - Added a
validateOnBlur
prop toTextbox
,TextboxNumeric
, andTextboxMultiline
- Added
- Bug fixes:
- Allow pressing
Tab
to hide the menu in theDropdown
component - Fixed a bug for when the
suffix
prop is specified inTextboxNumeric
- Fixed UI bugs in the
useFocusTrap
anduseScrollableMenu
hooks - Middle-aligned the
icon
relative to the height of the textbox in theTextbox
,TextboxAutocomplete
,TextboxNumeric
components - Adjusted the focused style (the height of the blue outlined box) and the selected style (the background color of the selected text) of all textboxes (ie.
Textbox
etc.) to be identical to that in the Figma editor - Prevent menu items in
Dropdown
andTextboxAutocomplete
from wrapping - Dynamically adjust the horizontal menu position of
Dropdown
- Allow pressing
- CSS:
- Added colors
--color-black-6-translucent
,--color-black-3-translucent
, and--color-blue-30-translucent
to@create-figma-plugin/ui/lib/css/base.css
- Added colors
- New features:
-
@create-figma-plugin/utilities
- New features:
convertHexColorToRgbColor
convertNamedColorToHexColor
convertRgbColorToHexColor
isValidHexColor
unsetRelaunchButton
- Bug fixes:
- When
setRelaunchButton
is called, any relaunch buttons (with a differentrelaunchButtonId
) previously set by the plugin on the particular node will be retained rather than overriden
- When
- New features:
@create-figma-plugin/ui
- New features:
TextboxColor
– Added a new component for receiving a user input hex color with opacityDropdown
,TextboxAutocomplete
– Allow individual menu options to bedisabled
SearchTextbox
,Textbox
,TextboxAutocomplete
,TextboxMultiline
,TextboxNumeric
– Added aspellCheck
prop that defaults tofalse
to hide the red squiggly lines from the browser’s spellchecking
- Bug fixes:
Dropdown
,TextboxAutocomplete
– Fixed az-index
bug with the menu, hide the menu on clicking anywhere outside the pluginiframe
(previously the menu only hides when clicking outside the menu but within the pluginiframe
)TextboxNumeric
– Fixed a bug withrevertOnEscapeKeyDown
not working as expected when thesuffix
prop is also setDropdown
– Fixed dynamic positioning of the menuButton
,SearchTextbox
,Textbox
,TextboxAutocomplete
,TextboxMultiline
,TextboxNumeric
– Set thebackground-color
of the root element totransparent
- New features:
create-figma-plugin
- Added
src/**/*.tsx
to the"include"
key of thedefault
template’stsconfig.json
- Added
@create-figma-plugin/ui
- Made the
--box-shadow
style identical to that in the Figma CSS - Fixed the style of disabled options in the
SegmentedControl
component
- Made the
create-figma-plugin
- Included
plugin-templates/*/.gitignore
in the published package - Added a
^
prefix to@create-figma-plugin/*
version numbers in thedefault
template
- Included
- Improved documentation
Note: 1.0.0 requires Node.js v14.
@create-figma-plugin/build@1
@create-figma-plugin/tsconfig@1
@create-figma-plugin/ui@1
@create-figma-plugin/utilities@1
-
The
build-figma-plugin
CLI is now powered by esbuild, replacing Webpack. esbuild is extremely fast, and building any non-trivial plugin should reliably take less than 1 second. (esbuild actually runs within a couple hundred milliseconds, but some parts of the build process – compiling and generating.d.ts
files for CSS modules, generating themanifest.json
file – still runs in Node.js-land.) -
Given the move away from Webpack, the ability to override the build process via a
figma-plugin.config.js
file has also been removed. -
Minification and type checking of your plugin code is now disabled by default in the
build-figma-plugin
CLI. Thebuild
andwatch
scripts in yourpackage.json
should be updated as follows:{ ... "scripts": { - "build": "build-figma-plugin", + "build": "build-figma-plugin --typecheck --minify", - "watch": "build-figma-plugin --watch", + "watch": "build-figma-plugin --typecheck --watch", ... }, ... }
-
The ability to use SCSS in CSS Modules has been removed. Now, only “vanilla” CSS Modules is supported. To migrate, use the
sass
CLI to do a one-off conversion of your.scss
files to.css
, then update your UI code to reference the generated.css
files. -
There’s now a JSON schema for validating the plugin configuration in your
package.json
file. To enable autocomplete and inline validation of your plugin configuration in Visual Studio Code, create a.vscode/settings.json
file containing the following:{ "json.schemas": [ { "fileMatch": [ "package.json" ], "url": "https://yuanqing.github.io/create-figma-plugin/figma-plugin.json" } ] }
-
The
tsconfig.json
file has changed significantly, given the move to esbuild.{ "compilerOptions": { "esModuleInterop": true, "isolatedModules": true, "jsx": "react", "jsxFactory": "h", "lib": ["DOM", "ES2020"], "module": "ES2020", "moduleResolution": "Node", "strict": true } }
-
Either copy the above to your project’s
tsconfig.json
, or directly extend from@create-figma-plugin/tsconfig
. You should at least ensure that the"isolatedModules"
option is enabled in yourtsconfig.json
.
-
There are many breaking changes and new features. Your best bet for migrating to
v1
might be to try to build your plugin using thebuild-figma-plugin --typecheck --watch
command, and then incrementally fixing the errors surfaced by the TypeScript compiler. Otherwise, refer to usage examples of all the components in the Storybook, or see below for a detailed breakdown of all component changes. -
One of the most significant changes is that the
onChange
prop of all components now has the signature(event: JSX.TargetedEvent<HTMLInputElement>) => void
. See the before and after, using theCheckbox
component as an example:// Before `v1` const [state, setState] = useState({ foo: false }) // ... <Checkbox name="foo" onChange={setState} value={state.foo}> Text </Checkbox>
// `v1` const [value, setValue] = useState(false) function handleChange(event: JSX.TargetedEvent<HTMLInputElement>) { const newValue = event.currentTarget.checked console.log(newValue) //=> either `true` or `false` setValue(newValue) } // ... <Checkbox onChange={handleChange} value={value}> Text </Checkbox>
-
An alternative to using the
onChange
prop to listen to state changes is to use the newonValueChange
prop. This prop is available on all components that also have anonChange
prop. TheonValueChange
handler has the signature<Value, Name extends string>(newValue: Value, name?: Name) => void
, and it is called on every DOMchange
event. The secondname
parameter passed to the handler is precisely thename
prop that was set on the component. Again, using theCheckbox
component as an example:const [value, setValue] = useState(false) function handleChange(newValue: boolean, name: undefined | string) { console.log(newValue) //=> either `true` or `false` console.log(name) //=> 'foo' setValue(newValue) } // ... <Checkbox name="foo" onValueChange={handleValueChange} value={value}> Text </Checkbox>
-
The
onChange
prop has been removed from theSearchTextbox
,Textbox
,TextboxAutocomplete
, andTextboxNumeric
components. (This prop was inaccurately named for these components because the handler is actually called on every DOMinput
event.) Instead, use theonInput
andonValueInput
props to handle the DOMinput
event. -
The
DropdownMenu
component has been removed. Use the newDropdown
component, which has an improved UI design and component API. -
All component styles are now written as “vanilla” CSS modules rather than SCSS. The previous SCSS variables are now expressed as CSS variables on
:root
. Refer to thebase.css
file in@create-figma-plugin/ui
for the list of CSS variables that are available for use in your custom CSS. -
Added new components
Dropdown
,MiddleAlign
,TextboxMultiline
andToggle
, in addition to 175 icon components extracted from Figma’s official “UI2” design system file on Figma Community.
-
All icons are now exported as Preact functional components. Refer to the following mapping to migrate existing icons to their equivalents in
v1
:checkCircleIcon
→<IconCheckCircle32 />
checkIcon
→<IconMenuCheckmarkChecked16 />
componentIcon
→<IconLayerComponent16 />
crossIcon
→<IconCross32 />
frameIcon
→<IconLayerFrame16 />
imageIcon
→<IconLayerImage16 />
moveDownIcon
→<IconMoveDown16 />
moveRightIcon
→<IconMoveRight16 />
searchIcon
→<IconSearch32 />
spaceHorizontalIcon
→<IconSpacingHorizontal16 />
spaceVerticalIcon
→<IconSpacingVertical16 />
Note that
IconCheckCircle32
,IconCross32
andIconSearch32
all have a dimension of32px
, which is double the size of the corresponding icons in versions of@create-figma-plugin/ui
prior tov1
. -
All icons also now take a
color
prop for customizing thefill
colour of the iconsvg
.
- The
focused
prop has been removed.
- The
focused
prop has been removed. - The
onChange
prop now has the signature(event: JSX.TargetedEvent<HTMLInputElement>) => void
. - There’s a new
onValueChange
prop with the signature(newValue: boolean, name?: string) => void
.
- The
focused
andonClick
props have been removed. - The
onSelectedFiles
prop now has the signature(files: Array<File>) => void
.
- The
onSelectedFiles
prop now has the signature(files: Array<File>) => void
.
- This component has an almost entirely new API. (The
onClick
,selected
, andtype
props have been removed. New props includebold
,onChange
,onValueChange
,icon
,color
, andvalue
.)
- There’s a new
color
prop for customizing thefill
colour of thesvg
representing the loading indicator.
- The
value
prop can now benull
, or aboolean
,number
, orstring
. - The
focused
prop has been removed. - The
onChange
prop now has the signature(event: JSX.TargetedEvent<HTMLInputElement>) => void
. - There’s a new
onValueChange
prop with the signature(newValue: boolean | number | string, name?: string) => void
. - For the
RadioButtonsOption
type:- The
text
key has been renamed tochildren
. value
can now only be aboolean
,number
, orstring
.
- The
- The
focused
andonChange
props have been removed. - There’s a new
onInput
prop with the signature(event: JSX.TargetedEvent<HTMLInputElement>) => void
. - There’s a new
onValueInput
prop with the signature(newValue: string, name?: string) => void
.
- The height of the component is now
24px
(reduced from36px
) to be identical to the height of segmented controls in the Figma editor UI. - The style of the component’s focused state has been tweaked to follow that of segmented controls in the Figma editor UI.
- The
value
prop cannot benull
and can now only be aboolean
,number
, orstring
. - The
focused
prop has been removed. - The
onChange
prop now has the signature(event: JSX.TargetedEvent<HTMLInputElement>) => void
. - There’s a new
onValueChange
prop with the signature(newValue: boolean | number | string, name?: string) => void
. - In the
SegmentedControlOption
type:- The
text
key has been renamed tochildren
. value
cannot benull
and can now only be aboolean
,number
, orstring
.
- The
- The
onKeyDown
prop has been removed. - The
onChange
prop now has the signature(event: JSX.TargetedEvent<HTMLInputElement>) => void
. - There’s a new
onValueChange
prop with the signature(newValue: boolean, name?: string) => void
.
- The
focused
prop has been removed. - The
onChange
prop now has the signature(event: JSX.TargetedEvent<HTMLInputElement>) => void
. - There’s a new
onValueChange
prop with the signature(newValue: string, name?: string) => void
. - In the
TabsOption
type:- The
disabled
andtext
keys have been removed. - The
view
key has been renamed tochildren
. value
can now only be astring
.
- The
- The height of the component is now
28px
(reduced from32px
) to be identical to the height of textboxes in the Figma editor UI. - The
value
prop cannot benull
and can now only be astring
.- A “Mixed” value is represented by the
MIXED_STRING
constant from@create-figma-plugin/utilities
.
- A “Mixed” value is represented by the
- The
focused
,onChange
, andtype
props have been removed. - There’s a new
onInput
prop with the signature(event: JSX.TargetedEvent<HTMLInputElement>) => void
. - There’s a new
onValueInput
prop with the signature(newValue: string, name?: string) => void
. - There’s a new
password
prop for changing the display to a password field. (Previously, you’d set thetype
prop to'password'
.) - There’s a new
revertOnEscapeKeyDown
prop to enable reverting the originalvalue
when theEsc
key is pressed.
- The height of the component is now
28px
(reduced from32px
) to be identical to the height of textboxes in the Figma editor UI. - The height of the autocomplete menu will dynamically expand (while still keeping within the dimensions of
window
) so as to fit as many items as possible in the menu. - The
focused
andonChange
props have been removed. - There’s a new
onInput
prop with the signature(event: JSX.TargetedEvent<HTMLInputElement>) => void
. - There’s a new
onValueInput
prop with the signature(newValue: string, name?: string) => void
. - There’s a new
revertOnEscapeKeyDown
prop to enable reverting the originalvalue
when theEsc
key is pressed.
- The height of the component is now
28px
(reduced from32px
) to be identical to the height of textboxes in the Figma editor UI. - The
value
prop cannot benull
and can now only be astring
.- A “Mixed” value is represented by the
MIXED_STRING
constant from@create-figma-plugin/utilities
.
- A “Mixed” value is represented by the
- The
focused
, andonChange
props have been removed. - There’s a new
onInput
prop with the signature(event: JSX.TargetedEvent<HTMLInputElement>) => void
. - There’s a new
onValueInput
prop with the signature(newValue: string, name?: string) => void
. - There’s a new
onNumericValueInput
prop with the signature(newValue: null | number, name?: string) => void
, wherenewValue
is the result of evaluatingvalue
as a numeric expression.- If
value
is the empty string, thennewValue
is null. - If
value
is theMIXED_STRING
constant from@create-figma-plugin/utilities
, thennewValue
will be theMIXED_NUMBER
constant from the same.
- If
- There’s a new
revertOnEscapeKeyDown
prop to enable reverting the originalvalue
when theEsc
key is pressed. - There’s a new
suffix
prop for automatically appending an arbitrary string to the numeric textbox.
compareArrays
has been removed. UsecompareObjects
instead.isWithinInstance
has been renamed toisWithinInstanceNode
.computeSiblingNodes
,deduplicateNodes
,sortNodesByCanonicalOrder
, andsortNodesByName
all now take a type parameter<Node extends SceneNode>
. This type parameter allows these functions to accept and return arrays of specific node types, rather than merely an array ofSceneNode
.loadSettingsAsync
andsaveSettingsAsync
both now take an optional second argument for customizing the key for loading from or saving tofigma.clientStorage
.- Added new utilities
compareStringArrays
,getParentNode
, andgetSceneNodeById
.