Skip to content
Snippets Groups Projects
Select Git revision
  • move-gl-dropdown
  • improve-table-pagination-spec
  • move-markdown-preview
  • winh-fix-merge-request-spec
  • master default
  • index-namespaces-lower-name
  • winh-single-karma-test
  • 10-3-stable
  • 36782-replace-team-user-role-with-add_role-user-in-specs
  • winh-modal-internal-state
  • tz-ide-file-icons
  • 38869-milestone-select
  • update-autodevops-template
  • jivl-activate-repo-cookie-preferences
  • qa-add-deploy-key
  • docs-move-article-ldap
  • 40780-choose-file
  • 22643-manual-job-page
  • refactor-cluster-show-page-conservative
  • dm-sidekiq-versioning
  • v10.4.0.pre
  • v10.3.0
  • v10.3.0-rc5
  • v10.3.0-rc4
  • v10.3.0-rc3
  • v10.3.0-rc2
  • v10.2.5
  • v10.3.0-rc1
  • v10.0.7
  • v10.1.5
  • v10.2.4
  • v10.2.3
  • v10.2.2
  • v10.2.1
  • v10.3.0.pre
  • v10.2.0
  • v10.2.0-rc4
  • v10.2.0-rc3
  • v10.1.4
  • v10.2.0-rc2
40 results

scss_styleguide.md

Blame
  • Forked from GitLab.org / GitLab FOSS
    20404 commits behind the upstream repository.
    scss_styleguide.md 4.34 KiB

    SCSS styleguide

    This style guide recommends best practices for SCSS to make styles easy to read, easy to maintain, and performant for the end-user.

    Rules

    Naming

    CSS classes should use the lowercase-hyphenated format rather than snake_case or camelCase.

    // Bad
    .class_name {
      color: #fff;
    }
    
    // Bad
    .className {
      color: #fff;
    }
    
    // Good
    .class-name {
      color: #fff;
    }

    Formatting

    You should always use a space before a brace, braces should be on the same line, each property should each get its own line, and there should be a space between the property and its value.

    // Bad
    .container-item { 
      width: 100px; height: 100px;
      margin-top: 0;
    }
    
    // Bad
    .container-item
    {
      width: 100px;
      height: 100px;
      margin-top: 0;
    }
    
    // Bad
    .container-item{
      width:100px;
      height:100px;
      margin-top:0;
    }
    
    // Good
    .container-item {
      width: 100px;
      height: 100px;
      margin-top: 0;
    }

    Note that there is an exception for single-line rulesets, although these are not typically recommended.

    p { margin: 0; padding: 0; }

    Colors

    HEX (hexadecimal) colors should use shorthand where possible, and should use lower case letters to differentiate between letters and numbers, e.g. #E3E3E3 vs. #e3e3e3.

    // Bad
    p {
      color: #ffffff;
    }
    
    // Bad
    p {
      color: #FFFFFF;
    }
    
    // Good
    p {
      color: #fff;
    }

    Indentation

    Indentation should always use two spaces for each indentation level.

    // Bad, four spaces
    p {
        color: #f00;
    }
    
    // Good
    p {
      color: #f00;
    }

    Semicolons

    Always include semicolons after every property. When the stylesheets are minified, the semicolons will be removed automatically.

    // Bad
    .container-item {
      width: 100px;
      height: 100px
    }
    
    // Good
    .container-item {
      width: 100px;
      height: 100px;
    }