MotivationInstallDocsCustomize
MotivationInstallDocsCustomize
  • Overview
  • Important! Purge!
  • Getting Started
    • Colors and Pseudo Classes
      • Colors
        • Color Shades

        • Psuedo Classes

      • Classes with Colors
        • Text Color

        • Background Color

        • Border Color

        • Outline Color

        • Text Decoration

        • Selection

      • Transitions
        • Transition Classes

        • With Pseudo Classes

      • Additional Classes
        • Font Size

        • Font Family

        • Font Weight

        • Text Decoration & Style

        • Border Width & Style

        • Outline Width & Style

    • Dark Mode
      • With JS

      • No JS

      • Grid
        • Class Definitions

        • Responsive Examples

        • Responsive Examples
          • Breakpoints

          • Max Breakpoints

          • Examples

          • Margin
            • Classes

            • Examples

          • Padding
            • Classes

            • Examples

          • Border Width
            • Classes

            • Examples

          • Outline Width
            • Classes

            • Outline Offset

            • Examples

          • Width
            • Rem Values

            • Percantage Values

            • Screen relative Values

            • XS - XL

          • Height
            • Rem Values

            • Percantage Values

            • Screen relative Values

            • XS - XL

          • Display
          • Flex
            • Flex Direction

            • Flex Wrap

            • Shrink & Grow

            • Justify Content

            • Align Content

            • Align Items

            • Align Self

            • Not Included

          • Text/Font
            • Font Size

            • Line Height

            • Letter Spacing

          • Position
            • Top Left Right & Bottom

          • Overflow
            • Overflow x & y

          • Box Sizing
        • Box-Shadow
          • Size

          • Color

          • Respoinsive

          • Psuedo States

          • Other Utilities
            • Text/Font
              • Align

              • Transform

              • Indent

              • Wrap

              • Font Family

              • Font Weight

              • Font Style

              • Text Decoration

              • Decoration Thickness

            • Border
              • Directional Style

            • Outline Style
            • Cursor
            • Opacity
            • Visibility
            • z-Index

          Simple Scss Utilities


          Width

          How to use

          Width and height have a lot of different utiltiy classes. I'm much more of a coder than a designer (or writer) so when I do try to come up with a design on my own I'm always endlessly tweaking things. Which means that for me to be satifsfied with height and width utility classes, (and to a lesser extent, position0), they need to have lots of possible values.

          Clean maintaiable code is the only way projects will ever work well. However, if you're lucky enough to have a good designer who can give you good mockups, it's important to match it as cloesly as you can. Ideally, you will be able to have super clean code while still matching the design closely enough that no one can tell the difference without making some serious effort at insepction.

          So, that's why I have every possible position based value used with anything else alsow working with heights and widths. And of course, these all can be edited in _variables.scss if you need different values/or more!

          Width Rem Values

          I find myself assigning widths with REM based values quite often. All these clases will work for min-width and max-width as well.

          ClassCSS rule
          .w-1width: 1rem;
          .w-2width: 2rem;
          .w-3width: 3rem;
          .w-4width: 4rem;
          .w-5width: 5rem;
          .w-6width: 6rem;
          .w-7width: 7rem;
          .w-8width: 8rem;
          .w-10width: 10rem;
          .w-12width: 12rem;
          .w-16width: 16rem;
          .w-20width: 20rem;
          .w-24width: 24rem;
          .w-30width: 30rem;
          .w-36width: 36rem;
          .w-42width: 42rem;
          .w-48width: 48rem;
          .w-56width: 56rem;
          .w-64width: 64rem;
          .w-72width: 72rem;
          .w-80width: 80rem;

          Examples

          Here's some examples of the rem based width classes:

          .w-4

          .w-12

          .w-24

          HTML
          <div class="text-white">
          <div class="w-4 h-4 bg-blue center-start pl-md sizing-border mb-sm">
          <p>.w-4</p>
          </div>
          <div class="w-12 h-4 bg-blue center-start pl-md sizing-border mb-sm">
          <p>.w-12</p>
          </div>
          <div class="w-24 h-4 bg-blue center-start pl-md sizing-border mb-sm">
          <p>.w-24</p>
          </div>
          </div>

          Min, Max, and Responsive Examples

          Of course all these classes can can be prefixed with min-, max-, as well as responsive breapoints. If you're on a browser change the screen widths to see how they work (on small sizes you'll have to close the sidebar).

          .min-w-42 .max-w-48

          This will break out of the right margins on small displays, as the min width is greater than small screen widths.

          .w-24 .tab:w-30 .scr:w-36 .lg:w-48

          This div will change size responsively based on screen size.

          .w-48 .max-scr:w-24

          Another responsive exmple with max:scr with a width of 24 on sizes below 1024px (the default scr breakpoint).

          HTML
          <div
          class="min-w-36 max-w-48 h-4 bg-blue center-start pl-md sizing-border mb-sm text-white"
          >
          <p>.min-w-42 .max-w-48</p>
          </div>
          <p>
          This will break out of the right margins on small displays, as the min width
          is greater than small screen widths.
          </p>
          <div
          class="h-4 w-24 tab:w-30 scr:w-36 lg:w-48 bg-blue center-start pl-md sizing-border mb-sm text-white"
          >
          <p>.w-24 .tab:w-30 .scr:w-36 .lg:w-48</p>
          </div>
          <p>This div will change size responsively based on screen size.</p>
          <div
          class="h-4 w-48 max-scr:w-24 bg-blue center-start pl-md sizing-border mb-sm text-white"
          >
          <p>.w-48 .max-scr:w-24</p>
          </div>
          <p>
          Another responsive exmple with max:scr with a width of 24 on sizes below
          1024px (the default `scr` breakpoint).
          </p>

          Width Percentage Values

          It is also handy to have percentage based values (represented by fractions). I think it is a good balance of usefullness and number of classes to have them increment in steps of about 5% (plus classes for 3rd's). Classes are not repeated, for example, there is a 1/10 class but not a 2/20 class because that would give the same % value. All these can be prefixed with min and max as well as breakpoint prefixes:

          ClassCSS rule
          .w-0width: 1rem;
          .w-1/2width: 2rem;
          .w-1/3width: 3rem;
          .w-1/4width: 4rem;
          .w-3/4width: 5rem;
          .w-1/5width: 6rem;
          .w-2/5width: 7rem;
          .w-3/5width: 8rem;
          .w-4/5width: 10rem;
          .w-1/10width: 12rem;
          .w-3/10width: 16rem;
          .w-7/10width: 20rem;
          .w-9/10width: 24rem;
          .w-1/20width: 30rem;
          .w-3/20width: 36rem;
          .w-7/20width: 42rem;
          .w-9/20width: 48rem;
          .w-11/20width: 56rem;
          .w-13/20width: 64rem;
          .w-17/20width: 72rem;
          .w-19/20width: 80rem;
          .w-fullwidth: 80rem;

          Widths are based on widths fo the parent container (in this case this section is wrapped in a div with a max-width of 1024 px)

          .w-1/4

          .w-1/3

          .w-17/20

          HTML
          <div class="text-white">
          <div class="w-1/4 h-4 bg-blue center-start pl-md sizing-border mb-sm">
          <p>.w-1/4</p>
          </div>
          <div class="w-1/3 h-4 bg-blue center-start pl-md sizing-border mb-sm">
          <p>.w-1/3</p>
          </div>
          <div class="w-17/20 h-4 bg-blue center-start pl-md sizing-border mb-sm">
          <p>.w-17/20</p>
          </div>
          </div>

          Min, Max, and Responsive Examples

          If your'e in a browser you can change screen sizes to see these react, on small widths you'll have to close the sidebar to see the smallest widths:

          .w-1/2 .min-w-full

          Although this is set at 1/2 width, the min-w class overrides the min-width to full width.

          .w-1/4 .tab:w-1/2 .scr:3/4 .lg:w-full

          Fractional widths that change with breakpoints.

          .w-full .max-scr:w-1/2

          Another responsive exmple with max:scr with a width of 1/2 on sizes below 1024px (the default scr breakpoint).

          HTML
          <div
          className="min-w-36 max-w-48 h-4 bg-blue center-start pl-md sizing-border mb-sm text-white"
          >
          <p>.w-1/2 .min-w-full</p>
          </div>
          <p className="text-lg">
          Although this is set at 1/2 width, the min-w class overrides the min-width to
          full width.
          </p>
          <div
          className="h-4 w-1/4 tab:w-1/2 scr:w-3/4 lg:w-full bg-blue center-start pl-md sizing-border mb-sm text-white"
          >
          <p>.w-1/4 .tab:w-1/2 .scr:3/4 .lg:w-full</p>
          </div>
          <p className="text-lg mb-lg">Fractional widths that change with breakpoints.</p>
          <div
          className="h-4 w-full max-scr:w-1/2 bg-blue center-start pl-md sizing-border mb-sm text-white"
          >
          <p>.w-full .max-scr:w-1/2</p>
          </div>
          <p className="text-lg">
          Another responsive exmple with max:scr with a width of 1/2 on sizes below
          1024px (the default `scr` breakpoint).
          </p>

          Screen Based Widths

          I only use these in certina cases myself which is why I only have a few values, espeically for utility classes it probably makes more sense to me for this to be a case where one can write their own SCSS, but like with everything else values can be edited in _variables.scss if you need more values:

          ClassCSS rule
          .w-1/4-screenwidth: 25vw;
          .w-1/3-screenwidth: 33vw
          .w-1/2-screenwidth: 50vw;
          .w-screenwidth: 100vw;

          Examples

          As opposed to percentage based values on the container, these are relative to the entire view port. On small widths with the sidebar closed, they will match the fractional values, but on larger widths with the sidebar open you can see the difference since those are based on the size of this section, while these are based on the size of the screen:

          .w-1/4-screen

          .w-1/2-screen

          HTML
          <div class="text-white">
          <div class="w-1/4-screen h-4 bg-blue center-start pl-md sizing-border mb-sm">
          <p>.w-1/4-screen</p>
          </div>
          <div class="w-1/2-screen h-4 bg-blue center-start pl-md sizing-border mb-sm">
          <p>.w-1/2-screen</p>
          </div>
          </div>

          Min, Max, and Responsive Examples

          Of course these can be made responsive as well:

          .w-1/4 .min-w-1/2-screen

          Although this is set at 1/4 width, the min-w class overrides the min-width to 1/2 screen

          .w-1/5 .tab:w-1/4-screen .scr:w-1/3-screen .lg:w-1/2-screen

          Fractional widths that change with breakpoints.

          .w-1/2-screen .max-scr:w-1/3-screen

          Another responsive exmple with max:scr with a width of 1/3 screen on sizes below 1024px (the default scr breakpoint).

          HTML
          <div
          class="w-1/4 min-w-1/2-screen h-4 bg-blue center-start pl-md sizing-border mb-sm text-white"
          >
          <p>.w-1/4 .min-w-1/2-screen</p>
          </div>
          <p class="text-lg">
          Although this is set at 1/4 width, the min-w class overrides the min-width to
          1/2 screen
          </p>
          <div
          class="h-4 w-1/5 tab:w-1/4-screen scr:w-1/3-screen lg:w-1/2-screen bg-blue center-start pl-md sizing-border mb-sm text-white"
          >
          <p>.w-1/5 .tab:w-1/4-screen .scr:w-1/3-screen .lg:w-1/2-screen</p>
          </div>
          <p class="text-lg mb-lg">Fractional widths that change with breakpoints.</p>
          <div
          class="h-4 w-1/2-screen max-scr:w-1/3-screen bg-blue center-start pl-md sizing-border mb-sm text-white"
          >
          <p>.w-1/2-screen .max-scr:w-1/3-screen</p>
          </div>
          <p class="text-lg">
          Another responsive exmple with max:scr with a width of 1/3 screen on sizes
          below 1024px (the default `scr` breakpoint).
          </p>

          XS - XL Widths

          Finally, widths can also work with all the xs-xl values up to 5xl which are the same as the margin and padding values. Not quite as useful in my opnion, but I thought what the heck, why not include 'em.

          ClassCSS rule
          .w-xxswidth: 0.125rem;
          .w-xswidth: 0.25rem;
          .w-smwidth: 0.5rem;
          .w-mdwidth: 0.75rem;
          .w-basewidth: 1rem;
          .w-lgwidth: 1.25rem;
          .w-xlwidth: 1.5rem;
          .w-2xlwidth: 2rem;
          .w-3xlwidth: 3rem;
          .w-4xlwidth: 4rem;
          .w-5xlwidth: 5rem;

          Examples

          using these are pretty straight forward:

          .w-5xl

          Pretty much the only examples that can fit text are the largest ones haha, since these were values origionally designed with margins and paddings in mind. Here is the html:

          <div className="text-white">
          <div className="w-5xl h-4 bg-blue center-start pl-md sizing-border mb-sm">
          <p>.w-5xl</p>
          </div>
          </div>

          Like the examples above, these also work with min, max and the breakpoint prefixes as well.

          Well that's it for widths. Happy Coding!

          © 2025 Simple Scss Utilities