Craft

Craft is the standard guideline for building with Webstudio.

Work in progress. Contribute your thoughts on this guide by commenting on this GitHub Discussion. Coming up with the standard is a community effort.

When building highly maintainable and scaleable websites, some conventions prove to work well. Plus, when collaborating with team members and other creators, a standardized system results in a smoother learning curve and easier sharing, such as through the Marketplace.

Craft is a set of standards, CSS variables, and guidelines that make building websites fast, flexible, and maintainable. It also enables sharing without our websites becoming cluttered with other people’s CSS variables, Tokens, and naming conventions.

While Craft is not mandatory, it’s the recommended way to build in Webstudio.

Here are the standards and guidelines of Craft.

CSS Variables

Craft uses Open Props, an MIT-licensed library of CSS variables that helps accelerate adaptive and consistent design.

Insert Craft from the Marketplace, and it will add the CSS variables to your Global Root. To match your branding, you can customize the values, such as colors, gradients, and more. You can also add custom variables.

CSS Props doesn't impose style opinions on your site. This library contains variables like --size-4 and --gradient-5. Then, it's up to you to customize their values or use the defaults.

Tokens

When to use Tokens vs Local?

Use Tokens for the following scenarios:

  • There are multiple styles and at least one of which has many options for the value (e.g., size and colors) as opposed to something like text alignment.

  • When there is a common use case that takes more time to select Local and apply manually than using a Token, such as setting the margin left and right to auto.

Don't use Tokens for the following scenarios:

  • When you can click an item in the Style Panel, such as text alignment or display flex.

  • When there is only one style (use CSS variables).

More info:

Tokens are great for reusing styles, so you don't have to remember values. They shouldn't be used for simple tasks like centering text since that can be done with a button, and when switching between breakpoints, you may want to adjust the alignment.

However, Tokens can be helpful for flex layouts, for example, when they fall into this rule:

Common use case that takes more time to select Local and apply manually than using a Token.

For example, it's common to use a flex wrapper to add a gap to the content, which typically requires setting display to flex, direction to vertical, and adding a gap. It's faster to create a utility token like flex-gap-small that handles all this in one go.

Internal Style Guide

The page on the site is used to display and design the various HTML elements like headings, components, brand elements, and more.

Structure

  • Page Wrapper

    • Slot

      • Global Styles

      • Nav

    • Main

      • Section (generally, but not always)

        • Container

    • Slot

      • Footer

Misc

Abbreviations

Avoid abbreviations unless otherwise noted. Universal clarity is a priority, and abbreviations may be counterproductive.

HTML Embed

  • 1 instance = 1 purpose

  • Start the code with a comment about its purpose

Last updated