Generate all the Sketch text styles you have based on a config set up in your artboards. No more making and maintaining multiple variations!
If your text style system requires the use of different alignments or colour variations you are faced with either detaching styles, risking updates overwrite the tweaks you make or you manually have to create every style.
This plugin aims to solve the generation and maintenance of Sketch text styles where you need colour and alignment variations of your text styles.
Either install via Sketchpacks, Sketch Runner or...
- Download from the releases page
- Unzip
- Double Click on
text-to-styles.sketchplugin
This is an opinioated plugin on how Text Styles should be named. The naming convention is:
Style Name/Colour/Alignment/Breakpoint Varation
The breakpoint variation is optional.
There is a sample project under sample/text-styles-sample.sketch to base your text and colour tokens off
You will need to set your Page structure and naming like this:
- Styles
- Colours or Colors
- Alignments
Please note that this is case sensitive!
Add your base text styles here. This plugin will pick up on:
- Font Family
- Font Size
- Font Weight
- Font Style
- Line Height
- Letter Spacing
- Text Transform (uppercase,lowercase)
- Paragraph Spacing
If you wish to add breakpoint adjustment for styles use the following naming syntax for the layer
Style Name/Breakpoint Variation
e.g.
Heading 1/BP1
The plugin will then split the name and add the breakpoint to the end of the text style name
Add shapes here with the colour value you want to render. The name of the layer defines the name in the Text Style palette. Order is done alphabetically.
Add your alignments here by setting each text layer to your preffered alignment. Order is set Left, Center, Right.
There are several commands available Run Document Setup
, Create Text Styles
, Render Style Sheet
and Export JSON Tokens
Sets up the Sketch document Page names with sample Styles, Alignments and Colors. You can then remove or modify them as you see fit.
Converts the contents of Styles, Alignments and Colors into text styles.
This will reate a Page called "Rendered Styles" and create every combination within your text styles. Please make sure you have run the Create Text Styles command before.
This command can take a long time to run. The more combinations the longer it will take.
This will export out the text styles and colour palettes as a JSON file to use in other applications. Perhaps your production code base or documentation.
You will be presented with two options for formatting the text style json. Either an Array or an Object. Depending on your needs you may want the Object.
{
"name": "Style 1",
"styles": {
"fontFamily": "SFProDisplay-Semibold",
"fontSize": "28px",
"lineHeight": "34px",
"fontWeight": 8,
"paragraphSpacing": 25,
"letterSpacing": "0.02em",
"textTransform": "none"
},
"alignments": [
"left",
"right",
"center"
],
"adjustments": [
{
"name": "BP3",
"styles": {
"fontSize": "42px",
"lineHeight": "48px",
"paragraphSpacing": 100,
"letterSpacing": "0.03em"
}
}
]
}
"Style 1": {
"name": "Style 1",
"styles": {
"fontFamily": "SFProDisplay-Semibold",
"fontSize": "28px",
"lineHeight": "34px",
"fontWeight": 8,
"paragraphSpacing": 25,
"letterSpacing": "0.02em",
"textTransform": "none"
},
"alignments": [
"left",
"right",
"center"
],
"adjustments": [
{
"name": "BP3",
"styles": {
"fontSize": "42px",
"lineHeight": "48px",
"paragraphSpacing": 100,
"letterSpacing": "0.03em"
}
}
]
}
@tbrasington | tbrasington.com