Code snippets π©βπ»
Here's a collection of great code snippets that we have found on the internets that work great with Sketch2React.
Last updated
Here's a collection of great code snippets that we have found on the internets that work great with Sketch2React.
Last updated
Copy the code to a blank new text document, we usually use Visual Studio Code or Sublime Text
You can use all of these snippets in the same document just don't forget when saving to add .css or .js to the name of the document e.g. mycustomcode.css or mycustomcode.js
Use the class name e.g .link and enter it like this [link] on any of our components π
Drag the newly created .css or .js file to the Macs Terminal app, you will need the correct file path for linking this inside Sketch
Copy the file entire file path to clipboard, it usually starts with /Users/β¦
In Sketch use the Text tool and copy the file path from clipboard into your artboard
Add file:// just before /Users/etcetc ending up with file:///Users/etcetcβ¦
In the Side Panel name the text layer {externalasset.css} or {externalasset.js}
Make sure to copy the text layer to all of the artboards using your custom code
You can add as many {externalasset} layers as you need
Open up the folder Experimental that comes with your Sketch2React 2021 + license purchase
Install the plugin called sketch2react-code.sketchplugin
Open up Sketch, create a new document and create your Sketch2React magic
Launch our code editor plugin
Select the artboard where you want to add your custom CSS code
Paste the code into our code editor and hit the save button
Copy the class names e.g. link onto the ones of our components that you want to customize or alter with your own code
Save in Sketch
Open the same Sketch file in Sketch2React Beta and do a happy dance π―ββοΈ
Creates a simple animated line under any component that uses our {link} component. Feel free to change the height, color animation or anything else.
πOriginal source
A great trick to balance your designs in code is to use equal heights on things such as column backgrounds etc. Here's a neat snippet using only css flexbox.