import{a as o,t as n}from"./disclose-version.CXHRVq_p.js";import{n as i}from"./runtime.Br9mCy3B.js";const l={title:"Sketch App — A (better) responsive button using Symbols",description:"Using Symbol Overrides to pin/stretch/edit globally",date:"2017-06-17T23:16:14.995Z",keywords:[],slug:"/sketch-app-a-better-responsive-button-using-symbols-53df1b61a47a",published:!0};var s=n('<h2>The Problem</h2> <p>There have been many articles written trying to solve the problem of making consistent buttons within a Sketch file. Problems with these methods include:</p> <ul><li>Not being able to measure the actual distance between button elements and other elements on the page</li> <li>Inconsistent “padding” between the centered text of the button and its edges</li> <li>Not using Sketch symbols at all, and preventing file-level changes to the buttons later on</li></ul> <p>As designers, we must ensure that our hi-fi mockups and prototypes are both pixel-perfect and quick to build. In some cases, these demands require a trade-off between one or the other. Since the introduction of the “Pin on resize” feature in Sketch (and thanks to a plugin or two), we can build our mockups/prototypes quickly and <em>consistently</em> — avoiding confusion in user tests and downstream development.</p> <h2>A Better Solution</h2> <p><img src="/img/medium/1__1FtzSmGXES6ffvKFAFyckg.gif" alt="Much Fast. Such Easy. Wow."> Much Fast. Such Easy. Wow.</p> <h2>What You’ll Need</h2> <ul><li>Sketch 44.1 (or later)<br> (previous versions might break “pinning” in symbols)</li> <li><a href="https://github.com/kenmoore/sketch-relabel-button" rel="nofollow">Button (by Ken Moore)</a></li> <li>Optional: <a href="https://github.com/romannurik/Sketch-ArtboardTricks" rel="nofollow">Artboard Tricks</a> OR <a href="https://support.invisionapp.com/hc/en-us/articles/208434046-Craft-Introduction-to-the-Library-plugin" rel="nofollow">Craft Library</a> (to keep things organized)</li></ul> <h2>How To</h2> <p>First, make your ideal button. As an example, I’ll copy the material design one:</p> <p><img src="/img/medium/1__tNrEZtuMhncnpPKvyvnLEA.png"></p> <h2>Creating the Symbol Button</h2> <p>Then, create a symbol out of the button:</p> <p><img src="/img/medium/1__fSNpO0XdOTgckKUqNE3gMA.png"></p> <p>Double-click the button to navigate to it on the symbol page. Select its background and create another symbol out of it:</p> <p><img src="/img/medium/1__vsUZnL5KijKZOy3dujBmlw.png"></p> <p>To finish up your symbol, click the text in the middle and change its <strong>Resizing</strong> properties to “Pin object to all edges on resize”:</p> <p><img src="/img/medium/1__MB__1PORPrKMNH__8qdAoqLA.png"></p> <h2>Using the Symbol Button</h2> <p>Go ahead and create a new button by inserting from your symbols list:</p> <p><img src="/img/medium/1__KyTJR__Apsu9LEn8cSKOClw.png"></p> <p>Then, use the “Button” plugin (CMD+J) to change the text and width of the button:</p> <p><img src="/img/medium/1__rYBQK0J1phQR5CEqkgIbHQ.png"></p> <p>Clicking “OK” will change the <em>Text</em> property in the symbol’s <strong>Overrides</strong> and resize the button to keep a consistent padding between the text and the button edges!</p> <p><img src="/img/medium/1__LedsxnbnnWwHiLhdZxN7FQ.png"></p> <p>Pretty cool right?</p> <h2>Changing the Button’s Color</h2> <p>Symbol Overrides also let you change the color of the button quickly and easily. To do so, simply copy the <code>base</code> color you made earlier and change its color:</p> <p><img src="/img/medium/1__w__jLLYL5xPYsjIqlBdJKJA.gif"></p> <p>Then, navigate to the Button whose color you’d like to change, and change its <code>base</code> in <strong>Overrides</strong>:</p> <p><img src="/img/medium/1__AmQk84TLLU2WCZc9ApmHOA.png"></p> <p><em>Viola</em> a blue button!</p> <p><img src="/img/medium/1__fkDqbwabTHoHHMcELBAw5A.png"></p> <h2>Buttons with Icons</h2> <p>For buttons with icons, you can follow a similar pattern, just make sure you pin your elements correctly:</p> <p><img src="/img/medium/1__P__EnpRX7RUSqWfEjWKdP1Q.png"></p> <p>For a button with an icon on the left, enable “Pin object to the left edge on resize” for the icon. All of the other settings for your button can remain the same.</p> <p><strong>To be able to switch out the icons, make sure their symbols are all the same size.</strong></p> <p>Here is an example of it in action:</p> <p><img src="/img/medium/1__zgIdiejvuu9caJHDjo__Dyw.gif"></p> <p>Combine the ability to switch out icons with your color/text switching workflows and you’ve got a pretty slick set of key strokes to quickly build consistent UI elements!</p> <h2>Keeping Organized (optional)</h2> <p>Once you’ve created a variety of buttons, bases, and colors, it can get cumbersome to keep everything organized. To lighten the load of managing your symbols, I recommend following the naming conventions outlined by Javier ‘Simón’ Cuello in <a href="https://medium.com/sketch-app-sources/sketch-symbols-b36f7355414a" rel="nofollow">Unleashing The Full Potential Of Symbols In Sketch</a>.</p> <p>Sometimes, you may need to find a particular symbol visually, rather than in a list. For this case, I recommend using <a href="https://github.com/romannurik/Sketch-ArtboardTricks" rel="nofollow">Artboard Tricks by Roman Nurik</a> to sort your artboards into a grid and move them into an organized layout. Luckily, Sketch made selecting and moving artboards easier by making that the default selection method.</p> <p>Alternatively, InVision’s Craft also provides a great way to keep your symbols organized with Library. This adds an extra UI overlay to easily sort and filter your symbols, as well as share them across your organization:</p> <p><img src="/img/medium/1__e3v8oH5UK__i__baa3TwW__Sw.png"></p> <h2>Did I miss something?</h2> <p>Is there a use-case I didn’t capture in this blog post? Maybe you were wondering if you can use the Button plugin for other text elements like Tooltips or Toast notifications (hint: you can). <strong>Please let me know in the comments below!</strong></p>',1);function m(e){var t=s();i(94),o(e,t)}export{m as default,l as metadata};
